Documentation
¶
Overview ¶
Package styra holds a client and helpers for interacting with the Styra APIs.
Index ¶
- func DecisionMappingsEquals(dms1, dms2 map[string]DecisionMapping) bool
- func NewHTTPError(statuscode int, body string) error
- func SubjectsAreEqual(as []*Subject, bs []*Subject) bool
- type ClaimConfig
- type Client
- func (c *Client) CreateInvitation(ctx context.Context, email bool, name string) (*CreateInvitationResponse, error)
- func (c *Client) CreateRoleBinding(ctx context.Context, request *CreateRoleBindingRequest) (*CreateRoleBindingResponse, error)
- func (c *Client) CreateSystem(ctx context.Context, request *CreateSystemRequest) (*CreateSystemResponse, error)
- func (c *Client) CreateUpdateSecret(ctx context.Context, secretID string, ...) (*CreateUpdateSecretResponse, error)
- func (c *Client) DeleteDatasource(ctx context.Context, id string) (*DeleteDatasourceResponse, error)
- func (c *Client) DeleteRoleBindingV2(ctx context.Context, id string) (*DeleteRoleBindingV2Response, error)
- func (c *Client) DeleteSystem(ctx context.Context, id string) (*DeleteSystemResponse, error)
- func (c *Client) GetDatasource(ctx context.Context, id string) (*GetDatasourceResponse, error)
- func (c *Client) GetOPAConfig(ctx context.Context, systemID string) (OPAConfig, error)
- func (c *Client) GetSystem(ctx context.Context, id string) (*GetSystemResponse, error)
- func (c *Client) GetUser(ctx context.Context, name string) (*GetUserResponse, error)
- func (c *Client) ListRoleBindingsV2(ctx context.Context, params *ListRoleBindingsV2Params) (*ListRoleBindingsV2Response, error)
- func (c *Client) UpdateRoleBindingSubjects(ctx context.Context, id string, request *UpdateRoleBindingSubjectsRequest) (*UpdateRoleBindingSubjectsResponse, error)
- func (c *Client) UpdateSystem(ctx context.Context, id string, request *UpdateSystemRequest) (*UpdateSystemResponse, error)
- func (c *Client) UpsertDatasource(ctx context.Context, id string, request *UpsertDatasourceRequest) (*UpsertDatasourceResponse, error)
- func (c *Client) VerifyGitConfiguration(ctx context.Context, request *VerfiyGitConfigRequest) (*VerfiyGitConfigResponse, error)
- type ClientInterface
- type CreateInvitationRequest
- type CreateInvitationResponse
- type CreateRoleBindingRequest
- type CreateRoleBindingResponse
- type CreateSystemRequest
- type CreateSystemResponse
- type CreateUpdateSecretResponse
- type CreateUpdateSecretsRequest
- type DatasourceConfig
- type DecisionMapping
- type DecisionMappingAllowed
- type DecisionMappingColumn
- type DecisionMappingReason
- type DeleteDatasourceResponse
- type DeleteRoleBindingV2Response
- type DeleteSystemResponse
- type DeploymentParameters
- type GetDatasourceResponse
- type GetSystemResponse
- type GetUserResponse
- type GitRepoConfig
- type HTTPError
- type ListRoleBindingsV2Params
- type ListRoleBindingsV2Response
- type OPAConfig
- type ResourceFilter
- type Role
- type RoleBindingConfig
- type RoleBindingKind
- type SourceControlConfig
- type Subject
- type SubjectKind
- type SystemConfig
- type UpdateRoleBindingSubjectsRequest
- type UpdateRoleBindingSubjectsResponse
- type UpdateSystemRequest
- type UpdateSystemResponse
- type UpsertDatasourceRequest
- type UpsertDatasourceResponse
- type VerfiyGitConfigRequest
- type VerfiyGitConfigResponse
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecisionMappingsEquals ¶
func DecisionMappingsEquals(dms1, dms2 map[string]DecisionMapping) bool
DecisionMappingsEquals asserts if two decisionmappings are equal.
func NewHTTPError ¶
NewHTTPError creates a new HTTPError based on the statuscode and body from a failed call to the Styra API.
func SubjectsAreEqual ¶
SubjectsAreEqual checks if two lists of Subjects are equal.
Types ¶
type ClaimConfig ¶
type ClaimConfig struct {
IdentityProvider string `json:"identity_provider,omitempty"`
Key string `json:"key"`
Value string `json:"value"`
}
ClaimConfig represents a claim configuration.
type Client ¶
Client is a client for the Styra APIs.
func (*Client) CreateInvitation ¶
func (c *Client) CreateInvitation(ctx context.Context, email bool, name string) (*CreateInvitationResponse, error)
CreateInvitation calls the POST /v1/invitations endpoint in the Styra API.
func (*Client) CreateRoleBinding ¶
func (c *Client) CreateRoleBinding( ctx context.Context, request *CreateRoleBindingRequest, ) (*CreateRoleBindingResponse, error)
CreateRoleBinding calls the POST /v2/authz/rolebindings endpoint in the Styra API.
func (*Client) CreateSystem ¶
func (c *Client) CreateSystem(ctx context.Context, request *CreateSystemRequest) (*CreateSystemResponse, error)
CreateSystem calls the POST /v1/systems endpoint in the Styra API.
func (*Client) CreateUpdateSecret ¶
func (c *Client) CreateUpdateSecret( ctx context.Context, secretID string, createUpdateSecretsRequest *CreateUpdateSecretsRequest, ) (*CreateUpdateSecretResponse, error)
CreateUpdateSecret calls the PUT /v1/secrets/{secretId} endpoint in the Styra API.
func (*Client) DeleteDatasource ¶
func (c *Client) DeleteDatasource(ctx context.Context, id string) (*DeleteDatasourceResponse, error)
DeleteDatasource calls the DELETE /v1/datasources/{datasource} endpoint in the Styra API.
func (*Client) DeleteRoleBindingV2 ¶
func (c *Client) DeleteRoleBindingV2(ctx context.Context, id string) (*DeleteRoleBindingV2Response, error)
DeleteRoleBindingV2 calls the DELETE /v2/authz/rolebindings/{id}/subjects endpoint in the Styra API.
func (*Client) DeleteSystem ¶
DeleteSystem calls the DELETE /v1/systems/{system} endpoint in the Styra API.
func (*Client) GetDatasource ¶
GetDatasource calls the GET /v1/datasources/{datasource} endpoint in the Styra API.
func (*Client) GetOPAConfig ¶
GetOPAConfig calls the GET /v1/systems/{systemId}/assets/opa-config endpoint in the Styra API.
func (*Client) ListRoleBindingsV2 ¶
func (c *Client) ListRoleBindingsV2( ctx context.Context, params *ListRoleBindingsV2Params, ) (*ListRoleBindingsV2Response, error)
ListRoleBindingsV2 calls the GET /v2/authz/rolebindings endpoint in the Styra API.
func (*Client) UpdateRoleBindingSubjects ¶
func (c *Client) UpdateRoleBindingSubjects( ctx context.Context, id string, request *UpdateRoleBindingSubjectsRequest, ) (*UpdateRoleBindingSubjectsResponse, error)
UpdateRoleBindingSubjects calls the POST /v2/authz/rolebindings/{id}/subjects endpoint in the Styra API.
func (*Client) UpdateSystem ¶
func (c *Client) UpdateSystem( ctx context.Context, id string, request *UpdateSystemRequest, ) (*UpdateSystemResponse, error)
UpdateSystem calls the PUT /v1/systems/{system} endpoint in the Styra API.
func (*Client) UpsertDatasource ¶
func (c *Client) UpsertDatasource( ctx context.Context, id string, request *UpsertDatasourceRequest, ) (*UpsertDatasourceResponse, error)
UpsertDatasource calls the PUT /v1/datasources/{datasource} endpoint in the Styra API.
func (*Client) VerifyGitConfiguration ¶
func (c *Client) VerifyGitConfiguration( ctx context.Context, request *VerfiyGitConfigRequest, ) (*VerfiyGitConfigResponse, error)
VerifyGitConfiguration calls the POST /v1/systems/source-control/verify-config endpoint in the Styra API.
type ClientInterface ¶
type ClientInterface interface {
GetSystem(ctx context.Context, id string) (*GetSystemResponse, error)
CreateUpdateSecret(
ctx context.Context,
secretID string,
request *CreateUpdateSecretsRequest,
) (*CreateUpdateSecretResponse, error)
GetUser(ctx context.Context, name string) (*GetUserResponse, error)
CreateInvitation(ctx context.Context, email bool, name string) (*CreateInvitationResponse, error)
ListRoleBindingsV2(ctx context.Context, params *ListRoleBindingsV2Params) (*ListRoleBindingsV2Response, error)
CreateRoleBinding(ctx context.Context, request *CreateRoleBindingRequest) (*CreateRoleBindingResponse, error)
UpdateRoleBindingSubjects(
ctx context.Context,
id string,
request *UpdateRoleBindingSubjectsRequest,
) (*UpdateRoleBindingSubjectsResponse, error)
DeleteRoleBindingV2(ctx context.Context, id string) (*DeleteRoleBindingV2Response, error)
GetDatasource(ctx context.Context, id string) (*GetDatasourceResponse, error)
UpsertDatasource(
ctx context.Context,
id string,
request *UpsertDatasourceRequest,
) (*UpsertDatasourceResponse, error)
DeleteDatasource(ctx context.Context, id string) (*DeleteDatasourceResponse, error)
UpdateSystem(ctx context.Context, id string, request *UpdateSystemRequest) (*UpdateSystemResponse, error)
DeleteSystem(ctx context.Context, id string) (*DeleteSystemResponse, error)
CreateSystem(ctx context.Context, request *CreateSystemRequest) (*CreateSystemResponse, error)
GetOPAConfig(ctx context.Context, systemID string) (OPAConfig, error)
VerifyGitConfiguration(ctx context.Context, request *VerfiyGitConfigRequest) (*VerfiyGitConfigResponse, error)
}
ClientInterface defines the interface for the Styra client.
func New ¶
func New(url string, token string) ClientInterface
New creates a new Styra ClientInterface.
type CreateInvitationRequest ¶
type CreateInvitationRequest struct {
UserID string `json:"user_id"`
}
CreateInvitationRequest is the request body for the POST /v1/invitations endpoint in the Styra API.
type CreateInvitationResponse ¶
CreateInvitationResponse is the response type for calls to the POST /v1/invitations endpoint in the Styra API.
type CreateRoleBindingRequest ¶
type CreateRoleBindingRequest struct {
ResourceFilter *ResourceFilter `json:"resource_filter"`
RoleID Role `json:"role_id"`
Subjects []*Subject `json:"subjects"`
}
CreateRoleBindingRequest is the request body for the POST /v2/authz/rolebindings endpoint in the Styra API.
type CreateRoleBindingResponse ¶
type CreateRoleBindingResponse struct {
Rolebinding *RoleBindingConfig `json:"rolebinding"`
StatusCode int
Body []byte
}
CreateRoleBindingResponse is the response body for the POST /v2/authz/rolebindings endpoint in the Styra API.
type CreateSystemRequest ¶
type CreateSystemRequest struct {
*SystemConfig
}
CreateSystemRequest is the request body for the POST /v1/systems endpoint in the Styra API.
type CreateSystemResponse ¶
type CreateSystemResponse struct {
StatusCode int
Body []byte
SystemConfig *SystemConfig
}
CreateSystemResponse is the response body for the POST /v1/systems endpoint in the Styra API.
type CreateUpdateSecretResponse ¶
CreateUpdateSecretResponse is the response type for calls to the PUT /v1/secrets/{secretId} endpoint in the Styra API.
type CreateUpdateSecretsRequest ¶
type CreateUpdateSecretsRequest struct {
Description string `json:"description"`
Name string `json:"name"`
Secret string `json:"secret"`
}
CreateUpdateSecretsRequest is the response body for the PUT /v1/secrets/{secretId} endpoint in the Styra API.
type DatasourceConfig ¶
type DatasourceConfig struct {
Category string `json:"category"`
Type string `json:"type,omitempty"`
Optional bool `json:"optional,omitempty"`
Commit string `json:"commit,omitempty"`
Credentials string `json:"credentials,omitempty"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled,omitempty"`
ID string `json:"id,omitempty"`
Path string `json:"path,omitempty"`
Reference string `json:"reference,omitempty"`
URL string `json:"url,omitempty"`
}
DatasourceConfig defines the structure of a datasource configuration.
type DecisionMapping ¶
type DecisionMapping struct {
Allowed *DecisionMappingAllowed `json:"allowed,omitempty"`
Columns []DecisionMappingColumn `json:"columns,omitempty"`
Reason *DecisionMappingReason `json:"reason,omitempty"`
}
DecisionMapping defines the structure of a decision mapping.
type DecisionMappingAllowed ¶
type DecisionMappingAllowed struct {
Expected interface{} `json:"expected,omitempty"`
Negated bool `json:"negated,omitempty"`
Path string `json:"path"`
}
DecisionMappingAllowed defines the structure of the allow element in a decision mapping.
type DecisionMappingColumn ¶
type DecisionMappingColumn struct {
Key string `json:"key"`
Path string `json:"path"`
Type string `json:"type,omitempty"`
}
DecisionMappingColumn defines the structure of the column element in a decision mapping.
type DecisionMappingReason ¶
type DecisionMappingReason struct {
Path string `json:"path"`
}
DecisionMappingReason defines the structure of the reason element in a decision mapping.
type DeleteDatasourceResponse ¶
DeleteDatasourceResponse is the response type for calls to the DELETE /v1/datasources/{datasource} endpoint in the Styra API.
type DeleteRoleBindingV2Response ¶
DeleteRoleBindingV2Response is the response type for calls to the DELETE /v2/authz/rolebindings/{id}/subjects endpoint in the Styra API
type DeleteSystemResponse ¶
DeleteSystemResponse is the response type for calls to the DELETE /v1/systems/{system} endpoint in the Styra API.
type DeploymentParameters ¶ added in v0.6.0
type DeploymentParameters struct {
Discovery *v1beta1.DiscoveryOverrides `json:"discovery,omitempty"`
}
DeploymentParameters are additional OPA deployment parameters for the system.
type GetDatasourceResponse ¶
type GetDatasourceResponse struct {
StatusCode int
Body []byte
DatasourceConfig *DatasourceConfig
}
GetDatasourceResponse stores the response body for the GET /v1/datasources/{datasource} endpoint in the Styra API.
type GetSystemResponse ¶
type GetSystemResponse struct {
StatusCode int
Body []byte
SystemConfig *SystemConfig
}
GetSystemResponse is the response body for the GET /v1/systems{system} endpoint in the Styra API.
type GetUserResponse ¶
GetUserResponse is the response type for calls to the GET /v1/users endpoint in the Styra API.
type GitRepoConfig ¶
type GitRepoConfig struct {
Commit string `json:"commit"`
Credentials string `json:"credentials"`
Path string `json:"path"`
Reference string `json:"reference"`
URL string `json:"url"`
}
GitRepoConfig defines the structure of a git repo configuration.
type ListRoleBindingsV2Params ¶
type ListRoleBindingsV2Params struct {
ResourceKind RoleBindingKind
ResourceID string
RoleID Role
SubjectKind SubjectKind
}
ListRoleBindingsV2Params is the URL params for the GET /v2/authz/rolebindings endpoint in the Styra API.
type ListRoleBindingsV2Response ¶
type ListRoleBindingsV2Response struct {
Rolebindings []*RoleBindingConfig `json:"rolebindings"`
StatusCode int
Body []byte
}
ListRoleBindingsV2Response is the response body for the GET /v2/authz/rolebindings endpoint in the Styra API.
type OPAConfig ¶
OPAConfig stores the information retrieved from calling the GET /v1/systems/{systemId}/assets/opa-config endpoint in the Styra API.
type ResourceFilter ¶
type ResourceFilter struct {
ID string `json:"id"`
Kind RoleBindingKind `json:"kind"`
}
ResourceFilter is a resource filter. This is used to limit what resources are targeted in the Styra APIs.
type RoleBindingConfig ¶
type RoleBindingConfig struct {
ID string `json:"id"`
Subjects []*Subject `json:"subjects"`
RoleID Role `json:"role_id"`
}
RoleBindingConfig defines the structure of a rolebinding configuration. This is used for binding a list of subjects to a specific role.
type RoleBindingKind ¶
type RoleBindingKind string
RoleBindingKind is the kind of the role binding.
const ( // RoleBindingKindSystem is a RoleBindingKind used when the role is for a // System. RoleBindingKindSystem RoleBindingKind = "system" )
type SourceControlConfig ¶
type SourceControlConfig struct {
Origin GitRepoConfig `json:"origin"`
}
SourceControlConfig defines the structure of a source control configuration.
type Subject ¶
type Subject struct {
ID string `json:"id,omitempty"`
Kind SubjectKind `json:"kind"`
ClaimConfig *ClaimConfig `json:"claim_config,omitempty"`
}
Subject specifies a subject.
type SubjectKind ¶
type SubjectKind string
SubjectKind is the kind of a subject.
const ( // SubjectKindUser is a SubjectKind used when the subject is a user. SubjectKindUser SubjectKind = "user" // SubjectKindClaim is a SubjectKind used when the subject is a claim. SubjectKindClaim SubjectKind = "claim" )
type SystemConfig ¶
type SystemConfig struct {
DecisionMappings map[string]DecisionMapping `json:"decision_mappings,omitempty"`
Description string `json:"description,omitempty"`
Name string `json:"name"`
ReadOnly bool `json:"read_only"`
SourceControl *SourceControlConfig `json:"source_control,omitempty"`
Type string `json:"type"`
ID string `json:"id"`
Datasources []*DatasourceConfig `json:"datasources,omitempty"`
DeploymentParameters *DeploymentParameters `json:"deployment_parameters,omitempty"`
}
SystemConfig represents the configuration of a system in the Styra APIs.
type UpdateRoleBindingSubjectsRequest ¶
type UpdateRoleBindingSubjectsRequest struct {
Subjects []*Subject `json:"subjects"`
}
UpdateRoleBindingSubjectsRequest is the request body for the POST /v2/authz/rolebindings/{id}/subjects endpoint in the Styra API.
type UpdateRoleBindingSubjectsResponse ¶
UpdateRoleBindingSubjectsResponse is the response type for calls to the POST /v2/authz/rolebindings/{id}/subjects endpoint in the Styra API.
type UpdateSystemRequest ¶
type UpdateSystemRequest struct {
*SystemConfig
}
UpdateSystemRequest is the request body for the the PUT /v1/systems/{system} endpoint in the Styra API.
type UpdateSystemResponse ¶
type UpdateSystemResponse struct {
StatusCode int
Body []byte
SystemConfig *SystemConfig
}
UpdateSystemResponse is the response body for the PUT /v1/systems/{system} endpoint in the Styra API.
type UpsertDatasourceRequest ¶
type UpsertDatasourceRequest struct {
Category string `json:"category"`
Description string `json:"description,omitempty"`
Enabled bool `json:"enabled"`
Commit string `json:"commit,omitempty"`
Credentials string `json:"credentials,omitempty"`
Reference string `json:"reference,omitempty"`
URL string `json:"url,omitempty"`
Path string `json:"path,omitempty"`
}
UpsertDatasourceRequest is the request body for the PUT /v1/datasources/{datasource} endpoint in the Styra API.
type UpsertDatasourceResponse ¶
UpsertDatasourceResponse is the response type for calls to the PUT /v1/datasources/{datasource} endpoint in the Styra API.
type VerfiyGitConfigRequest ¶
type VerfiyGitConfigRequest struct {
Commit string `json:"commit"`
ID string `json:"id"`
Credentials string `json:"credentials"`
Path string `json:"path"`
Reference string `json:"reference"`
URL string `json:"url"`
}
VerfiyGitConfigRequest is the request body for the POST /v1/systems/source-control/verify-config endpoint in the Styra API.
type VerfiyGitConfigResponse ¶
VerfiyGitConfigResponse is the response type for calls to the POST /v1/systems/source-control/verify-config endpoint in the Styra API.