iampapv1

package
v0.0.0-...-9e96525 Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: Apache-2.0 Imports: 10 Imported by: 26

Documentation

Index

Constants

View Source
const (
	AuthorizationPolicyType = "authorization"
	AccessPolicyType        = "access"
)
View Source
const (
	AccessGroupIDAttribute   = "accesGroupId"
	AccountIDAttribute       = "accountId"
	OrganizationIDAttribute  = "organizationId"
	SpaceIDAttribute         = "spaceId"
	RegionAttribute          = "region"
	ServiceTypeAttribute     = "serviceType"
	ServiceNameAttribute     = "serviceName"
	ServiceInstanceAttribute = "serviceInstance"
	ResourceTypeAttribute    = "resourceType"
	ResourceAttribute        = "resource"
	ResourceGroupIDAttribute = "resourceGroupId"
)
View Source
const ErrCodeAPICreation = "APICreationError"

ErrCodeAPICreation ...

View Source
const IAM_ACCOUNT_ESCAPE = "a%2f"

Variables

This section is empty.

Functions

This section is empty.

Types

type AccessPolicyListResponse

type AccessPolicyListResponse struct {
	Policies []AccessPolicyResponse
}

type AccessPolicyRequest

type AccessPolicyRequest struct {
	Roles     []Roles     `json:"roles" binding:"required"`
	Resources []Resources `json:"resources" binding:"required"`
}

type AccessPolicyResponse

type AccessPolicyResponse struct {
	ID        string
	Roles     []Roles
	Resources []Resources
}

type Attribute

type Attribute struct {
	Name     string `json:"name"`
	Value    string `json:"value"`
	Operator string `json:"operator,omitempty"`
}

Attribute is part of policy subject and resource

type AuthorizationPolicy

type AuthorizationPolicy struct {
	ID        string                  `json:"id,omitempty"`
	Roles     []models.PolicyRole     `json:"roles"`
	Resources []models.PolicyResource `json:"resources"`
	Subjects  []models.PolicyResource `json:"subjects"`
	Type      string                  `json:"type,omitempty"`
	Version   string                  `json:"-"`
}

type AuthorizationPolicyRepository

type AuthorizationPolicyRepository interface {
	List(accountID string, query *AuthorizationPolicySearchQuery) ([]AuthorizationPolicy, error)
	Get(accountID string, policyID string) (AuthorizationPolicy, error)
	Create(accountID string, policy AuthorizationPolicy) (AuthorizationPolicy, error)
	Update(accountID string, policyID string, policy AuthorizationPolicy, version string) (AuthorizationPolicy, error)
	Delete(accountID string, policyID string) error
}

func NewAuthorizationPolicyRepository

func NewAuthorizationPolicyRepository(c *client.Client) AuthorizationPolicyRepository

type AuthorizationPolicySearchQuery

type AuthorizationPolicySearchQuery struct {
	SubjectID     string
	Type          string
	AccessGroupID string
}

type IAMPAPAPI

type IAMPAPAPI interface {
	IAMPolicy() IAMPolicy
	IAMService() IAMService
	AuthorizationPolicies() AuthorizationPolicyRepository
	V1Policy() V1PolicyRepository
}

IAMPAPAPI is the IAMpapv2 client ...

func New

func New(sess *session.Session) (IAMPAPAPI, error)

New ...

type IAMPolicy

type IAMPolicy interface {
	Create(scope, userId string, params AccessPolicyRequest) (AccessPolicyResponse, string, error)
	List(scope, userId string) (AccessPolicyListResponse, error)
	Delete(scope, userId, policyId string) error
	Get(scope, userId, policyId string) (AccessPolicyResponse, error)
	Update(scope, userId, policyId, etag string, params AccessPolicyRequest) (AccessPolicyResponse, string, error)
}

type IAMService

type IAMService interface {
	GetServiceName(serviceDispName string) (string, error)
	GetServiceDispalyName(serviceName string) (string, error)
}

type Policy

