Documentation
¶
Overview ¶
Package `organizations` provides a client wrapping the WorkOS Organizations API.
Index ¶
- Constants
- Variables
- func DeleteOrganization(ctx context.Context, opts DeleteOrganizationOpts) error
- func SetAPIKey(apiKey string)
- type Client
- func (c *Client) CreateOrganization(ctx context.Context, opts CreateOrganizationOpts) (Organization, error)
- func (c *Client) DeleteOrganization(ctx context.Context, opts DeleteOrganizationOpts) error
- func (c *Client) GetOrganization(ctx context.Context, opts GetOrganizationOpts) (Organization, error)
- func (c *Client) GetOrganizationByExternalID(ctx context.Context, opts GetOrganizationByExternalIDOpts) (Organization, error)
- func (c *Client) ListOrganizationRoles(ctx context.Context, opts ListOrganizationRolesOpts) (ListOrganizationRolesResponse, error)
- func (c *Client) ListOrganizations(ctx context.Context, opts ListOrganizationsOpts) (ListOrganizationsResponse, error)
- func (c *Client) UpdateOrganization(ctx context.Context, opts UpdateOrganizationOpts) (Organization, error)
- type CreateOrganizationOpts
- type DeleteOrganizationOpts
- type GetOrganizationByExternalIDOpts
- type GetOrganizationOpts
- type ListOrganizationRolesOpts
- type ListOrganizationRolesResponse
- type ListOrganizationsOpts
- type ListOrganizationsResponse
- type Order
- type Organization
- func CreateOrganization(ctx context.Context, opts CreateOrganizationOpts) (Organization, error)
- func GetOrganization(ctx context.Context, opts GetOrganizationOpts) (Organization, error)
- func GetOrganizationByExternalID(ctx context.Context, opts GetOrganizationByExternalIDOpts) (Organization, error)
- func UpdateOrganization(ctx context.Context, opts UpdateOrganizationOpts) (Organization, error)
- type OrganizationDomain
- type OrganizationDomainData
- type OrganizationDomainDataState
- type OrganizationDomainState
- type OrganizationDomainVerificationStrategy
- type UpdateOrganizationOpts
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 Organizations functions.
Functions ¶
func DeleteOrganization ¶
func DeleteOrganization( ctx context.Context, opts DeleteOrganizationOpts, ) error
DeleteOrganization deletes an Organization.
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 manage Organization records from WorkOS.
// Defaults to http.Client.
HTTPClient *http.Client
// The endpoint to WorkOS API. Defaults to https://api.workos.com.
Endpoint string
// The function used to encode in JSON. Defaults to json.Marshal.
JSONEncode func(v interface{}) ([]byte, error)
// contains filtered or unexported fields
}
Client represents a client that performs Organization requests to the WorkOS API.
func (*Client) CreateOrganization ¶
func (c *Client) CreateOrganization(ctx context.Context, opts CreateOrganizationOpts) (Organization, error)
CreateOrganization creates an Organization.
func (*Client) DeleteOrganization ¶
func (c *Client) DeleteOrganization( ctx context.Context, opts DeleteOrganizationOpts, ) error
DeleteOrganization deletes an Organization.
func (*Client) GetOrganization ¶
func (c *Client) GetOrganization( ctx context.Context, opts GetOrganizationOpts, ) (Organization, error)
GetOrganization gets an Organization.
func (*Client) GetOrganizationByExternalID ¶
func (c *Client) GetOrganizationByExternalID( ctx context.Context, opts GetOrganizationByExternalIDOpts, ) (Organization, error)
GetOrganizationByExternalID gets an Organization by its External ID.
func (*Client) ListOrganizationRoles ¶
func (c *Client) ListOrganizationRoles( ctx context.Context, opts ListOrganizationRolesOpts, ) (ListOrganizationRolesResponse, error)
ListOrganizationRoles gets a list of roles for the given organization.
func (*Client) ListOrganizations ¶
func (c *Client) ListOrganizations( ctx context.Context, opts ListOrganizationsOpts, ) (ListOrganizationsResponse, error)
ListOrganizations gets a list of WorkOS Organizations.
func (*Client) UpdateOrganization ¶
func (c *Client) UpdateOrganization(ctx context.Context, opts UpdateOrganizationOpts) (Organization, error)
UpdateOrganization updates an Organization.
type CreateOrganizationOpts ¶
type CreateOrganizationOpts struct {
// Name of the Organization.
Name string `json:"name"`
// Whether Connections within the Organization allow profiles that are
// outside of the Organization's configured User Email Domains.
//
// Deprecated: If you need to allow sign-ins from any email domain, contact support@workos.com.
AllowProfilesOutsideOrganization bool `json:"allow_profiles_outside_organization"`
// Domains of the Organization.
//
// Deprecated: Use DomainData instead.
Domains []string `json:"domains"`
// Domains of the Organization.
DomainData []OrganizationDomainData `json:"domain_data"`
// Optional unique identifier to ensure idempotency
IdempotencyKey string `json:"idempotency_key,omitempty"`
// The Organization's external id.
ExternalID string `json:"external_id,omitempty"`
// The Organization's metadata.
Metadata map[string]string `json:"metadata,omitempty"`
}
CreateOrganizationOpts contains the options to create an Organization.
type DeleteOrganizationOpts ¶
type DeleteOrganizationOpts struct {
// Organization unique identifier.
Organization string
}
DeleteOrganizationOpts contains the options to delete an Organization.
type GetOrganizationByExternalIDOpts ¶
type GetOrganizationByExternalIDOpts struct {
ExternalID string
}
type GetOrganizationOpts ¶
type GetOrganizationOpts struct {
// Organization unique identifier.
Organization string
}
GetOrganizationOpts contains the options to request details for an Organization.
type ListOrganizationRolesOpts ¶
type ListOrganizationRolesOpts struct {
// The Organization's unique identifier.
OrganizationID string
}
ListOrganizationsOpts contains the options to request Organizations.
type ListOrganizationRolesResponse ¶
type ListOrganizationRolesResponse struct {
// List of roles for the given organization.
Data []roles.Role `json:"data"`
}
func ListOrganizationRoles ¶
func ListOrganizationRoles( ctx context.Context, opts ListOrganizationRolesOpts, ) (ListOrganizationRolesResponse, error)
ListOrganizationRoles lists roles for an Organization.
type ListOrganizationsOpts ¶
type ListOrganizationsOpts struct {
// Domains of the Organization.
Domains []string `url:"domains,brackets,omitempty"`
// Maximum number of records to return.
Limit int `url:"limit,omitempty"`
// The order in which to paginate records.
Order Order `url:"order,omitempty"`
// Pagination cursor to receive records before a provided Organization ID.
Before string `url:"before,omitempty"`
// Pagination cursor to receive records after a provided Organization ID.
After string `url:"after,omitempty"`
}
ListOrganizationsOpts contains the options to request Organizations.
type ListOrganizationsResponse ¶
type ListOrganizationsResponse struct {
// List of provisioned Organizations.
Data []Organization `json:"data"`
// Cursor pagination options.
ListMetadata common.ListMetadata `json:"list_metadata"`
}
ListOrganizationsResponse describes the response structure when requesting Organizations
func ListOrganizations ¶
func ListOrganizations( ctx context.Context, opts ListOrganizationsOpts, ) (ListOrganizationsResponse, error)
ListOrganizations gets a list of Organizations.
type Organization ¶
type Organization struct {
// The Organization's unique identifier.
ID string `json:"id"`
// The Organization's name.
Name string `json:"name"`
// Whether Connections within the Organization allow profiles that are
// outside of the Organization's configured User Email Domains.
//
// Deprecated: If you need to allow sign-ins from any email domain, contact support@workos.com.
AllowProfilesOutsideOrganization bool `json:"allow_profiles_outside_organization"`
// The Organization's Domains.
Domains []OrganizationDomain `json:"domains"`
// The Organization's Stripe Customer ID.
StripeCustomerID string `json:"stripe_customer_id,omitempty "`
// The timestamp of when the Organization was created.
CreatedAt string `json:"created_at"`
// The timestamp of when the Organization was updated.
UpdatedAt string `json:"updated_at"`
// The Organization's external id.
ExternalID string `json:"external_id"`
// The Organization's metadata.
Metadata map[string]string `json:"metadata"`
}
Organization contains data about a WorkOS Organization.
func CreateOrganization ¶
func CreateOrganization( ctx context.Context, opts CreateOrganizationOpts, ) (Organization, error)
CreateOrganization creates an Organization.
func GetOrganization ¶
func GetOrganization( ctx context.Context, opts GetOrganizationOpts, ) (Organization, error)
GetOrganization gets an Organization.
func GetOrganizationByExternalID ¶
func GetOrganizationByExternalID( ctx context.Context, opts GetOrganizationByExternalIDOpts, ) (Organization, error)
GetOrganization gets an Organization by its external id
func UpdateOrganization ¶
func UpdateOrganization( ctx context.Context, opts UpdateOrganizationOpts, ) (Organization, error)
UpdateOrganization creates an Organization.
type OrganizationDomain ¶
type OrganizationDomain = organization_domains.OrganizationDomain
type OrganizationDomainData ¶
type OrganizationDomainData struct {
// The domain's value.
Domain string `json:"domain"`
// The domain's state.
State OrganizationDomainDataState `json:"state"`
}
OrganizationDomainData contains data used to create an OrganizationDomain.
type OrganizationDomainDataState ¶
type OrganizationDomainDataState string
type OrganizationDomainState ¶
type OrganizationDomainState = organization_domains.OrganizationDomainState
const ( OrganizationDomainPending OrganizationDomainState = organization_domains.OrganizationDomainPending OrganizationDomainVerified OrganizationDomainState = organization_domains.OrganizationDomainVerified OrganizationDomainFailed OrganizationDomainState = organization_domains.OrganizationDomainFailed OrganizationDomainLegacyVerified OrganizationDomainState = organization_domains.OrganizationDomainLegacyVerified )
type OrganizationDomainVerificationStrategy ¶
type OrganizationDomainVerificationStrategy = organization_domains.OrganizationDomainVerificationStrategy
type UpdateOrganizationOpts ¶
type UpdateOrganizationOpts struct {
// Organization unique identifier.
Organization string `json:"-"`
// Name of the Organization.
Name string `json:"name,omitempty"`
// Whether Connections within the Organization allow profiles that are
// outside of the Organization's configured User Email Domains.
//
// Deprecated: If you need to allow sign-ins from any email domain, contact support@workos.com.
AllowProfilesOutsideOrganization bool `json:"allow_profiles_outside_organization,omitempty"`
// Domains of the Organization.
//
// Deprecated: Use DomainData instead.
Domains []string `json:"domains,omitempty"`
// Domains of the Organization.
DomainData []OrganizationDomainData `json:"domain_data,omitempty"`
// The Organization's external id.
ExternalID string `json:"external_id,omitempty"`
// The Organization's Stripe Customer ID.
StripeCustomerID string `json:"stripe_customer_id,omitempty"`
// The Organization's metadata.
Metadata map[string]*string `json:"metadata,omitempty"`
}
UpdateOrganizationOpts contains the options to update an Organization.