github.com/aiven/aiven-go-client@v1.36.0/service_tags.go (about) 1 package aiven 2 3 type ( 4 // ServiceTagsHandler is the client which interacts with the Aiven service tags endpoints. 5 ServiceTagsHandler struct { 6 client *Client 7 } 8 9 // ServiceTagsRequest contains the parameters used to set service tags. 10 ServiceTagsRequest struct { 11 Tags map[string]string `json:"tags"` 12 } 13 14 // ServiceTagsResponse represents the response from Aiven for listing service tags. 15 ServiceTagsResponse struct { 16 APIResponse 17 Tags map[string]string `json:"tags"` 18 } 19 ) 20 21 // Set sets service tags with the given parameters. 22 func (h *ServiceTagsHandler) Set(project, service string, req ServiceTagsRequest) (*ServiceTagsResponse, error) { 23 path := buildPath("project", project, "service", service, "tags") 24 bts, err := h.client.doPutRequest(path, req) 25 if err != nil { 26 return nil, err 27 } 28 29 var rsp ServiceTagsResponse 30 if errR := checkAPIResponse(bts, &rsp); errR != nil { 31 return nil, errR 32 } 33 34 return &rsp, nil 35 } 36 37 // Get returns a list of all service tags. 38 func (h *ServiceTagsHandler) Get(project, service string) (*ServiceTagsResponse, error) { 39 path := buildPath("project", project, "service", service, "tags") 40 bts, err := h.client.doGetRequest(path, nil) 41 if err != nil { 42 return nil, err 43 } 44 45 var rsp ServiceTagsResponse 46 if errR := checkAPIResponse(bts, &rsp); errR != nil { 47 return nil, errR 48 } 49 50 return &rsp, nil 51 }