directorysync

package
v3.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2024 License: MIT Imports: 11 Imported by: 0

README

directorysync

Go Report Card

A Go package to make requests to the WorkOS Directory Sync API.

Install

go get -u github.com/workos/workos-go/v3/pkg/directorysync

How it works

See the Directory Sync integration guide.

Documentation

Overview

Package `directorysync` provides a client wrapping the WorkOS Directory Sync API.

Index

Constants

View Source
const ResponseLimit = 10

ResponseLimit is the default number of records to limit a response to.

Variables

View Source
var (
	DefaultClient = &Client{
		Endpoint: "https://api.workos.com",
	}
)

DefaultClient is the client used by SetAPIKey and Directory Sync functions.

Functions

func DeleteDirectory

func DeleteDirectory(
	ctx context.Context,
	opts DeleteDirectoryOpts,
) error

DeleteDirectory deletes a directory

func SetAPIKey

func SetAPIKey(apiKey string)

SetAPIKey sets the WorkOS API key for Directory Sync requests.

Types

type Client

type Client struct {
	// The WorkOS API Key. It can be found in https://dashboard.workos.com/api-keys.
	APIKey string

	// The http.Client that is used to get Directory Sync records from WorkOS.
	// Defaults to http.Client.
	HTTPClient *http.Client

	// The endpoint to WorkOS API. Defaults to https://api.workos.com.
	Endpoint string
	// contains filtered or unexported fields
}

Client represents a client that performs Directory Sync requests to the WorkOS API.

func (*Client) DeleteDirectory

func (c *Client) DeleteDirectory(
	ctx context.Context,
	opts DeleteDirectoryOpts,
) error

DeleteDirectory deletes a Connection.

func (*Client) GetDirectory

func (c *Client) GetDirectory(
	ctx context.Context,
	opts GetDirectoryOpts,
) (Directory, error)

GetDirectory gets a Directory.

func (*Client) GetGroup

func (c *Client) GetGroup(
	ctx context.Context,
	opts GetGroupOpts,
) (Group, error)

GetGroup gets a provisioned Group for a Directory.

func (*Client) GetUser

func (c *Client) GetUser(
	ctx context.Context,
	opts GetUserOpts,
) (User, error)

GetUser gets a provisioned User for a Directory Endpoint.

func (*Client) ListDirectories

func (c *Client) ListDirectories(
	ctx context.Context,
	opts ListDirectoriesOpts,
) (ListDirectoriesResponse, error)

ListDirectories gets details of existing Directories.

func (*Client) ListGroups

func (c *Client) ListGroups(
	ctx context.Context,
	opts ListGroupsOpts,
) (ListGroupsResponse, error)

ListGroups gets a list of provisioned Groups for a Directory Endpoint.

func (*Client) ListUsers

func (c *Client) ListUsers(
	ctx context.Context,
	opts ListUsersOpts,
) (ListUsersResponse, error)

ListUsers gets a list of provisioned Users for a Directory.

type DeleteDirectoryOpts

type DeleteDirectoryOpts struct {
	// Directory unique identifier.
	Directory string
}

DeleteDirectoryOpts contains the options to delete a Connection.

type Directory

type Directory struct {
	// Directory unique identifier.
	ID string `json:"id"`

	// Directory name.
	Name string `json:"name"`

	// Directory domain.
	Domain string `json:"domain"`

	// Externally used identifier for the Directory.
	ExternalKey string `json:"external_key"`

	// Type of the directory.
	Type DirectoryType `json:"type"`

	// Linked status for the Directory.
	State DirectoryState `json:"state"`

	// The user's directory provider's Identifier
	IdpID string `json:"idp_id"`

	// Identifier for the Directory's Organization.
	OrganizationID string `json:"organization_id"`

	// The timestamp of when the Directory was created.
	CreatedAt string `json:"created_at"`

	// The timestamp of when the Directory was updated.
	UpdatedAt string `json:"updated_at"`
}

Directory contains data about a project's directory.

func GetDirectory

func GetDirectory(
	ctx context.Context,
	opts GetDirectoryOpts,
) (Directory, error)

GetDirectory gets a Directory.

type DirectoryState

type DirectoryState string

DirectoryState represents if a Directory is linked or unlinked.

const (
	Linked             DirectoryState = "linked"
	Unlinked           DirectoryState = "unlinked"
	InvalidCredentials DirectoryState = "invalid_credentials"
)