type Policy struct {
	ID               string     `json:"id,omitempty"`
	Type             string     `json:"type"`
	Subjects         []Subject  `json:"subjects"`
	Roles            []Role     `json:"roles"`
	Resources        []Resource `json:"resources"`
	Href             string     `json:"href,omitempty"`
	CreatedAt        string     `json:"created_at,omitempty"`
	CreatedByID      string     `json:"created_by_id,omitempty"`
	LastModifiedAt   string     `json:"last_modified_at,omitempty"`
	LastModifiedByID string     `json:"last_modified_by_id,omitempty"`
	Version          string     `json:"-"`
}

Policy is the model of IAM PAP policy

type Resource

type Resource struct {
	Attributes []Attribute `json:"attributes"`
}

Resource is the object controlled by the policy

func (*Resource) AccessGroupID

func (r *Resource) AccessGroupID() string

AccessGroupID returns access group ID attribute of policy resource if exists

func (*Resource) AccountID

func (r *Resource) AccountID() string

AccountID returns account ID attribute of policy resource if exists

func (*Resource) CustomAttributes

func (r *Resource) CustomAttributes() []Attribute

CustomAttributes will return all attributes which are not system defined

func (*Resource) GetAttribute

func (r *Resource) GetAttribute(name string) string

GetAttribute returns an attribute of policy resource

func (*Resource) OrganizationID

func (r *Resource) OrganizationID() string

OrganizationID returns organization ID attribute of policy resource if exists

func (*Resource) Region

func (r *Resource) Region() string

Region returns region attribute of policy resource if exists

func (*Resource) Resource

func (r *Resource) Resource() string

Resource returns resource attribute of policy resource if exists

func (*Resource) ResourceGroupID

func (r *Resource) ResourceGroupID() string

ResourceGroupID returns resource group ID attribute of policy resource if exists

func (*Resource) ResourceType

func (r *Resource) ResourceType() string

ResourceType returns resource type attribute of policy resource if exists

func (*Resource) ServiceInstance

func (r *Resource) ServiceInstance() string

ServiceInstance returns service instance attribute of policy resource if exists

func (*Resource) ServiceName

func (r *Resource) ServiceName() string

ServiceName returns service name attribute of policy resource if exists

func (*Resource) ServiceType

func (r *Resource) ServiceType() string

ServiceType returns service type attribute of policy resource if exists

func (*Resource) SetAccessGroupID

func (r *Resource) SetAccessGroupID(value string)

SetAccessGroupID sets value of access group ID attribute of policy resource

func (*Resource) SetAccountID

func (r *Resource) SetAccountID(value string)

SetAccountID sets value of account ID attribute of policy resource

func (*Resource) SetAttribute

func (r *Resource) SetAttribute(name string, value string)

SetAttribute sets value of an attribute of policy resource

func (*Resource) SetOrganizationID

func (r *Resource) SetOrganizationID(value string)

SetOrganizationID sets value of organization ID attribute of policy resource

func (*Resource) SetRegion

func (r *Resource) SetRegion(value string)

SetRegion sets value of region attribute of policy resource

func (*Resource) SetResource

func (r *Resource) SetResource(value string)

SetResource sets value of resource attribute of policy resource

func (*Resource) SetResourceGroupID

func (r *Resource) SetResourceGroupID(value string)

SetResourceGroupID sets value of resource group ID attribute of policy resource

func (*Resource) SetResourceType

func (r *Resource) SetResourceType(value string)

SetResourceType sets value of resource type attribute of policy resource

func (*Resource) SetServiceInstance

func (r *Resource) SetServiceInstance(value string)

SetServiceInstance sets value of service instance attribute of policy resource

func (*Resource) SetServiceName

func (r *Resource) SetServiceName(value string)

SetServiceName sets value of service name attribute of policy resource

func (*Resource) SetServiceType

func (r *Resource) SetServiceType(value string)

SetServiceType sets value of service type attribute of policy resource

func (*Resource) SetSpaceID

func (r *Resource) SetSpaceID(value string)

SetSpaceID sets value of space ID attribute of policy resource

func (*Resource) SpaceID

func (r *Resource) SpaceID() string

SpaceID returns space ID attribute of policy resource if exists

type Resources

