conductoronesdkgo

package module
v2.1.13-0...-95ca5db Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2023 License: MIT Imports: 29 Imported by: 0

README

conductorone-api

SDK Installation

go get github.com/ConductorOne/conductorone-sdk-go

SDK Example Usage

Example
package main

import (
	"context"
	conductoronesdkgo "github.com/conductorone/conductorone-sdk-go/v2"
	"github.com/conductorone/conductorone-sdk-go/v2/pkg/models/shared"
	"log"
)

func main() {
	ctx := context.Background()

	s := NewWithCredentials(ctx, &ClientCredentials{
		ClientID:     "",
		ClientSecret: "",
	} )

	res, err := s.Apps.Create(ctx, &shared.CreateAppRequest{
		Owners: []string{
			"string",
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	if res.CreateAppResponse != nil {
		// handle response
	}
}

Available Resources and Operations

Apps
Connector
AppEntitlements
AppEntitlementUserBinding
AppEntitlementOwners
AppOwners
AppReport
AppReportAction
AppResourceType
AppResource
AppResourceOwners
AppUsageControls
AppUser
Attributes
Auth
RequestCatalogManagement
Directory
PersonalClient
Roles
Policies
PolicyValidate
AppResourceSearch
AppSearch
AttributeSearch
AppEntitlementSearch
PolicySearch
RequestCatalogSearch
TaskSearch
UserSearch
Task
TaskActions
User

Error Handling

Handling errors in this SDK should largely match your expectations. All operations return a response object or an error, they will never return both. When specified by the OpenAPI spec document, the SDK will return the appropriate subclass.

Error Object Status Code Content Type
sdkerrors.SDKError 400-600 /
Example
package main

import (
	"context"
	"errors"
	conductoronesdkgo "github.com/conductorone/conductorone-sdk-go/v2"
	"github.com/conductorone/conductorone-sdk-go/v2/pkg/models/sdkerrors"
	"github.com/conductorone/conductorone-sdk-go/v2/pkg/models/shared"
	"log"
)

func main() {
	ctx := context.Background()

	s := NewWithCredentials(ctx, &ClientCredentials{
		ClientID:     "",
		ClientSecret: "",
	})
	res, err := s.Apps.Create(ctx, &shared.CreateAppRequest{
		Owners: []string{
			"string",
		},
	})
	if err != nil {

		var e *sdkerrors.SDKError
		if errors.As(err, &e) {
			// handle error
			log.Fatal(e.Error())
		}
	}
}

SDK Example Usage with Custom Server/Tenant

Example
package main

import (
	"context"
	conductoronesdkgo "github.com/conductorone/conductorone-sdk-go/v2"
	"github.com/conductorone/conductorone-sdk-go/v2/pkg/models/shared"
	"log"
)

func main() {
	ctx := context.Background()

	/* Optional Override 
	* Server URL will be extracted from client, optionally, you can
	* provide a server URL or a tenant domain (will create URL https://{tenant_domain}.conductor.one) 
	*/
	opts := []sdk.CustomSDKOption{}
	opt, _ := sdk.WithTenantCustom("Server URL or Tenant Domain")
	opts = append(opts, opt)

	s := NewWithCredentials(ctx, &ClientCredentials{
		ClientID:     "",
		ClientSecret: "",
	} opts...)

	res, err := s.Apps.Create(ctx, &shared.CreateAppRequest{
		Owners: []string{
			"string",
		},
	})
	if err != nil {
		log.Fatal(err)
	}

	if res.CreateAppResponse != nil {
		// handle response
	}
}

Maturity

This SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage to a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally looking for the latest version.

Contributions

While we value open-source contributions to this SDK, this library is generated programmatically. Feel free to open a PR or a Github issue as a proof of concept and we'll do our best to include it in a future release !

SDK Created by Speakeasy

Documentation

Index

Constants

View Source
const ClientIdGolangSDK = "2RCzHlak5q7CY14SdBc8HoZEJRf"

Variables

View Source
var (
	ErrInvalidClientSecret = errors.New("invalid client secret")
	ErrInvalidClientID     = errors.New("invalid client id")
)
View Source
var ServerList = []string{

	"https://{tenantDomain}.conductor.one",
}

ServerList contains the list of servers available to the SDK

Functions

func Bool

func Bool(b bool) *bool

Bool provides a helper function to return a pointer to a bool

func Float32

func Float32(f float32) *float32

Float32 provides a helper function to return a pointer to a float32

func Float64

func Float64(f float64) *float64

Float64 provides a helper function to return a pointer to a float64

func Int

func Int(i int) *int

Int provides a helper function to return a pointer to an int

func Int64

func Int64(i int64) *int64

Int64 provides a helper function to return a pointer to an int64

func NewTokenSource

func NewTokenSource(ctx context.Context, clientID string, clientSecret string, tokenHost string) (oauth2.TokenSource, error)

func String

func String(s string) *string

String provides a helper function to return a pointer to a string

Types

type AppEntitlementOwners

type AppEntitlementOwners struct {
	// contains filtered or unexported fields
}

func (*AppEntitlementOwners) Add

Add Add an owner to a given app entitlement.

func (*AppEntitlementOwners) List

List List owners for a given app entitlement.

func (*AppEntitlementOwners) Remove

Remove Remove an owner from a given app entitlement.

func (*AppEntitlementOwners) Set

Set Sets the owners for a given app entitlement to the specified list of users.

type AppEntitlementSearch

type AppEntitlementSearch struct {
	// contains filtered or unexported fields
}

func (*AppEntitlementSearch) Search

Search Search app entitlements based on filters specified in the request body.

type AppEntitlementUserBinding

type AppEntitlementUserBinding struct {
	// contains filtered or unexported fields
}

func (*AppEntitlementUserBinding) ListAppUsersForIdentityWithGrant

ListAppUsersForIdentityWithGrant - List App Users For Identity With Grant Returns a list of app users for the identity in the app. If that app user also has a grant to the entitlement from the request, data about the grant is also returned. It will always return ALL app users for this identity, but only SOME may have grant data.

type AppEntitlements

type AppEntitlements struct {
	// contains filtered or unexported fields
}

func (*AppEntitlements) Get

Get Get an app entitlement by ID.

func (*AppEntitlements) List

List List app entitlements associated with an app.

func (*AppEntitlements) ListForAppResource

ListForAppResource - List For App Resource List app entitlements associated with an app resource.

func (*AppEntitlements) ListForAppUser

ListForAppUser - List For App User List app entitlements associated with an app user.

func (*AppEntitlements) ListUsers

ListUsers - List Users List the users, as AppEntitlementUsers objects, of an app entitlement.

func (*AppEntitlements) Update

Update Update an app entitlement by ID.

type AppOwners

type AppOwners struct {
	// contains filtered or unexported fields
}

func (*AppOwners) Add

Add Adds an owner to an app.

func (*AppOwners) List

List List owners of an app.

func (*AppOwners) Remove

Remove Removes an owner from an app.

func (*AppOwners) Set

Set Sets the owners for a given app to the specified list of users.

type AppReport

type AppReport struct {
	// contains filtered or unexported fields
}

func (*AppReport) List

List Get a list of reports for the given app.

type AppReportAction

type AppReportAction struct {
	// contains filtered or unexported fields
}

func (*AppReportAction) GenerateReport

GenerateReport - Generate Report Generate a report for the given app.

type AppResource

type AppResource struct {
	// contains filtered or unexported fields
}

func (*AppResource) Get

Get Invokes the c1.api.app.v1.AppResourceService.Get method.

func (*AppResource) List

List Invokes the c1.api.app.v1.AppResourceService.List method.

type AppResourceOwners

type AppResourceOwners struct {
	// contains filtered or unexported fields
}

func (*AppResourceOwners) List

List List all owners of an app resource.

type AppResourceSearch

type AppResourceSearch struct {
	// contains filtered or unexported fields
}

func (*AppResourceSearch) SearchAppResourceTypes

SearchAppResourceTypes - Search App Resource Types Search app resources based on filters specified in the request body.

type AppResourceType

type AppResourceType struct {
	// contains filtered or unexported fields
}

func (*AppResourceType) Get

Get Get an app resource type.

func (*AppResourceType) List

List List app resource types.

type AppSearch

type AppSearch struct {
	// contains filtered or unexported fields
}

func (*AppSearch) Search

Search Search apps based on filters specified in the request body.

type AppUsageControls

type AppUsageControls struct {
	// contains filtered or unexported fields
}

func (*AppUsageControls) Get

Get Get usage controls, as an AppUsageControls object which describes some peripheral configuration, for an app.

func (*AppUsageControls) Update

Update Update usage controls for an app.

type AppUser

type AppUser struct {
	// contains filtered or unexported fields
}

func (*AppUser) Update

Update Update an app user by ID. Only the fields specified in the update mask are updated.

Currently, only the appUserType, and identityUserId fields can be updated.

type Apps

type Apps struct {
	// contains filtered or unexported fields
}

func (*Apps) Create

Create Create a new app.

func (*Apps) Delete

Delete Delete an app.

func (*Apps) Get

Get Get an app by ID.

func (*Apps) List

List List all apps.

func (*Apps) Update

Update Update an existing app.

type AttributeSearch

type AttributeSearch struct {
	// contains filtered or unexported fields
}

func (*AttributeSearch) SearchAttributeValues

SearchAttributeValues - Search Attribute Values Search attributes based on filters specified in the request body.

type Attributes

type Attributes struct {
	// contains filtered or unexported fields
}

func (*Attributes) CreateAttributeValue

CreateAttributeValue - Create Attribute Value Create a new attribute value.

func (*Attributes) DeleteAttributeValue

DeleteAttributeValue - Delete Attribute Value Delete an attribute value by id.

func (*Attributes) GetAttributeValue

GetAttributeValue - Get Attribute Value Get an attribute value by id.

func (*Attributes) ListAttributeTypes

ListAttributeTypes - List Attribute Types List all attribute types.

func (*Attributes) ListAttributeValues

ListAttributeValues - List Attribute Values List all attribute values for a given attribute type.

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

func (*Auth) Introspect

Introspect Introspect returns the current user's principle_id, user_id and a list of roles, permissions, and enabled features.

type ClientConfig

type ClientConfig struct {
	// contains filtered or unexported fields
}

func NormalizeTenant

func NormalizeTenant(input string) (*ClientConfig, error)

func ParseClientID

func ParseClientID(input string) (*ClientConfig, error)

func (*ClientConfig) GetServerURL

func (c *ClientConfig) GetServerURL() string

GetServerURL returns the server URL. If serverURL is empty (""), it constructs the server URL using the tenant. However, if the tenant is also empty, then it will return an empty string.

func (*ClientConfig) ServerURL

func (c *ClientConfig) ServerURL() string

ServerURL returns the server URL.

func (*ClientConfig) SetServerURL

func (c *ClientConfig) SetServerURL(serverURL string) error

func (*ClientConfig) SetTenant

func (c *ClientConfig) SetTenant(tenant string) error

func (*ClientConfig) Tenant

func (c *ClientConfig) Tenant() string

func (*ClientConfig) UseWithServer

func (c *ClientConfig) UseWithServer() bool

func (*ClientConfig) UseWithTenant

func (c *ClientConfig) UseWithTenant() bool

type ClientCredentials

type ClientCredentials struct {
	ClientID     string
	ClientSecret string
}

func LoginFlow

func LoginFlow(
	ctx context.Context,
	tenantName string,
	clientID string,
	personalClientCredentialDisplayName string,
	cb func(validateDetails *DeviceCodeResponse) error,
) (*ClientCredentials, error)

type ConductoroneAPI

type ConductoroneAPI struct {
	Apps                      *Apps
	Connector                 *Connector
	AppEntitlements           *AppEntitlements
	AppEntitlementUserBinding *AppEntitlementUserBinding
	AppEntitlementOwners      *AppEntitlementOwners
	AppOwners                 *AppOwners
	AppReport                 *AppReport
	AppReportAction           *AppReportAction
	AppResourceType           *AppResourceType
	AppResource               *AppResource
	AppResourceOwners         *AppResourceOwners
	AppUsageControls          *AppUsageControls
	AppUser                   *AppUser
	Attributes                *Attributes
	Auth                      *Auth
	RequestCatalogManagement  *RequestCatalogManagement
	Directory                 *Directory
	PersonalClient            *PersonalClient
	Roles                     *Roles
	Policies                  *Policies
	PolicyValidate            *PolicyValidate
	AppResourceSearch         *AppResourceSearch
	AppSearch                 *AppSearch
	AttributeSearch           *AttributeSearch
	AppEntitlementSearch      *AppEntitlementSearch
	PolicySearch              *PolicySearch
	RequestCatalogSearch      *RequestCatalogSearch
	TaskSearch                *TaskSearch
	UserSearch                *UserSearch
	Task                      *Task
	TaskActions               *TaskActions
	User                      *User
	// contains filtered or unexported fields
}

ConductoroneAPI - ConductorOne API: The ConductorOne API is a HTTP API for managing ConductorOne resources.

func New

func New(opts ...SDKOption) *ConductoroneAPI

New creates a new instance of the SDK with the provided options

func NewWithCredentials

func NewWithCredentials(ctx context.Context, cred *ClientCredentials, opts ...CustomSDKOption) (*ConductoroneAPI, error)

type Connector

type Connector struct {
	// contains filtered or unexported fields
}

func (*Connector) Create

Create Create a configured connector.

func (*Connector) CreateDelegated

CreateDelegated - Create Delegated Create a connector that is pending a connector config.

func (*Connector) Delete

Delete Delete a connector.

func (*Connector) GetCredentials

GetCredentials - Get Credentials Get credentials for a connector.

func (*Connector) List

List List connectors for an app.

func (*Connector) RevokeCredential

RevokeCredential - Revoke Credential Revoke credentials for a connector.

func (*Connector) RotateCredential

RotateCredential - Rotate Credential Rotate credentials for a connector.

func (*Connector) Update

Update Update a connector.

func (*Connector) UpdateDelegated

UpdateDelegated - Update Delegated Update a delegated connector.

type CustomOptions

type CustomOptions struct {
	*ClientConfig
	// contains filtered or unexported fields
}

type CustomSDKOption

type CustomSDKOption func(*CustomOptions)

func WithLog

func WithLog(logger *zap.Logger) CustomSDKOption

func WithTLSConfig

func WithTLSConfig(tlsConfig *tls.Config) CustomSDKOption

func WithTenantCustom

func WithTenantCustom(input string) (CustomSDKOption, error)

func WithUserAgent

func WithUserAgent(userAgent string) CustomSDKOption

type DeviceCodeResponse

type DeviceCodeResponse struct {
	DeviceCode      string `json:"device_code"`
	UserCode        string `json:"user_code"`
	VerificationURI string `json:"verification_uri_complete"`
	ExpiresIn       int64  `json:"expires_in"`
	Interval        int64  `json:"interval"`
}

type Directory

type Directory struct {
	// contains filtered or unexported fields
}

func (*Directory) Create

Create Create a directory.

func (*Directory) Delete

Delete Delete a directory by app_id.

func (*Directory) Get

Get Get a directory by app_id.

type HTTPClient

type HTTPClient interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPClient provides an interface for suplying the SDK with a custom HTTP client

type PersonalClient

type PersonalClient struct {
	// contains filtered or unexported fields
}

func (*PersonalClient) Create

Create Create creates a new PersonalClient object for the current User.

type Policies

type Policies struct {
	// contains filtered or unexported fields
}

func (*Policies) Create

Create Create a policy.

func (*Policies) Delete

Delete Delete a policy by ID.

func (*Policies) Get

Get Get a policy by ID.

func (*Policies) List

List List policies.

func (*Policies) Update

Update Update a policy by providing a policy object and an update mask.

type PolicySearch

type PolicySearch struct {
	// contains filtered or unexported fields
}

func (*PolicySearch) Search

Search Search policies based on filters specified in the request body.

type PolicyValidate

type PolicyValidate struct {
	// contains filtered or unexported fields
}

func (*PolicyValidate) ValidateCEL

ValidateCEL - Validate Cel Validate policies

type RequestCatalogManagement

type RequestCatalogManagement struct {
	// contains filtered or unexported fields
}

func (*RequestCatalogManagement) AddAccessEntitlements

AddAccessEntitlements - Add Access Entitlements Add visibility bindings (access entitlements) to a catalog.

func (*RequestCatalogManagement) AddAppEntitlements

AddAppEntitlements - Add App Entitlements Add requestable entitlements to a catalog.

func (*RequestCatalogManagement) Create

Create Creates a new request catalog.

func (*RequestCatalogManagement) List

List Get a list of request catalogs.

func (*RequestCatalogManagement) ListEntitlementsForAccess

ListEntitlementsForAccess - List Entitlements For Access List visibility bindings (access entitlements) for a catalog.

func (*RequestCatalogManagement) ListEntitlementsPerCatalog

ListEntitlementsPerCatalog - List Entitlements Per Catalog List entitlements in a catalog that are requestable.

func (*RequestCatalogManagement) RemoveAccessEntitlements

RemoveAccessEntitlements - Remove Access Entitlements Remove visibility bindings (access entitlements) to a catalog.

func (*RequestCatalogManagement) RemoveAppEntitlements

RemoveAppEntitlements - Remove App Entitlements Remove requestable entitlements from a catalog.

type RequestCatalogSearch

type RequestCatalogSearch struct {
	// contains filtered or unexported fields
}

func (*RequestCatalogSearch) SearchEntitlements

SearchEntitlements - Search Entitlements Search request catalogs based on filters specified in the request body.

type Roles

type Roles struct {
	// contains filtered or unexported fields
}

func (*Roles) Get

Get Get a role by id.

func (*Roles) List

List List all roles for the current user.

func (*Roles) Update

Update Update a role by passing a Role object.

type SDKOption

type SDKOption func(*ConductoroneAPI)

func WithClient

func WithClient(client HTTPClient) SDKOption

WithClient allows the overriding of the default HTTP client used by the SDK

func WithRetryConfig

func WithRetryConfig(retryConfig utils.RetryConfig) SDKOption

func WithSecurity

func WithSecurity(security shared.Security) SDKOption

func WithSecuritySource

func WithSecuritySource(security func(context.Context) (shared.Security, error)) SDKOption

WithSecuritySource configures the SDK to invoke the Security Source function on each method call to determine authentication

func WithServerIndex

func WithServerIndex(serverIndex int) SDKOption

WithServerIndex allows the overriding of the default server by index

func WithServerURL

func WithServerURL(serverURL string) SDKOption

WithServerURL allows the overriding of the default server URL

func WithTemplatedServerURL

func WithTemplatedServerURL(serverURL string, params map[string]string) SDKOption

WithTemplatedServerURL allows the overriding of the default server URL with a templated URL populated with the provided parameters

func WithTenant

func WithTenant(input string) (SDKOption, error)

func WithTenantDomain

func WithTenantDomain(tenantDomain string) SDKOption

WithTenantDomain allows setting the tenantDomain variable for url substitution

type Task

type Task struct {
	// contains filtered or unexported fields
}

func (*Task) CreateGrantTask

CreateGrantTask - Create Grant Task Create a grant task

func (*Task) CreateRevokeTask

CreateRevokeTask - Create Revoke Task Create a revoke task

func (*Task) Get

Get Get a task by ID

type TaskActions

type TaskActions struct {
	// contains filtered or unexported fields
}

func (*TaskActions) Approve

Approve Invokes the c1.api.task.v1.TaskActionsService.Approve method.

func (*TaskActions) Comment

Comment Invokes the c1.api.task.v1.TaskActionsService.Comment method.

func (*TaskActions) Deny

Deny Invokes the c1.api.task.v1.TaskActionsService.Deny method.

func (*TaskActions) EscalateToEmergencyAccess

EscalateToEmergencyAccess - Escalate To Emergency Access Invokes the c1.api.task.v1.TaskActionsService.EscalateToEmergencyAccess method.

func (*TaskActions) Restart

Restart Invokes the c1.api.task.v1.TaskActionsService.Restart method.

type TaskSearch

type TaskSearch struct {
	// contains filtered or unexported fields
}

func (*TaskSearch) Search

Search Search tasks based on filters specified in the request body.

type User

type User struct {
	// contains filtered or unexported fields
}

func (*User) Get

Get Get a user by ID.

type UserSearch

type UserSearch struct {
	// contains filtered or unexported fields
}

func (*UserSearch) Search

Search Search users based on filters specified in the request body.

Directories

Path Synopsis
pkg

Jump to

Keyboard shortcuts

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