Skip to content

Latest commit

 

History

History
235 lines (156 loc) · 6.52 KB

LabelsAPI.md

File metadata and controls

235 lines (156 loc) · 6.52 KB

\LabelsAPI

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

Operation: CreateLabel

CreateLabel201Response CreateLabel(ctx).CreateLabelV1Input(createLabelV1Input).Execute()

Create Label

Example

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())
}

Path Parameters

Other Parameters

Other parameters are passed through a pointer to a apiCreateLabelRequest struct via the builder pattern

Name Type Description Notes
createLabelV1Input CreateLabelV1Input

Return type

CreateLabel201Response

Authorization

token

HTTP request headers

  • 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]

Operation: DeleteLabel

DeleteLabel200Response DeleteLabel(ctx, key, value).Execute()

Delete Label

Example

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())
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
key string
value string

Other Parameters

Other parameters are passed through a pointer to a apiDeleteLabelRequest struct via the builder pattern

Name Type Description Notes

Return type

DeleteLabel200Response

Authorization

token

HTTP request headers

  • 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]

Operation: ListLabels

ListLabels200Response ListLabels(ctx).Execute()

List Labels

Example

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())
}

Path Parameters

This endpoint does not need any parameter.

Other Parameters

Other parameters are passed through a pointer to a apiListLabelsRequest struct via the builder pattern

Return type

ListLabels200Response

Authorization

token

HTTP request headers

  • 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]