-
Notifications
You must be signed in to change notification settings - Fork 25
/
delete_certificate.go
43 lines (35 loc) · 1.02 KB
/
delete_certificate.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package examples
import (
"fmt"
"net/url"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/certificates"
"github.com/OctopusDeploy/go-octopusdeploy/v2/pkg/client"
)
// DeleteCertificateExample provides an example of how to delete a certificate
// from Octopus Deploy through the Go API client.
func DeleteCertificateExample() {
var (
apiKey string = "API-YOUR_API_KEY"
octopusURL string = "https://your_octopus_url"
spaceID string = "space-id"
// certificate values
certificateID string = "certificate-id"
)
apiURL, err := url.Parse(octopusURL)
if err != nil {
_ = fmt.Errorf("error parsing URL for Octopus API: %v", err)
return
}
client, err := client.NewClient(nil, apiURL, apiKey, spaceID)
if err != nil {
_ = fmt.Errorf("error creating API client: %v", err)
return
}
// delete certificate
err = certificates.DeleteByID(client, spaceID, certificateID)
if err != nil {
_ = fmt.Errorf("error deleting certificate: %v", err)
return
}
fmt.Printf("certificate deleted: (%s)\n", certificateID)
}