-
Notifications
You must be signed in to change notification settings - Fork 25
/
delete_channel.go
42 lines (34 loc) · 932 Bytes
/
delete_channel.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
package examples
import (
"fmt"
"net/url"
"github.com/OctopusDeploy/go-octopusdeploy/octopusdeploy"
)
// DeleteChannelExample provides an example of how to delete a channel from
// Octopus Deploy through the Go API client.
func DeleteChannelExample() {
var (
apiKey string = "API-YOUR_API_KEY"
octopusURL string = "https://your_octopus_url"
spaceID string = "space-id"
// channel values
channelID string = "channel-id"
)
apiURL, err := url.Parse(octopusURL)
if err != nil {
_ = fmt.Errorf("error parsing URL for Octopus API: %v", err)
return
}
client, err := octopusdeploy.NewClient(nil, apiURL, apiKey, spaceID)
if err != nil {
_ = fmt.Errorf("error creating API client: %v", err)
return
}
// delete channel
err = client.Channels.DeleteByID(channelID)
if err != nil {
_ = fmt.Errorf("error deleting channel: %v", err)
return
}
fmt.Printf("channel deleted: (%s)\n", channelID)
}