Documentation
¶
Overview ¶
Package `directorysync` provides a client wrapping the WorkOS Directory Sync API.
Index ¶
- Constants
- Variables
- func DeleteDirectory(ctx context.Context, opts DeleteDirectoryOpts) error
- func SetAPIKey(apiKey string)
- type Client
- func (c *Client) DeleteDirectory(ctx context.Context, opts DeleteDirectoryOpts) error
- func (c *Client) GetDirectory(ctx context.Context, opts GetDirectoryOpts) (Directory, error)
- func (c *Client) GetGroup(ctx context.Context, opts GetGroupOpts) (Group, error)
- func (c *Client) GetUser(ctx context.Context, opts GetUserOpts) (User, error)
- func (c *Client) ListDirectories(ctx context.Context, opts ListDirectoriesOpts) (ListDirectoriesResponse, error)
- func (c *Client) ListGroups(ctx context.Context, opts ListGroupsOpts) (ListGroupsResponse, error)
- func (c *Client) ListUsers(ctx context.Context, opts ListUsersOpts) (ListUsersResponse, error)
- type DeleteDirectoryOpts
- type Directory
- type DirectoryState
- type DirectoryType
- type GetDirectoryOpts
- type GetGroupOpts
- type GetUserOpts
- type Group
- type ListDirectoriesOpts
- type ListDirectoriesResponse
- type ListGroupsOpts
- type ListGroupsResponse
- type ListUsersOpts
- type ListUsersResponse
- type Order
- type User
- type UserEmail
- type UserGroup
- type UserState
Constants ¶
const ResponseLimit = 10
ResponseLimit is the default number of records to limit a response to.
Variables ¶
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
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 ¶
GetDirectory gets a Directory.
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.
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 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 primary email Email string `json:"email"` // The User's username. // Deprecated: Will be removed in a future major version. Enable the `username` custom attribute // in dashboard and pull from customAttributes instead. See // https://workos.com/docs/directory-sync/attributes/custom-attributes/auto-mapped-attributes for details. Username string `json:"username"` // The User's e-mails. // Deprecated: Will be removed in a future major version. Enable the `emails` custom attribute // in dashboard and pull from customAttributes instead. See // https://workos.com/docs/directory-sync/attributes/custom-attributes/auto-mapped-attributes for details. 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. // Deprecated: Will be removed in a future major version. Enable the `job_title` custom attribute // in dashboard and pull from customAttributes instead. See // https://workos.com/docs/directory-sync/attributes/custom-attributes/auto-mapped-attributes for details. 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"` // The role given to this Directory User Role common.RoleResponse `json:"role,omitempty"` }
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 ¶
PrimaryEmail is a method for finding a user's primary email (when applicable) Deprecated: Will be removed in a future major version. Use `email` attribute on User instead.
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.