session

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Dec 20, 2019 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package session provides configuration for Workday service clients.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	Environment *string
	Tenant      *string
	Credentials credentials.Provider
}

Config is used to manually configure a session via the FromConfig session option.

type Option

type Option func(sess *Session) (*Session, error)

Option defines the function signature used for session options.

func FromConfig

func FromConfig(config Config) Option

FromConfig is a session option that loads session from a manual configuration object.

type Session

type Session struct {
	Environment string
	Tenant      string
	Credentials credentials.Provider
}

Session provides configuration for Workday service clients.

A single session is meant to be shared by multiple Workday clients and threads. It is not safe to mutate a session after it has been passed to a client.

NewSession is the recommended way to create a new session.

func FromEnvironment

func FromEnvironment(sess *Session) (*Session, error)

FromEnvironment is a session option that loads session data from the environment.

WD_ENVIRONMENT
WD_TENANT

# Basic Auth
WD_BASIC_AUTH_USERNAME
WD_BASIC_AUTH_PASSWORD

# OAuth Client Credentials
WD_CLIENT_CREDENTIALS_CLIENT_ID
WD_CLIENT_CREDENTIALS_CLIENT_SECRET
WD_CLIENT_CREDENTIALS_REFRESH_TOKEN

func MustSession

func MustSession(options ...Option) (sess *Session)

MustSession is like NewSession but panics in the cased where NewSession would return an error.

func NewSession

func NewSession(options ...Option) (sess *Session, err error)

NewSession creates a new session. If no options are provided the session will created from the environment. See the FromEnvironment option for details.

func (*Session) Validate

func (sess *Session) Validate() error

Validate returns an error if the session is invalid.

Jump to

Keyboard shortcuts

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