sailpoint

package module
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 3, 2023 License: MIT Imports: 16 Imported by: 0

README

golang-sdk

Create your project
go mod init github.com/github-repo-name/projectname
Create sdk.go file and copy the below code into the file
package main

import (
	"context"
	"fmt"
	"os"

	sailpoint "github.com/sailpoint-oss/sailpoint-api-client-go"
)

func main() {

	ctx := context.TODO()
	configuration := sailpoint.NewDefaultConfiguration()
	apiClient := sailpoint.NewAPIClient(configuration)

	resp, r, err := apiClient.V3.AccountsApi.ListAccounts(ctx).Execute()
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `AccountsApi.ListAccount``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `ListAccounts`: []Account
	fmt.Fprintf(os.Stdout, "First response from `AccountsApi.ListAccount`: %v\n", resp[0].Name)

}
Create a configuration file or save your configuration as environment variables

You can create a local configuration file using the CLI tool or you can store your configuration in environment variables

  • SAIL_BASE_URL
  • SAIL_CLIENT_ID
  • SAIL_CLIENT_SECRET
Install sdk
go mod tidy
Run the example
go run sdk.go
Handling Pagination

there is a built in pagination function that can be used to automatically call and collect responses from APIs that support pagination. Use the following syntax to call it:

import (
	"context"
	"fmt"
	"os"

	sailpoint "github.com/sailpoint-oss/sailpoint-api-client-go"
	// need to import the v3 library so we are aware of the sailpointsdk.Account struct
	sailpointsdk "github.com/sailpoint-oss/sailpoint-api-client-go/v3"
)

func main() {

	ctx := context.TODO()
	configuration := sailpoint.NewDefaultConfiguration()
	apiClient := sailpoint.NewAPIClient(configuration)

	// use the paginate function to get 1000 results instead of hitting the normal 250 limit
	resp, r, err := sailpoint.PaginateWithDefaults[sailpointsdk.Account](apiClient.V3.AccountsApi.ListAccounts(ctx))
	if err != nil {
		fmt.Fprintf(os.Stderr, "Error when calling `AccountsApi.ListAccount``: %v\n", err)
		fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
	}
	// response from `ListAccounts`: []Account
	fmt.Fprintf(os.Stdout, "First response from `AccountsApi.ListAccount`: %v\n", resp[0].Name)

}

See more uses of the SDK here.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Invoke

func Invoke(any interface{}, name string, args ...interface{}) []reflect.Value

func Paginate

func Paginate[T any](f interface{}, initialOffset int32, increment int32, limit int32) ([]T, *http.Response, error)

func PaginateSearchApi

func PaginateSearchApi(ctx context.Context, apiClient *APIClient, search v3.Search, initialOffset int32, increment int32, limit int32) ([]map[string]interface{}, *http.Response, error)

func PaginateWithDefaults

func PaginateWithDefaults[T any](f interface{}) ([]T, *http.Response, error)

Types

type APIClient

type APIClient struct {
	V3   *v3.APIClient
	V2   *v2.APIClient
	Beta *beta.APIClient
	CC   *cc.APIClient
	// contains filtered or unexported fields
}

APIClient manages communication with the IdentityNow V3 API API v3.0.0 In most cases there should be only one, shared, APIClient.

func NewAPIClient

func NewAPIClient(cfg *Configuration) *APIClient

NewAPIClient creates a new API client. Requires a userAgent string describing your application. optionally a custom http.Client to allow for advanced features such as caching.

type ClientConfiguration

type ClientConfiguration struct {
	ClientId     string
	ClientSecret string
	BaseURL      string
	TokenURL     string
	Token        string
}

type Configuration

type Configuration struct {
	Host                string            `json:"host,omitempty"`
	Scheme              string            `json:"scheme,omitempty"`
	DefaultHeader       map[string]string `json:"defaultHeader,omitempty"`
	UserAgent           string            `json:"userAgent,omitempty"`
	Debug               bool              `json:"debug,omitempty"`
	HTTPClient          *retryablehttp.Client
	ClientConfiguration ClientConfiguration
}

Configuration stores the configuration of the API client

func NewConfiguration

func NewConfiguration(clientConfiguration ClientConfiguration) *Configuration

NewConfiguration returns a new Configuration object

func NewDefaultConfiguration

func NewDefaultConfiguration() *Configuration

type Environment

type Environment struct {
	TenantURL string    `mapstructure:"tenanturl"`
	BaseURL   string    `mapstructure:"baseurl"`
	Pat       PatConfig `mapstructure:"pat"`
	OAuth     Token     `mapstructure:"oauth"`
}

type OrgConfig

type OrgConfig struct {

	//Standard Variables
	Debug             bool                   `mapstructure:"debug"`
	AuthType          string                 `mapstructure:"authtype"`
	ActiveEnvironment string                 `mapstructure:"activeenvironment"`
	Environments      map[string]Environment `mapstructure:"environments"`
}

type PatConfig

type PatConfig struct {
	ClientID     string    `mapstructure:"clientid"`
	ClientSecret string    `mapstructure:"clientsecret"`
	AccessToken  string    `mapstructure:"accesstoken"`
	Expiry       time.Time `mapstructure:"expiry"`
}

type ServerVariable

type ServerVariable struct {
	Description  string
	DefaultValue string
	EnumValues   []string
}

ServerVariable stores the information about a server variable

type Token

type Token struct {
	AccessToken string    `mapstructure:"accesstoken"`
	Expiry      time.Time `mapstructure:"expiry"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL