portal

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Feb 1, 2021 License: MIT Imports: 10 Imported by: 0

README

portal

Go Report Card

A Go package to make requests to the WorkOS Admin Portal API.

Install

go get -u github.com/riskledger/workos-go/pkg/portal

How it works

See the Admin Portal integration guide.

Documentation

Overview

Package `portal` provides a client wrapping the WorkOS Admin Portal 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 Admin Portal functions.

Functions

func GenerateLink(
	ctx context.Context,
	opts GenerateLinkOpts,
) (string, error)

GenerateLink generates an ephemeral link to the Admin Portal

func SetAPIKey

func SetAPIKey(apiKey string)

SetAPIKey sets the WorkOS API key for Admin Portal 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 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 (c *Client) GenerateLink(
	ctx context.Context,
	opts GenerateLinkOpts,
) (string, error)

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.

Jump to

Keyboard shortcuts

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