Documentation ¶
Overview ¶
Package `portal` provides a client wrapping the WorkOS Admin Portal API.
Index ¶
- Constants
- Variables
- func GenerateLink(ctx context.Context, opts GenerateLinkOpts) (string, error)
- func SetAPIKey(apiKey string)
- type Client
- func (c *Client) CreateOrganization(ctx context.Context, opts CreateOrganizationOpts) (Organization, error)
- func (c *Client) GenerateLink(ctx context.Context, opts GenerateLinkOpts) (string, error)
- func (c *Client) ListOrganizations(ctx context.Context, opts ListOrganizationsOpts) (ListOrganizationsResponse, error)
- type CreateOrganizationOpts
- type GenerateLinkIntent
- type GenerateLinkOpts
- type ListOrganizationsOpts
- type ListOrganizationsResponse
- type Organization
- type OrganizationDomain
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 Admin Portal functions.
Functions ¶
func GenerateLink ¶
func GenerateLink( ctx context.Context, opts GenerateLinkOpts, ) (string, error)
GenerateLink generates an ephemeral link to the Admin Portal
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 Admin Portal 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 Admin Portal 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) GenerateLink ¶
GenerateLink generates a link to the Admin Portal
func (*Client) ListOrganizations ¶
func (c *Client) ListOrganizations( ctx context.Context, opts ListOrganizationsOpts, ) (ListOrganizationsResponse, error)
ListOrganizations gets a list of WorkOS Organizations.
type CreateOrganizationOpts ¶
type CreateOrganizationOpts struct { // Domains of the Organization. Domains []string `json:"domains"` // Name of the Organization. Name string `json:"name"` }
CreateOrganizationOpts contains the options to create an Organization.
type GenerateLinkIntent ¶
type GenerateLinkIntent string
GenerateLinkIntent represents the intent of an Admin Portal.
const (
SSO GenerateLinkIntent = "sso"
)
Constants that enumerate the available GenerateLinkIntent types.
type GenerateLinkOpts ¶
type GenerateLinkOpts struct { // Intent of the Admin Portal Intent GenerateLinkIntent `json:"intent"` // Organization identifier to scope the Portal Session Organization string `json:"organization"` // The URL to which users will return to when finished with the Admin Portal. ReturnURL string `json:"return_url"` }
GenerateLinkOpts contains the options to request Organizations.
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"` // 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:"listMetadata"` }
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"` // The Organization's Domains. Domains []OrganizationDomain `json:"domains"` }
Organization contains data about a WorkOS Organization.
func CreateOrganization ¶
func CreateOrganization( ctx context.Context, opts CreateOrganizationOpts, ) (Organization, error)
CreateOrganization creates an Organization.
type OrganizationDomain ¶
type OrganizationDomain struct { // The Organization Domains's unique identifier. ID string `json:"id"` // The domain value Domain string `json:"domain"` }
OrganizationDomain contains data about an Organization's Domains.