organizations

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 14, 2022 License: MIT Imports: 11 Imported by: 0

README

organizations

Go Report Card

A Go package to make requests to the WorkOS Organizations API.

Install

go get -u github.com/workos/workos-go/pkg/organizations

How it works

See the Organizations API reference.

Documentation

Overview

Package `organizations` provides a client wrapping the WorkOS Organizations 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 Organizations functions.

Functions

func DeleteOrganization

func DeleteOrganization(
	ctx context.Context,
	opts DeleteOrganizationOpts,
) error

DeleteOrganization deletes an Organization.

func SetAPIKey

func SetAPIKey(apiKey string)

SetAPIKey sets the WorkOS API key for Organizations 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 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) 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.
	AllowProfilesOutsideOrganization bool `json:"allow_profiles_outside_organization"`

	// Domains of the Organization.
	Domains []string `json:"domains"`

	// Optional unique identifier to ensure idempotency
	IdempotencyKey string `json:"idempotency_iey,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 GetOrganizationOpts

type GetOrganizationOpts struct {
	// Organization unique identifier.
	Organization string
}

GetOrganizationOpts contains the options to request details 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:"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 Order added in v1.12.0

type Order string

Order represents the order of records.

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

Constants that enumerate the available orders.

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.
	AllowProfilesOutsideOrganization bool `json:"allow_profiles_outside_organization"`

	// The Organization's Domains.
	Domains []OrganizationDomain `json:"domains"`

	// 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"`
}

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 UpdateOrganization

func UpdateOrganization(
	ctx context.Context,
	opts UpdateOrganizationOpts,
) (Organization, error)

UpdateOrganization creates an Organization.

type OrganizationDomain

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

	// The domain value
	Domain string `json:"domain"`
}

OrganizationDomain contains data about an Organization's Domains.

type UpdateOrganizationOpts

type UpdateOrganizationOpts struct {
	// Organization unique identifier.
	Organization string

	// Name of the Organization.
	Name string

	// Whether Connections within the Organization allow profiles that are
	// outside of the Organization's configured User Email Domains.
	AllowProfilesOutsideOrganization bool

	// Domains of the Organization.
	Domains []string
}

UpdateOrganizationOpts contains the options to update an Organization.

Jump to

Keyboard shortcuts

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