Constants that enumerate the linked status of a Directory.

type DirectoryType

type DirectoryType string

DirectoryType represents a Directory type.

const (
	AzureSCIMV2_0   DirectoryType = "azure scim v2.0"
	BambooHr        DirectoryType = "bamboohr"
	BreatheHr       DirectoryType = "breathe hr"
	CezanneHr       DirectoryType = "cezanne hr"
	CyberArk        DirectoryType = "cyberark scim v2.0"
	FourthHr        DirectoryType = "fourth hr"
	GSuiteDirectory DirectoryType = "gsuite directory"
	GenericSCIMV2_0 DirectoryType = "generic scim v2.0"
	Hibob           DirectoryType = "hibob"
	JumpCloud       DirectoryType = "jump cloud scim v2.0"
	OktaSCIMV2_0    DirectoryType = "okta scim v2.0"
	OneLogin        DirectoryType = "onelogin scim v2.0"
	PeopleHr        DirectoryType = "people hr"
	Personio        DirectoryType = "personio"
	PingFederate    DirectoryType = "pingfederate scim v2.0"
	Rippling        DirectoryType = "rippling scim v2.0"
	SFTP            DirectoryType = "sftp"
	SFTPWorkday     DirectoryType = "sftp workday"
	Workday         DirectoryType = "workday"
)

Constants that enumerate the available Directory types.

type GetDirectoryOpts

type GetDirectoryOpts struct {
	// Directory unique identifier.
	Directory string
}

GetDirectoryOpts contains the options to request details for an Directory.

type GetGroupOpts

type GetGroupOpts struct {
	// Directory Group unique identifier.
	Group string
}

GetGroupOpts contains the options to request details for a provisioned Directory Group.

type GetUserOpts

type GetUserOpts struct {
	// Directory User unique identifier.
	User string
}

GetUserOpts contains the options to request details for a provisioned Directory User.

type Group

type Group struct {
	// The Group's unique identifier.
	ID string `json:"id"`

	// The Group's name.
	Name string `json:"name"`

	// The Group's unique identifier assigned by the Directory Provider.
	IdpID string `json:"idp_id"`

	// The identifier of the Directory the group belongs to.
	DirectoryID string `json:"directory_id"`

	// The identifier for the Organization in which the Directory resides.
	OrganizationID string `json:"organization_id"`

	// The Group's created at date.
	CreatedAt string `json:"created_at"`

	// The Group's updated at date.
	UpdatedAt string `json:"updated_at"`

	// The Group's raw attributes in raw encoded JSON.
	RawAttributes json.RawMessage `json:"raw_attributes"`
}

Group contains data about a provisioned Directory Group.

func GetGroup

func GetGroup(
	ctx context.Context,
	opts GetGroupOpts,
) (Group, error)

GetGroup gets a provisioned Group for a Directory.

type ListDirectoriesOpts

type ListDirectoriesOpts struct {
	// Domain of a Directory. Can be empty.
	Domain string `url:"domain,omitempty"`

	// Searchable text for a Directory. Can be empty.
	Search string `url:"search,omitempty"`

	// Organization ID of a Directory. Can be empty.
	OrganizationID string `url:"organization_id,omitempty"`

	// Maximum number of records to return.
	Limit int `url:"limit"`

	// The order in which to paginate records.
	Order Order `url:"order,omitempty"`

	// Pagination cursor to receive records before a provided Directory ID.
	Before string `url:"before,omitempty"`

	// Pagination cursor to receive records after a provided Directory ID.
	After string `url:"after,omitempty"`
}

ListDirectoriesOpts contains the options to request a Project's Directories.

type ListDirectoriesResponse

type ListDirectoriesResponse struct {
	// List of Directories.
	Data []Directory `json:"data"`

	// Cursor pagination options.
	ListMetadata common.ListMetadata `json:"listMetadata"`
}

ListDirectoriesResponse describes the response structure when requesting existing Directories.

func ListDirectories

func ListDirectories(
	ctx context.Context,
	opts ListDirectoriesOpts,
) (ListDirectoriesResponse, error)

ListDirectories gets details of a Project's Directories.

type ListGroupsOpts