type Resources struct {
	ServiceName     string `json:"serviceName,omitempty"`
	ServiceInstance string `json:"serviceInstance,omitempty"`
	Region          string `json:"region,omitempty"`
	ResourceType    string `json:"resourceType,omitempty"`
	Resource        string `json:"resource,omitempty"`
	SpaceId         string `json:"spaceId,omitempty"`
	AccountId       string `json:"accountId,omitempty"`
	OrganizationId  string `json:"organizationId,omitempty"`
}

type Role

type Role struct {
	RoleID      string `json:"role_id"`
	Name        string `json:"display_name,omitempty"`
	Description string `json:"description,omitempty"`
}

Role is the role model used by policy

func ConvertRoleModels

func ConvertRoleModels(roles []models.PolicyRole) []Role

ConvertRoleModels will transform role models returned from "/v1/roles" to the model used by policy

func ConvertV2RoleModels

func ConvertV2RoleModels(roles []iampapv2.Role) []Role

ConvertV2RoleModels will transform role models returned from "/v2/roles" to the model used by policy

type Roles

type Roles struct {
	ID          string `json:"id" binding:"required"`
	DisplayName string `json:"displayName,omitempty"`
	Description string `json:"description,omitempty"`
}

type SearchParams

type SearchParams struct {
	AccountID     string
	IAMID         string
	AccessGroupID string
	Type          string
	ServiceType   string
	Sort          string
}

type Subject

type Subject struct {
	Attributes []Attribute `json:"attributes"`
}

Subject is the target to which is assigned policy

func (*Subject) AccessGroupID

func (s *Subject) AccessGroupID() string

AccessGroupID returns access group ID attribute of policy subject if exists

func (*Subject) AccountID

func (s *Subject) AccountID() string

AccountID returns account ID attribute of policy subject if exists

func (*Subject) GetAttribute

func (s *Subject) GetAttribute(name string) string

GetAttribute returns an attribute of policy subject

func (*Subject) IAMID

func (s *Subject) IAMID() string

IAMID returns IAM ID attribute of policy subject if exists

func (*Subject) ResourceGroupID

func (s *Subject) ResourceGroupID() string

ResourceGroupID returns resource group ID attribute of policy resource if exists

func (*Subject) ResourceType

func (s *Subject) ResourceType() string

ResourceType returns resource type of the policy subject if exists

func (*Subject) ServiceInstance

func (s *Subject) ServiceInstance() string

ServiceInstance returns service instance attribute of policy subject if exists

func (*Subject) ServiceName

func (s *Subject) ServiceName() string

ServiceName returns service name attribute of policy subject if exists

func (*Subject) SetAccessGroupID

func (s *Subject) SetAccessGroupID(value string)

SetAccessGroupID sets value of access group ID attribute of policy subject

func (*Subject) SetAccountID

func (s *Subject) SetAccountID(value string)

SetAccountID sets value of account ID attribute of policy subject

func (*Subject) SetAttribute

func (s *Subject) SetAttribute(name string, value string)

SetAttribute sets value of an attribute of policy subject

func (*Subject) SetIAMID

func (s *Subject) SetIAMID(value string)

SetIAMID sets value of IAM ID attribute of policy subject

func (*Subject) SetResourceGroupID

func (s *Subject) SetResourceGroupID(value string)

SetResourceGroupID sets value of resource group ID attribute of policy resource

func (*Subject) SetResourceType

func (s *Subject) SetResourceType(value string)

SetResourceType sets value of resource type attribute of policy subject

func (*Subject) SetServiceInstance

func (s *Subject) SetServiceInstance(value string)

SetServiceInstance sets value of service instance attribute of policy subject

func (*Subject) SetServiceName

func (s *Subject) SetServiceName(value string)

SetServiceName sets value of service name attribute of policy subject

type V1PolicyRepository

type V1PolicyRepository interface {
	List(params SearchParams) ([]Policy, error)
	Get(policyID string) (Policy, error)
	Create(policy Policy) (Policy, error)
	Update(policyID string, policy Policy, version string) (Policy, error)
	Delete(policyID string) error
}

func NewV1PolicyRepository

func NewV1PolicyRepository(c *client.Client) V1PolicyRepository

Jump to

Keyboard shortcuts

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