client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: Apache-2.0 Imports: 15 Imported by: 3

Documentation

Overview

Package client is the client for interacting with the governor API

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRequestNonSuccess is returned when a call to the governor API returns a non-success status
	ErrRequestNonSuccess = errors.New("got a non-success response from governor")

	// ErrGroupNotFound is returned when a group is not found
	ErrGroupNotFound = errors.New("group not found")

	// ErrMissingGroupID is returned when a missing or bad group id is passed to a request
	ErrMissingGroupID = errors.New("missing group id in request")

	// ErrMissingOrganizationID is returned when a missing or bad organization id is passed to a request
	ErrMissingOrganizationID = errors.New("missing organization id in request")

	// ErrMissingApplicationID is returned when a missing or bad application id is passed to a request
	ErrMissingApplicationID = errors.New("missing application id in request")

	// ErrMissingApplicationTypeID is returned when a missing or bad application_type id is passed to a request
	ErrMissingApplicationTypeID = errors.New("missing application_type id in request")

	// ErrMissingUserID is returned when a missing or bad user id is passed to a request
	ErrMissingUserID = errors.New("missing user id in request")

	// ErrMissingRequestID is returned when a missing or bad request id is passed to a request
	ErrMissingRequestID = errors.New("missing request id in request")

	// ErrNilUserRequest is returned when a nil user body is passed to a request
	ErrNilUserRequest = errors.New("nil user request")

	// ErrNilGroupRequest is returned when a nil group body is passed to a request
	ErrNilGroupRequest = errors.New("nil group request")

	// ErrUserNotFound is returned when a user is expected to be returned but instead is not
	ErrUserNotFound = errors.New("user not found")
)

Functions

This section is empty.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is a governor API client

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient returns a new governor client

func (*Client) AddGroupMember

func (c *Client) AddGroupMember(ctx context.Context, groupID, userID string, admin bool) error

AddGroupMember adds a user to a group in governor

func (*Client) AddGroupToApplication

func (c *Client) AddGroupToApplication(ctx context.Context, groupID, appID string) error

AddGroupToApplication links the group to the application

func (*Client) AddGroupToOrganization

func (c *Client) AddGroupToOrganization(ctx context.Context, groupID, orgID string) error

AddGroupToOrganization links the group to the organization

func (*Client) Application

func (c *Client) Application(ctx context.Context, id string) (*v1alpha1.Application, error)

Application gets the details of an app from governor

func (*Client) ApplicationGroups

func (c *Client) ApplicationGroups(ctx context.Context, id string) ([]*v1alpha1.Group, error)

ApplicationGroups gets a list of groups linked to the given governor application

func (*Client) ApplicationType

func (c *Client) ApplicationType(ctx context.Context, id string) (*v1alpha1.ApplicationType, error)

ApplicationType gets the details of an application type from governor

func (*Client) ApplicationTypeApps

func (c *Client) ApplicationTypeApps(ctx context.Context, id string) ([]*v1alpha1.Application, error)

ApplicationTypeApps gets a list of governor applications with the given application type

func (*Client) ApplicationTypes

func (c *Client) ApplicationTypes(ctx context.Context) ([]*v1alpha1.ApplicationType, error)

ApplicationTypes gets the list of application types from governor

func (*Client) Applications

func (c *Client) Applications(ctx context.Context) ([]*v1alpha1.Application, error)

Applications gets the list of applications from governor

func (*Client) CreateGroup

func (c *Client) CreateGroup(ctx context.Context, group *v1alpha1.GroupReq) (*v1alpha1.Group, error)

CreateGroup creates a new group in governor

func (*Client) CreateUser

func (c *Client) CreateUser(ctx context.Context, user *v1alpha1.UserReq) (*v1alpha1.User, error)

CreateUser creates a user in governor and returns the user

func (*Client) DeleteGroup

func (c *Client) DeleteGroup(ctx context.Context, id string) error

DeleteGroup deletes a group from governor

func (*Client) DeleteUser

func (c *Client) DeleteUser(ctx context.Context, id string) error

DeleteUser deletes a user in governor

func (*Client) Group

func (c *Client) Group(ctx context.Context, id string, deleted bool) (*v1alpha1.Group, error)

Group gets the details of a group from governor

func (*Client) GroupMemberRequests

