github.com/IBM-Cloud/bluemix-go@v0.0.0-20240423071914-9e96525baef4/api/container/containerv1/webhooks.go (about) 1 package containerv1 2 3 import ( 4 "fmt" 5 6 "github.com/IBM-Cloud/bluemix-go/client" 7 ) 8 9 //WebHook is the web hook 10 type WebHook struct { 11 Level string 12 Type string 13 URL string 14 } 15 16 //Webhooks interface 17 type Webhooks interface { 18 List(clusterName string, target ClusterTargetHeader) ([]WebHook, error) 19 Add(clusterName string, params WebHook, target ClusterTargetHeader) error 20 } 21 22 type webhook struct { 23 client *client.Client 24 } 25 26 func newWebhookAPI(c *client.Client) Webhooks { 27 return &webhook{ 28 client: c, 29 } 30 } 31 32 //List ... 33 func (r *webhook) List(name string, target ClusterTargetHeader) ([]WebHook, error) { 34 rawURL := fmt.Sprintf("/v1/clusters/%s/webhooks", name) 35 webhooks := []WebHook{} 36 _, err := r.client.Get(rawURL, &webhooks, target.ToMap()) 37 if err != nil { 38 return nil, err 39 } 40 41 return webhooks, err 42 } 43 44 //Add ... 45 func (r *webhook) Add(name string, params WebHook, target ClusterTargetHeader) error { 46 rawURL := fmt.Sprintf("/v1/clusters/%s/webhooks", name) 47 _, err := r.client.Post(rawURL, params, nil, target.ToMap()) 48 return err 49 }