Skip to content

labd/bluestonepim-go-sdk

Repository files navigation

bluestonepim-go-sdk

Build Status codecov Go Report Card GoDoc

The Bluestone PIM Go SDK is automatically generated based on the official API specifications of Bluestone PIM. It should therefore be nearly feature complete.

The SDK was initially created for enabling the creation of the Terraform Provider for Bluestone PIM That provider enables you to use infrastructure-as-code principles with Bluestone PIM.

Note that since this SDK is automatically generated we cannot guarantee backwards compatibility between releases. Please pin the dependency correctly and be aware of potential changes when updating

Using the SDK

package main

import (
   "context"
   "errors"
   "fmt"
   "github.com/labd/bluestonepim-go-sdk/pim"
   "log"
   "math/rand"
   "time"

   "golang.org/x/oauth2/clientcredentials"
)

func main() {

   // Create the new client. When an empty value is passed it will use the CTP_*
   // environment variables to get the value. The HTTPClient arg is optional,
   // and when empty will automatically be created using the env values.
   oauth2Config := &clientcredentials.Config{
      ClientID:     "<your-client-id>",
      ClientSecret: "<your-client-secret",
      TokenURL:     "https://idp.bluestonepim.com/op/token",
   }
   
   ctx := context.Background()

   httpClient := oauth2Config.Client(ctx)

   client, err := pim.NewClientWithResponses(
      fmt.Sprintf("%s/pim", "https://api.bluestonepim.com"),
      pim.WithHTTPClient(httpClient),
   )
   if err != nil {
      log.Fatal(err)
   }
   
   // Create a new category
   response, err := client.CreateCategoryWithResponse(ctx,
      &pim.CreateCategoryParams{
         Validation: "NAME",
      },
      pim.CreateCategoryJSONRequestBody{
         Name:     "my category name",
         Number:   "my-category-key",
      },
   )
    if err != nil {
        log.Fatal(err)
    }
}

Generating code

To re-generate the API take the following steps:

Releases

No releases published

Sponsor this project

 

Packages

No packages published

Languages