client

package
v2.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MPL-2.0 Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EnvPageLimit = "TWINGATE_PAGE_LIMIT"
	EnvAPIToken  = "TWINGATE_API_TOKEN" // #nosec G101

)

Variables

View Source
var (
	ErrGraphqlIDIsEmpty          = errors.New("id is empty")
	ErrGraphqlNameIsEmpty        = errors.New("name is empty")
	ErrGraphqlEmptyBothNameAndID = errors.New("both name and id should not be empty")
	ErrGraphqlResultIsEmpty      = errors.New("query result is empty")
	ErrGraphqlConnectorIDIsEmpty = errors.New("connector id is empty")
	ErrGraphqlNetworkIDIsEmpty   = errors.New("network id is empty")
	ErrGraphqlNetworkNameIsEmpty = errors.New("network name is empty")
	ErrGraphqlEmailIsEmpty       = errors.New("email is empty")
)
View Source
var (
	ErrAPITokenNoSet = errors.New("api_token not set")
)

Functions

func NewUserFilterInput

func NewUserFilterInput(filter *UsersFilter) *query.UserFilterInput

Types

type APIError

type APIError struct {
	WrappedError error
	Operation    string
	Resource     string
	ID           graphql.ID
	Name         string
}

func NewAPIError

func NewAPIError(wrappedError error, operation, resource string) *APIError

func NewAPIErrorWithID

func NewAPIErrorWithID(wrappedError error, operation, resource, id string) *APIError

func NewAPIErrorWithName

func NewAPIErrorWithName(wrappedError error, operation, resource, name string) *APIError

func (*APIError) Error

func (e *APIError) Error() string

func (*APIError) Unwrap

func (e *APIError) Unwrap() error

type AccessInput

type AccessInput struct {
	PrincipalID      string  `json:"principalId"`
	SecurityPolicyID *string `json:"securityPolicyId"`
}

type Client

