Skip to content

patrickcping/pingone-go-sdk-v2

Repository files navigation

PingOne Administration GO SDK

The PingOne GO SDK provides a set of functions and stucts that help with interacting with the PingOne public cloud API.

The code is intended to be delivered as a sample, until an official GO SDK is released from Ping Identity. As such, the code is highly likely to change significantly between releases.

Code for each service is generated with the help of the OpenAPI Generator.

Packages

The SDK provides a core package, and a package per PingOne service, each with their own directory off the root of the project:

  • authorize - Documentation - for the PingOne Authorize service
  • credentials - Documentation - for the PingOne Credentials service, part of PingOne Neo
  • management - Documentation - for the PingOne platform common and SSO services
  • mfa - Documentation - for the PingOne MFA service
  • risk - Documentation - for the PingOne Protect service
  • verify - Documentation - for the PingOne Verify service, part of PingOne Neo

Getting Started

The client can be invoked using the following syntax:

...

import (
	"context"

	"github.com/patrickcping/pingone-go-sdk-v2/pingone"
)

...

config := &pingone.Config{
	ClientID:      clientId,
	ClientSecret:  clientSecret,
	EnvironmentID: environmentId,
	AccessToken:   accessToken,
	RegionCode:    regionCode,
}

client, err := config.APIClient(ctx)
if err != nil {
	return nil, err
}

The result is an object with clients initialised for each service:

  • client.AuthorizeAPIClient
  • client.CredentialsAPIClient
  • client.ManagementAPIClient
  • client.MFAAPIClient
  • client.RiskAPIClient
  • client.VerifyAPIClient

In the above, if an AccessToken is provided, this will be verified and used. If the AccessToken is not provided, the SDK will retrieve an access token from the provided ClientID, ClientSecret, EnvironmentID and RegionCode parameters.

The client SDK defaults to production hostnames, and the RegionCode is used to add the relevant suffix to the hostname. For example, EU as a RegionCode value with suffix the service hostname with .eu. Hostnames can be overridden with the optional APIHostnameOverride, and AuthHostnameOverride parameters.

An API call can be made against the API objects, as in the following example to get all environments in a tenant:

...

resp, r, err := client.ManagementAPIClient.EnvironmentsApi.ReadAllEnvironments(ctx).Execute()
if err != nil {
	return nil, err
}
...

Contributing

Each package is generated from an underlying OpenAPI 3 specification. Currently the OpenAPI 3 specification is stored in the ./<<module>>/generate/pingone-<<module>>.yml file, although this will be subject to change in the future.

Once this file has been updated, from the module directory itself run make generate. This will generate the required api_*.go files, model_*.go files and associated documentation.

Before raising a Pull request, the resulting code can be checked using the make devcheck command. This will build, lint and verify the code.