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 ( OktaSCIMV1_1 DirectoryType = "okta scim v1.1" OktaSCIMV2_0 DirectoryType = "okta scim v2.0" AzureSCIMV2_0 DirectoryType = "azure scim v2.0" GSuiteDirectory DirectoryType = "gsuite directory" GenericSCIMV1_1 DirectoryType = "generic scim v1.1" GenericSCIMV2_0 DirectoryType = "generic scim v2.0" )
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 // Searchable text for a Directory. Can be empty. Search string // Organization ID of a Directory. Can be empty. OrganizationID string // Maximum number of records to return. Limit int // The order in which to paginate records. Order Order // Pagination cursor to receive records before a provided Directory ID. Before string // Pagination cursor to receive records after a provided Directory ID. After string }
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 // Directory User unique identifier. User string // Maximum number of records to return. Limit int // The order in which to paginate records. Order Order // Pagination cursor to receive records before a provided Directory ID. Before string // Pagination cursor to receive records after a provided Directory ID. After string }
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 // Directory Group unique identifier. Group string // Maximum number of records to return. Limit int // The order in which to paginate records. Order Order // Pagination cursor to receive records before a provided Directory ID. Before string // Pagination cursor to receive records after a provided Directory ID. After string }
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 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 ¶
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.