func (c *Client) GroupMemberRequests(ctx context.Context, id string) ([]*v1alpha1.GroupMemberRequest, error)

GroupMemberRequests returns a list of member requests in the given governor group

func (*Client) GroupMembers

func (c *Client) GroupMembers(ctx context.Context, id string) ([]*v1alpha1.GroupMember, error)

GroupMembers returns a list of users in the given governor group

func (*Client) GroupMembersAll

func (c *Client) GroupMembersAll(ctx context.Context, expired bool) ([]*v1alpha1.GroupMembership, error)

GroupMembersAll returns a list of all group memberships across all groups

func (*Client) GroupMembershipRequestsAll

func (c *Client) GroupMembershipRequestsAll(ctx context.Context, expired bool) ([]*v1alpha1.GroupMemberRequest, error)

GroupMembershipRequestsAll returns all group membership requests across all users and groups

func (*Client) Groups

func (c *Client) Groups(ctx context.Context) ([]*v1alpha1.Group, error)

Groups gets the list of groups from governor

func (*Client) Organization

func (c *Client) Organization(ctx context.Context, id string) (*v1alpha1.Organization, error)

Organization gets the details of an org from governor

func (*Client) Organizations

func (c *Client) Organizations(ctx context.Context) ([]*v1alpha1.Organization, error)

Organizations gets the list of organizations from governor

func (*Client) RemoveGroupFromApplication

func (c *Client) RemoveGroupFromApplication(ctx context.Context, groupID, appID string) error

RemoveGroupFromApplication unlinks the group from the application

func (*Client) RemoveGroupFromOrganization

func (c *Client) RemoveGroupFromOrganization(ctx context.Context, groupID, orgID string) error

RemoveGroupFromOrganization unlinks the group from the organization

func (*Client) RemoveGroupMember

func (c *Client) RemoveGroupMember(ctx context.Context, groupID, userID string) error

RemoveGroupMember removes a user from a group in governor

func (*Client) RemoveGroupMembershipRequest

func (c *Client) RemoveGroupMembershipRequest(ctx context.Context, groupID, requestID string) error

RemoveGroupMembershipRequest removes a user from a group in governor

func (*Client) URL

func (c *Client) URL() string

URL returns the governor url

func (*Client) UpdateUser

func (c *Client) UpdateUser(ctx context.Context, id string, user *v1alpha1.UserReq) (*v1alpha1.User, error)

UpdateUser updates a user in governor and returns the user

func (*Client) User

func (c *Client) User(ctx context.Context, id string, deleted bool) (*v1alpha1.User, error)

User gets the details of a user from governor when deleted is true it will return information about a deleted user

func (*Client) Users

func (c *Client) Users(ctx context.Context, deleted bool) ([]*v1alpha1.User, error)

Users gets the list of users from governor when deleted is true it will also return deleted users

func (*Client) UsersQuery

func (c *Client) UsersQuery(ctx context.Context, query map[string][]string) ([]*v1alpha1.User, error)

UsersQuery searches for a user in governor with the passed query

func (*Client) UsersQueryV2

func (c *Client) UsersQueryV2(ctx context.Context, query map[string][]string) (*v1beta1.PaginationResponse[*v1beta1.User], error)

UsersQueryV2 searches for users in governor with the passed query

func (*Client) UsersV2

func (c *Client) UsersV2(ctx context.Context, queryParams map[string][]string) ([]*v1beta1.User, error)

UsersV2 gets the list of users from governor using paginated api

type HTTPDoer

type HTTPDoer interface {
	Do(req *http.Request) (*http.Response, error)
}

HTTPDoer implements the standard http.Client interface.

type Option

type Option func(r *Client)

Option is a functional configuration option

func WithClientCredentialConfig

func WithClientCredentialConfig(c *clientcredentials.Config) Option

WithClientCredentialConfig sets the oauth client credential config

func WithHTTPClient

func WithHTTPClient(c HTTPDoer) Option

WithHTTPClient overrides the default http client

func WithLogger

func WithLogger(l *zap.Logger) Option

WithLogger sets logger

func WithURL

func WithURL(u string) Option

WithURL sets the governor API URL

type Tokener

type Tokener interface {
	Token(ctx context.Context) (*oauth2.Token, error)
}

Tokener implements the token interface

Jump to

Keyboard shortcuts

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