Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CreateRoleEndpoint ¶
type CreateRoleEndpoint struct{}
Creates a custom role that can then be assigned to users in your account.
Roles created through the API are always owned by your account and have the type `user`. Returns a conflict error if a role with the same name already exists.
func (*CreateRoleEndpoint) Materialize ¶
func (e *CreateRoleEndpoint) Materialize() *apiendpoint.APIEndpoint[*CreateRoleRequest, *apiresource.Role]
type CreateRoleRequest ¶
type CreateRoleRequest struct {
// Display name for the role, such as "Warehouse Manager".
//
// Must be unique within your account.
Name string `json:"name" validate:"required,max=255"`
// Permissions to grant, in `{permission}:{action}` format, such as `customers:read`.
//
// The first half is a permission code such as `customers` or `sales_orders`, and the action must be one of `create`, `read`, `update`, or `delete`. List each action separately to grant more than one action on the same permission. A role created without any permissions grants no access until permissions are added.
Permissions []string `json:"permissions,omitzero"`
}
Request to create a role.
func (*CreateRoleRequest) SchemaExample ¶
func (*CreateRoleRequest) SchemaExample() any
type DeleteRoleEndpoint ¶
type DeleteRoleEndpoint struct{}
Deletes a role along with the permissions granted through it.
Only roles owned by your account can be deleted; the system-owned roles shared across all accounts cannot. A role that is still assigned to at least one user is rejected, so move those users to another role first.
func (*DeleteRoleEndpoint) Materialize ¶
func (e *DeleteRoleEndpoint) Materialize() *apiendpoint.APIEndpoint[*DeleteRoleRequest, *apiresource.EmptyResource]
type DeleteRoleRequest ¶
type DeleteRoleRequest struct {
// Role ID.
RoleID string `path:"id" validate:"required"`
}
Request to delete a role.
type ListRolesEndpoint ¶
type ListRolesEndpoint struct{}
Lists the roles that can be assigned to users in your account, newest first.
Results combine the roles your account owns with the system-owned roles shared by every account. Text search matches the role name.
func (*ListRolesEndpoint) Materialize ¶
func (e *ListRolesEndpoint) Materialize() *apiendpoint.APIEndpoint[*ListRolesRequest, *apiresource.List[apiresource.Role]]
type ListRolesRequest ¶
type ListRolesRequest struct {
apiresource.PaginationRequest
// Filter results to roles whose type matches any of the given values.
RoleType []constants.RoleType `query:"types"`
}
Request to list roles.
type RetrieveRoleEndpoint ¶
type RetrieveRoleEndpoint struct{}
Retrieves a single role by ID.
Both the roles your account owns and the system-owned roles shared by every account can be retrieved.
func (*RetrieveRoleEndpoint) Materialize ¶
func (e *RetrieveRoleEndpoint) Materialize() *apiendpoint.APIEndpoint[*RetrieveRoleRequest, *apiresource.Role]
type RetrieveRoleRequest ¶
type RetrieveRoleRequest struct {
// Role ID.
RoleID string `path:"id" validate:"required"`
}
Request to retrieve a role.
type RoleSvc ¶
type RoleSvc interface {
ListRoles(ctx context.Context, req *ListRolesRequest) (*apiresource.List[apiresource.Role], *apierror.APIError)
GetRole(ctx context.Context, req *RetrieveRoleRequest) (*apiresource.Role, *apierror.APIError)
CreateRole(ctx context.Context, req *CreateRoleRequest) (*apiresource.Role, *apierror.APIError)
UpdateRole(ctx context.Context, req *UpdateRoleRequest) (*apiresource.Role, *apierror.APIError)
DeleteRole(ctx context.Context, req *DeleteRoleRequest) (*apiresource.EmptyResource, *apierror.APIError)
}
func NewRoleSvc ¶
func NewRoleSvc(config *RoleSvcConfig) RoleSvc
type RoleSvcConfig ¶
type RoleSvcConfig struct {
// CoreClient (required) is the core-service gRPC client.
CoreClient pb.CoreServiceClient
}
type UpdateRoleEndpoint ¶
type UpdateRoleEndpoint struct{}
Updates a role's name or the set of permissions it grants.
Only roles owned by your account can be updated; the system-owned roles shared across all accounts are rejected. Permission changes apply to every user already assigned the role, starting with their next request.
func (*UpdateRoleEndpoint) Materialize ¶
func (e *UpdateRoleEndpoint) Materialize() *apiendpoint.APIEndpoint[*UpdateRoleRequest, *apiresource.Role]
type UpdateRoleRequest ¶
type UpdateRoleRequest struct {
// Role ID.
RoleID string `path:"id" validate:"required"`
// New display name for the role.
//
// Returns a conflict error if another role in your account already uses this name.
Name field.Optional[string] `json:"name,omitzero" validate:"omitempty,max=255"`
// Full replacement set of permissions, in `{permission}:{action}` format, such as `customers:read`.
//
// The role's existing permissions are discarded and replaced with exactly what you send, so include every permission the role should keep. Sending an empty array strips the role of all access, while leaving the field out keeps the current permissions untouched.
Permissions field.Optional[[]string] `json:"permissions,omitzero"`
}
Request to update a role.
func (*UpdateRoleRequest) SchemaExample ¶
func (*UpdateRoleRequest) SchemaExample() any