type Client struct {
	GraphqlClient    *graphql.Client
	HTTPClient       *http.Client
	GraphqlServerURL string
	APIServerURL     string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(url string, apiToken string, network string, httpTimeout time.Duration, httpRetryMax int, version string) *Client

func (*Client) AddResourceAccess

func (client *Client) AddResourceAccess(ctx context.Context, resourceID string, principalIDs []string) error

func (*Client) CreateConnector

func (client *Client) CreateConnector(ctx context.Context, input *model.Connector) (*model.Connector, error)

func (*Client) CreateGroup

func (client *Client) CreateGroup(ctx context.Context, input *model.Group) (*model.Group, error)

func (*Client) CreateRemoteNetwork

func (client *Client) CreateRemoteNetwork(ctx context.Context, req *model.RemoteNetwork) (*model.RemoteNetwork, error)

func (*Client) CreateResource

func (client *Client) CreateResource(ctx context.Context, input *model.Resource) (*model.Resource, error)

func (*Client) CreateServiceAccount

func (client *Client) CreateServiceAccount(ctx context.Context, serviceAccountName string) (*model.ServiceAccount, error)

func (*Client) CreateServiceKey

func (client *Client) CreateServiceKey(ctx context.Context, serviceAccountKey *model.ServiceKey) (*model.ServiceKey, error)

func (*Client) CreateUser

func (client *Client) CreateUser(ctx context.Context, input *model.User) (*model.User, error)

func (*Client) DeleteConnector

func (client *Client) DeleteConnector(ctx context.Context, connectorID string) error

func (*Client) DeleteGroup

func (client *Client) DeleteGroup(ctx context.Context, groupID string) error

func (*Client) DeleteGroupUsers

func (client *Client) DeleteGroupUsers(ctx context.Context, groupID string, userIDs []string) error

func (*Client) DeleteRemoteNetwork

func (client *Client) DeleteRemoteNetwork(ctx context.Context, remoteNetworkID string) error

func (*Client) DeleteResource

func (client *Client) DeleteResource(ctx context.Context, resourceID string) error

func (*Client) DeleteServiceAccount

func (client *Client) DeleteServiceAccount(ctx context.Context, serviceAccountID string) error

func (*Client) DeleteServiceKey

func (client *Client) DeleteServiceKey(ctx context.Context, serviceAccountKeyID string) error

func (*Client) DeleteUser

func (client *Client) DeleteUser(ctx context.Context, userID string) error

func (*Client) GenerateConnectorTokens

func (client *Client) GenerateConnectorTokens(ctx context.Context, connectorID string) (*model.ConnectorTokens, error)

func (*Client) ReadConnector

func (client *Client) ReadConnector(ctx context.Context, connectorID string) (*model.Connector, error)

func (*Client) ReadConnectors

func (client *Client) ReadConnectors(ctx context.Context, name, filter string) ([]*model.Connector, error)

func (*Client) ReadGroup

func (client *Client) ReadGroup(ctx context.Context, groupID string) (*model.Group, error)

func (*Client) ReadGroups

func (client *Client) ReadGroups(ctx context.Context, filter *model.GroupsFilter) ([]*model.Group, error)

func (*Client) ReadRemoteNetwork

func (client *Client) ReadRemoteNetwork(ctx context.Context, remoteNetworkID, remoteNetworkName string) (*model.RemoteNetwork, error)

func (*Client) ReadRemoteNetworkByID

func (client *Client) ReadRemoteNetworkByID(ctx context.Context, remoteNetworkID string) (*model.RemoteNetwork, error)

func (*Client) ReadRemoteNetworkByName

func (client *Client) ReadRemoteNetworkByName(ctx context.Context, remoteNetworkName string) (*model.RemoteNetwork, error)

func (*Client) ReadRemoteNetworks

func (client *Client) ReadRemoteNetworks(ctx context.Context, name, filter string) ([]*model.RemoteNetwork, error)

func (*Client) ReadResource

func (client *Client) ReadResource(ctx context.Context, resourceID string) (*model.Resource, error)

func (*Client) ReadResources

func (client *Client) ReadResources(ctx context.Context) ([]*model.Resource, error)

func (*Client) ReadResourcesByName

func (client *Client) ReadResourcesByName(ctx context.Context, name, filter string) ([]*model.Resource, error)

func (*Client) ReadSecurityPolicies

func (client *Client) ReadSecurityPolicies(ctx context.Context, name, filter string) ([]*model.SecurityPolicy, error)

func (*Client) ReadSecurityPolicy

func (client *Client) ReadSecurityPolicy(ctx context.Context, securityPolicyID, securityPolicyName string) (*model.SecurityPolicy, error)

func (*Client) ReadServiceAccount

func (client *Client) ReadServiceAccount(ctx context.Context, serviceAccountID string) (*model.ServiceAccount, error)

func (*Client) ReadServiceAccounts

func (client *Client) ReadServiceAccounts(ctx context.Context, input ...string) ([]*model.ServiceAccount, error)

func (*Client) ReadServiceKey

func (client *Client) ReadServiceKey(ctx context.Context, serviceAccountKeyID string) (*model.ServiceKey, error)

func (*Client) ReadShallowServiceAccount

func (client *Client) ReadShallowServiceAccount(ctx context.Context, serviceAccountID string) (*model.ServiceAccount, error)

func (*Client) ReadShallowServiceAccounts

func (client *Client) ReadShallowServiceAccounts(ctx context.Context) ([]*model.ServiceAccount, error)

func (*Client) ReadUser

func (client *Client) ReadUser(ctx context.Context, userID string) (*model.User, error)

func (*Client) ReadUsers

func (client *Client) ReadUsers(ctx context.Context, filter *UsersFilter) ([]*model.User, error)

func (*Client) RemoveResourceAccess

func (client *Client) RemoveResourceAccess(ctx context.Context, resourceID string, principalIDs []string) error

func (*Client) RevokeServiceKey

func (client *Client) RevokeServiceKey(ctx context.Context, serviceAccountKeyID string) error

func (*Client) UpdateConnector

func (client *Client) UpdateConnector(ctx context.Context, input *model.Connector) (*model.Connector, error)

func (*Client) UpdateGroup

func (client *Client) UpdateGroup(ctx context.Context, input *model.Group) (*model.Group, error)

func (*Client) UpdateRemoteNetwork

func (client *Client) UpdateRemoteNetwork(ctx context.Context, req *model.RemoteNetwork) (*model.RemoteNetwork, error)

func (*Client) UpdateResource

func (client *Client) UpdateResource(ctx context.Context, input *model.Resource) (*model.Resource, error)

func (*Client) UpdateResourceActiveState

func (client *Client) UpdateResourceActiveState(ctx context.Context, resource *model.Resource) error

func (*Client) UpdateServiceAccount

func (client *Client) UpdateServiceAccount(ctx context.Context, serviceAccount *model.ServiceAccount) (*model.ServiceAccount, error)

func (*Client) UpdateServiceAccountRemoveResources

func (client *Client) UpdateServiceAccountRemoveResources(ctx context.Context, serviceAccountID string, resourceIDsToRemove []string) error

func (*Client) UpdateServiceKey

func (client *Client) UpdateServiceKey(ctx context.Context, serviceAccountKey *model.ServiceKey) (*model.ServiceKey, error)

func (*Client) UpdateUser

func (client *Client) UpdateUser(ctx context.Context, input *model.UserUpdate) (*model.User, error)

func (*Client) UpdateUserRole

func (client *Client) UpdateUserRole(ctx context.Context, input *model.UserUpdate) (*model.User, error)

func (*Client) VerifyConnectorTokens

func (client *Client) VerifyConnectorTokens(ctx context.Context, refreshToken, accessToken string) error

type HTTPError

type HTTPError struct {
	RequestURI string
	StatusCode int
	Body       []byte
}

func NewHTTPError

func NewHTTPError(requestURI string, statusCode int, body []byte) *HTTPError

func (*HTTPError) Error

func (e *HTTPError) Error() string

type MutationError

type MutationError struct {
	Message string
}

func NewMutationError

func NewMutationError(message string) *MutationError

func (*MutationError) Error

func (e *MutationError) Error() string

type MutationResponse

type MutationResponse interface {
	OK() bool
	ErrorStr() string
	ResponseWithPayload
}

type PortRangeInput

type PortRangeInput struct {
	Start int `json:"start"`
	End   int `json:"end"`
}

type ProtocolInput

type ProtocolInput struct {
	Ports  []*PortRangeInput `json:"ports"`
	Policy string            `json:"policy"`
}

type ProtocolsInput

type ProtocolsInput struct {
	UDP       *ProtocolInput `json:"udp"`
	TCP       *ProtocolInput `json:"tcp"`
	AllowIcmp bool           `json:"allowIcmp"`
}

type RemoteNetworkLocation

type RemoteNetworkLocation string

type ResponseWithPayload

type ResponseWithPayload interface {
	IsEmpty() bool
}

type StringFilter

type StringFilter struct {
	Name   string
	Filter string
}

type UsersFilter

type UsersFilter struct {
	Email     *StringFilter
	FirstName *StringFilter
	LastName  *StringFilter
	Roles     []string
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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