policies

package
v1.58.3 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2024 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckPolicyExists added in v1.57.0

func CheckPolicyExists(auth iam.Authenticator, levelType string, levelID string, policyUUID string) (bool, string, error)

CheckPolicyExists attempts to fetch the details of a policy, identified by the given `policyUUID` and the presumed `levelType` and `levelID`. If the policy is not defined at the given `levelType` and `levelID` it returns false, without returning an error An error is returned ONLY if querying for the existence of the policy failed for another reason than `404 Not Found`

func FetchAllPolicyLevels added in v1.57.0

func FetchAllPolicyLevels(auth iam.Authenticator) (map[string]PolicyLevel, error)

FetchAllPolicyLevels pulls all known polices reachable via the given IAM Client from the REST API and notes down the `levelType` and `levelID` for these polices (identified via a UUID only).

You should use `ResolvePolicyLevel` to look up the `levelType` and `levelID` of a policy identifed by a UUID only

This operation is guarded by a mutext

func FetchPolicyLevel added in v1.57.0

func FetchPolicyLevel(auth iam.Authenticator, uuid string) (levelType string, levelID string, name string, err error)

FetchPolicyLevel determines the `levelType` and `levelID` of a policy identified by its UUID by trial and error, i.e. requests the policy from the REST API using all known combinations

Option 1: The policy is a global policy (levelType = global, levelID = global) Option 2: The policy is on the account level, identified by the argument `accountID` (levelType = account, levelID = `accountID` argument) Option 3: The policy is on the environment level. ALL environments reachable via the account are being taken into consideration

If all attempts fail the returned error contains the UUID in its message

This operation is guarded by a mutex

func GetEnvironmentIDs added in v1.57.0

func GetEnvironmentIDs(auth iam.Authenticator) ([]string, error)

GetEnvironmentIDs retrieves all environmentIDs reachable via the given accountID The operation is guarded by a mutex

func IsValidUUID added in v1.57.0

func IsValidUUID(uuid string) bool

func Join added in v1.57.0

func Join(uuid string, levelType string, levelID string) string

func RegisterPolicyLevel added in v1.57.0

func RegisterPolicyLevel(auth iam.Authenticator, level PolicyLevel) error

RegisterPolicyLevel notes down the `levelType` and `levelID` of the policy identified by the given `uuid`. Prior to that, if it hasn't happened yet, all known polices are getting pulled from the REST API In other words: Registering the `levelType` and `levelID` avoids that just partial information about the policys is stored locally. It's all nor nothing.

An error will be returned in case loading all known polices from the REST API fails for some reason

This operation is guarded by a mutex.

func ResolvePolicyLevel added in v1.57.0

func ResolvePolicyLevel(auth iam.Authenticator, uuid string) (levelType string, levelID string, name string, err error)

ResolvePolicyLevel determines the `levelType` and `levelID` of a policy using different strategies

  • If it hasn't happened yet, all known policies are getting retrieved from the REST API
  • In case none of the results contains the given `policyUUID` the `levelType` and `levelID` are getting resolved using trial and error (see `fetchPolicyLevel`)

This operation is guarded by a mutex

func Service

func Service(credentials *settings.Credentials) settings.CRUDService[*policies.Policy]

func SplitID

func SplitID(id string, defLevelType string, defLevelID string) (uuid string, levelType string, levelID string, err error)

defLevelType and devLevelID are getting used in case the passed policyID is just its UUID

In such a case the caller needs to have access to other configuration with these two strings e.g. the config object the policyIDs are embedded in

func SplitIDNoDefaults added in v1.57.0

func SplitIDNoDefaults(id string) (uuid string, levelType string, levelID string, err error)

Types

type DataStub added in v1.48.0

type DataStub struct {
	ID string `json:"id"`
}

type ListEnvResponse added in v1.48.0

type ListEnvResponse struct {
	Data []DataStub `json:"data"`
}

type ListPoliciesResponse added in v1.48.0

type ListPoliciesResponse struct {
	Policies []PolicyStub `json:"policies"`
}

type PolicyCreateResponse

type PolicyCreateResponse struct {
	UUID string `json:"uuid"`
}

type PolicyLevel added in v1.57.0

type PolicyLevel struct {
	UUID      string
	LevelType string
	LevelID   string
	Name      string
}

type PolicyServiceClient

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

func NewPolicyService

func NewPolicyService(clientID string, accountID string, clientSecret string) *PolicyServiceClient

func ServiceWithGloabals added in v1.57.0

func ServiceWithGloabals(credentials *settings.Credentials) *PolicyServiceClient

func (*PolicyServiceClient) AccountID

func (me *PolicyServiceClient) AccountID() string

func (*PolicyServiceClient) ClientID

func (me *PolicyServiceClient) ClientID() string

func (*PolicyServiceClient) ClientSecret

func (me *PolicyServiceClient) ClientSecret() string

func (*PolicyServiceClient) Create

func (me *PolicyServiceClient) Create(v *policies.Policy) (*api.Stub, error)

func (*PolicyServiceClient) Delete

func (me *PolicyServiceClient) Delete(id string) error

func (*PolicyServiceClient) Get

func (*PolicyServiceClient) List

func (me *PolicyServiceClient) List() (api.Stubs, error)

func (*PolicyServiceClient) ListWithGlobals added in v1.57.0

func (me *PolicyServiceClient) ListWithGlobals() (api.Stubs, error)

func (*PolicyServiceClient) Name added in v1.28.0

func (me *PolicyServiceClient) Name() string

func (*PolicyServiceClient) SchemaID

func (me *PolicyServiceClient) SchemaID() string

func (*PolicyServiceClient) Update

func (me *PolicyServiceClient) Update(id string, user *policies.Policy) error

type PolicyStub added in v1.48.0

type PolicyStub struct {
	UUID        string `json:"uuid"`
	Name        string `json:"name"`
	Description string `json:"description"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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