All URIs are relative to https://api.segmentapis.com
Method | HTTP request | Description |
---|---|---|
CreateLabel | Post /labels | Create Label |
DeleteLabel | Delete /labels/{key}/{value} | Delete Label |
ListLabels | Get /labels | List Labels |
CreateLabel201Response CreateLabel(ctx).CreateLabelV1Input(createLabelV1Input).Execute()
Create Label
package main
import (
"context"
"fmt"
"os"
api "github.com/segmentio/public-api-sdk-go"
)
func main() {
createLabelV1Input := *api.NewCreateLabelV1Input(*api.NewLabelV1("Key_example", "Value_example")) // CreateLabelV1Input |
configuration := api.NewConfiguration()
apiClient := api.NewAPIClient(configuration)
token := "<BEARER_TOKEN>"
ctx := context.WithValue(context.Background(), api.ContextAccessToken, token)
resp, r, err := apiClient.LabelsAPI.CreateLabel(ctx).CreateLabelV1Input(createLabelV1Input).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LabelsAPI.CreateLabel``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
responseErrors := api.UnwrapFullErrors(err)
if responseErrors != nil {
for _, responseError := range responseErrors.Errors {
fmt.Fprintf(os.Stderr, "Full error message: %v\n", *responseError.Message)
}
}
}
// response from `CreateLabel`: CreateLabel201Response
fmt.Fprintf(os.Stdout, "Response from `LabelsAPI.CreateLabel`: %v\n", resp.GetData())
}
Other parameters are passed through a pointer to a apiCreateLabelRequest struct via the builder pattern
Name | Type | Description | Notes |
---|---|---|---|
createLabelV1Input | CreateLabelV1Input |
- Content-Type: application/json, application/vnd.segment.v1+json, application/vnd.segment.v1beta+json, application/vnd.segment.v1alpha+json
- Accept: application/vnd.segment.v1+json, application/json, application/vnd.segment.v1beta+json, application/vnd.segment.v1alpha+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
DeleteLabel200Response DeleteLabel(ctx, key, value).Execute()
Delete Label
package main
import (
"context"
"fmt"
"os"
api "github.com/segmentio/public-api-sdk-go"
)
func main() {
key := "environment" // string |
value := "yolo" // string |
configuration := api.NewConfiguration()
apiClient := api.NewAPIClient(configuration)
token := "<BEARER_TOKEN>"
ctx := context.WithValue(context.Background(), api.ContextAccessToken, token)
resp, r, err := apiClient.LabelsAPI.DeleteLabel(ctx, key, value).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LabelsAPI.DeleteLabel``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
responseErrors := api.UnwrapFullErrors(err)
if responseErrors != nil {
for _, responseError := range responseErrors.Errors {
fmt.Fprintf(os.Stderr, "Full error message: %v\n", *responseError.Message)
}
}
}
// response from `DeleteLabel`: DeleteLabel200Response
fmt.Fprintf(os.Stdout, "Response from `LabelsAPI.DeleteLabel`: %v\n", resp.GetData())
}
Name | Type | Description | Notes |
---|---|---|---|
ctx | context.Context | context for authentication, logging, cancellation, deadlines, tracing, etc. | |
key | string | ||
value | string |
Other parameters are passed through a pointer to a apiDeleteLabelRequest struct via the builder pattern
Name | Type | Description | Notes |
---|
- Content-Type: Not defined
- Accept: application/vnd.segment.v1+json, application/json, application/vnd.segment.v1beta+json, application/vnd.segment.v1alpha+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]
ListLabels200Response ListLabels(ctx).Execute()
List Labels
package main
import (
"context"
"fmt"
"os"
api "github.com/segmentio/public-api-sdk-go"
)
func main() {
configuration := api.NewConfiguration()
apiClient := api.NewAPIClient(configuration)
token := "<BEARER_TOKEN>"
ctx := context.WithValue(context.Background(), api.ContextAccessToken, token)
resp, r, err := apiClient.LabelsAPI.ListLabels(ctx).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `LabelsAPI.ListLabels``: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
responseErrors := api.UnwrapFullErrors(err)
if responseErrors != nil {
for _, responseError := range responseErrors.Errors {
fmt.Fprintf(os.Stderr, "Full error message: %v\n", *responseError.Message)
}
}
}
// response from `ListLabels`: ListLabels200Response
fmt.Fprintf(os.Stdout, "Response from `LabelsAPI.ListLabels`: %v\n", resp.GetData())
}
This endpoint does not need any parameter.
Other parameters are passed through a pointer to a apiListLabelsRequest struct via the builder pattern
- Content-Type: Not defined
- Accept: application/vnd.segment.v1+json, application/json, application/vnd.segment.v1beta+json, application/vnd.segment.v1alpha+json
[Back to top] [Back to API list] [Back to Model list] [Back to README]