type ListGroupsOpts struct {
	// Directory unique identifier.
	Directory string `url:"directory,omitempty"`

	// Directory unique identifier.
	User string `url:"user,omitempty"`

	// Maximum number of records to return.
	Limit int `url:"limit"`

	// The order in which to paginate records.
	Order Order `url:"order,omitempty"`

	// Pagination cursor to receive records before a provided Group ID.
	Before string `url:"before,omitempty"`

	// Pagination cursor to receive records after a provided Group ID.
	After string `url:"after,omitempty"`
}

ListGroupsOpts contains the options to request provisioned Directory Groups.

type ListGroupsResponse

type ListGroupsResponse struct {
	// List of provisioned Users.
	Data []Group `json:"data"`

	// Cursor pagination options.
	ListMetadata common.ListMetadata `json:"listMetadata"`
}

ListGroupsResponse describes the response structure when requesting provisioned Directory Groups.

func ListGroups

func ListGroups(
	ctx context.Context,
	opts ListGroupsOpts,
) (ListGroupsResponse, error)

ListGroups gets a list of provisioned Groups for a Directory.

type ListUsersOpts

type ListUsersOpts struct {
	// Directory unique identifier.
	Directory string `url:"directory,omitempty"`

	// Directory Group unique identifier.
	Group string `url:"group,omitempty"`

	// Maximum number of records to return.
	Limit int `url:"limit"`

	// The order in which to paginate records.
	Order Order `url:"order,omitempty"`

	// Pagination cursor to receive records before a provided User ID.
	Before string `url:"before,omitempty"`

	// Pagination cursor to receive records after a provided User ID.
	After string `url:"after,omitempty"`
}

ListUsersOpts contains the options to request provisioned Directory Users.

type ListUsersResponse

type ListUsersResponse struct {
	// List of provisioned Users.
	Data []User `json:"data"`

	// Cursor pagination options.
	ListMetadata common.ListMetadata `json:"listMetadata"`
}

ListUsersResponse describes the response structure when requesting provisioned Directory Users.

func ListUsers

func ListUsers(
	ctx context.Context,
	opts ListUsersOpts,
) (ListUsersResponse, error)

ListUsers gets a list of provisioned Users for a Directory.

type Order

type Order string

Order represents the order of records.

const (
	Asc  Order = "asc"
	Desc Order = "desc"
)

Constants that enumerate the available orders.

type User

type User struct {
	// The User's unique identifier.
	ID string `json:"id"`

	// The User's unique identifier assigned by the Directory Provider.
	IdpID string `json:"idp_id"`

	// The identifier of the Directory the Directory User belongs to.
	DirectoryID string `json:"directory_id"`

	// The identifier for the Organization in which the Directory resides.
	OrganizationID string `json:"organization_id"`

	// The User's username.
	Username string `json:"username"`

	// The User's e-mails.
	Emails []UserEmail `json:"emails"`

	// The User's groups.
	Groups []UserGroup `json:"groups"`

	// The User's first name.
	FirstName string `json:"first_name"`

	// The User's last name.
	LastName string `json:"last_name"`

	// The User's job title.
	JobTitle string `json:"job_title"`

	// The User's state.
	State UserState `json:"state"`

	// The User's raw attributes in raw encoded JSON.
	RawAttributes json.RawMessage `json:"raw_attributes"`

	// The User's custom attributes in raw encoded JSON.
	CustomAttributes json.RawMessage `json:"custom_attributes"`

	// The User's created at date
	CreatedAt string `json:"created_at"`

	// The User's updated at date
	UpdatedAt string `json:"updated_at"`
}

User contains data about a provisioned Directory User.

func GetUser

func GetUser(
	ctx context.Context,
	opts GetUserOpts,
) (User, error)

GetUser gets a provisioned User for a Directory.

func (User) PrimaryEmail

func (r User) PrimaryEmail() (string, error)

PrimaryEmail is a method for finding a user's primary email (when applicable)

type UserEmail

type UserEmail struct {
	// Flag to indicate if this e-mail is primary.
	Primary bool

	// Directory User's e-mail.
	Value string

	// Type of e-mail (ex. work).
	Type string
}

UserEmail contains data about a Directory User's e-mail address.

type UserGroup

type UserGroup struct {
	// Description of the record.
	Object string

	// The Group's identifier.
	ID string

	// The Group's Name.
	Name string
}

UserGroup contains data about a Directory User's groups.

type UserState

type UserState string

UserState represents the active state of a Directory User.

const (
	Active   UserState = "active"
	Inactive UserState = "inactive"
)

Constants that enumerate the state of a Directory User.

Jump to

Keyboard shortcuts

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