Documentation
¶
Index ¶
- Constants
- Variables
- func MakeForbidden(err error) *goa.ServiceError
- func MakeInternalError(err error) *goa.ServiceError
- func MakeInvalidParameters(err error) *goa.ServiceError
- func MakeRoleNotFound(err error) *goa.ServiceError
- func MakeRoleTaken(err error) *goa.ServiceError
- func MakeUnauthorized(err error) *goa.ServiceError
- func MakeUserNotFound(err error) *goa.ServiceError
- func NewAssignRoleToUserEndpoint(s Service) goa.Endpoint
- func NewCreateRoleEndpoint(s Service) goa.Endpoint
- func NewDeleteRoleEndpoint(s Service) goa.Endpoint
- func NewListRolesEndpoint(s Service) goa.Endpoint
- func NewUnassignRoleToUserEndpoint(s Service) goa.Endpoint
- func WrapAssignRoleToUserEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
- func WrapCreateRoleEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
- func WrapDeleteRoleEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
- func WrapListRolesEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
- func WrapUnassignRoleToUserEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
- type AssignRoleToUserPayload
- type AuthentifiedInfo
- type Client
- func (c *Client) AssignRoleToUser(ctx context.Context, p *AssignRoleToUserPayload) (err error)
- func (c *Client) CreateRole(ctx context.Context, p *CreateRolePayload) (res *CreateRoleResult, err error)
- func (c *Client) DeleteRole(ctx context.Context, p *DeleteRolePayload) (err error)
- func (c *Client) ListRoles(ctx context.Context) (res []*Role, err error)
- func (c *Client) UnassignRoleToUser(ctx context.Context, p *UnassignRoleToUserPayload) (err error)
- type CreateRolePayload
- type CreateRoleResult
- type DeleteRolePayload
- type Endpoints
- type IsAdminInfo
- type Role
- type ServerInterceptors
- type Service
- type UnassignRoleToUserPayload
Constants ¶
const APIName = "fishykeys"
APIName is the name of the API as defined in the design.
const APIVersion = "1.0"
APIVersion is the version of the API as defined in the design.
const ServiceName = "roles"
ServiceName is the name of the service as defined in the design. This is the same value that is set in the endpoint request contexts under the ServiceKey key.
Variables ¶
var MethodNames = [5]string{"list roles", "create role", "delete role", "assign role to user", "unassign role to user"}
MethodNames lists the service method names as defined in the design. These are the same values that are set in the endpoint request contexts under the MethodKey key.
Functions ¶
func MakeForbidden ¶
func MakeForbidden(err error) *goa.ServiceError
MakeForbidden builds a goa.ServiceError from an error.
func MakeInternalError ¶
func MakeInternalError(err error) *goa.ServiceError
MakeInternalError builds a goa.ServiceError from an error.
func MakeInvalidParameters ¶
func MakeInvalidParameters(err error) *goa.ServiceError
MakeInvalidParameters builds a goa.ServiceError from an error.
func MakeRoleNotFound ¶
func MakeRoleNotFound(err error) *goa.ServiceError
MakeRoleNotFound builds a goa.ServiceError from an error.
func MakeRoleTaken ¶
func MakeRoleTaken(err error) *goa.ServiceError
MakeRoleTaken builds a goa.ServiceError from an error.
func MakeUnauthorized ¶
func MakeUnauthorized(err error) *goa.ServiceError
MakeUnauthorized builds a goa.ServiceError from an error.
func MakeUserNotFound ¶
func MakeUserNotFound(err error) *goa.ServiceError
MakeUserNotFound builds a goa.ServiceError from an error.
func NewAssignRoleToUserEndpoint ¶
NewAssignRoleToUserEndpoint returns an endpoint function that calls the method "assign role to user" of service "roles".
func NewCreateRoleEndpoint ¶
NewCreateRoleEndpoint returns an endpoint function that calls the method "create role" of service "roles".
func NewDeleteRoleEndpoint ¶
NewDeleteRoleEndpoint returns an endpoint function that calls the method "delete role" of service "roles".
func NewListRolesEndpoint ¶
NewListRolesEndpoint returns an endpoint function that calls the method "list roles" of service "roles".
func NewUnassignRoleToUserEndpoint ¶
NewUnassignRoleToUserEndpoint returns an endpoint function that calls the method "unassign role to user" of service "roles".
func WrapAssignRoleToUserEndpoint ¶
func WrapAssignRoleToUserEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
WrapAssignRoleToUserEndpoint wraps the assign role to user endpoint with the server-side interceptors defined in the design.
func WrapCreateRoleEndpoint ¶
func WrapCreateRoleEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
WrapCreateRoleEndpoint wraps the create role endpoint with the server-side interceptors defined in the design.
func WrapDeleteRoleEndpoint ¶
func WrapDeleteRoleEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
WrapDeleteRoleEndpoint wraps the delete role endpoint with the server-side interceptors defined in the design.
func WrapListRolesEndpoint ¶
func WrapListRolesEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
WrapListRolesEndpoint wraps the list roles endpoint with the server-side interceptors defined in the design.
func WrapUnassignRoleToUserEndpoint ¶
func WrapUnassignRoleToUserEndpoint(endpoint goa.Endpoint, i ServerInterceptors) goa.Endpoint
WrapUnassignRoleToUserEndpoint wraps the unassign role to user endpoint with the server-side interceptors defined in the design.
Types ¶
type AssignRoleToUserPayload ¶
type AssignRoleToUserPayload struct {
// ID of the user to assign the role to
UserID int
// ID of the role to assign to the user
RoleID int
}
AssignRoleToUserPayload is the payload type of the roles service assign role to user method.
type AuthentifiedInfo ¶
type AuthentifiedInfo struct {
// contains filtered or unexported fields
}
AuthentifiedInfo provides metadata about the current interception. It includes service name, method name, and access to the endpoint.
func (*AuthentifiedInfo) CallType ¶
func (info *AuthentifiedInfo) CallType() goa.InterceptorCallType
CallType returns the type of call the interceptor is handling.
func (*AuthentifiedInfo) Method ¶
func (info *AuthentifiedInfo) Method() string
Method returns the name of the method handling the request.
func (*AuthentifiedInfo) RawPayload ¶
func (info *AuthentifiedInfo) RawPayload() any
RawPayload returns the raw payload of the request.
func (*AuthentifiedInfo) Service ¶
func (info *AuthentifiedInfo) Service() string
Service returns the name of the service handling the request.
type Client ¶
type Client struct {
ListRolesEndpoint goa.Endpoint
CreateRoleEndpoint goa.Endpoint
DeleteRoleEndpoint goa.Endpoint
AssignRoleToUserEndpoint goa.Endpoint
UnassignRoleToUserEndpoint goa.Endpoint
}
Client is the "roles" service client.
func NewClient ¶
func NewClient(listRoles, createRole, deleteRole, assignRoleToUser, unassignRoleToUser goa.Endpoint) *Client
NewClient initializes a "roles" service client given the endpoints.
func (*Client) AssignRoleToUser ¶
func (c *Client) AssignRoleToUser(ctx context.Context, p *AssignRoleToUserPayload) (err error)
AssignRoleToUser calls the "assign role to user" endpoint of the "roles" service. AssignRoleToUser may return the following errors:
- "user_not_found" (type *goa.ServiceError): User not found
- "role_not_found" (type *goa.ServiceError): Role not found
- "invalid_parameters" (type *goa.ServiceError): Invalid input
- "internal_error" (type *goa.ServiceError): Internal server error
- "forbidden" (type *goa.ServiceError): Forbidden access
- "unauthorized" (type *goa.ServiceError): Unauthorized access
- error: internal error
func (*Client) CreateRole ¶
func (c *Client) CreateRole(ctx context.Context, p *CreateRolePayload) (res *CreateRoleResult, err error)
CreateRole calls the "create role" endpoint of the "roles" service. CreateRole may return the following errors:
- "role_taken" (type *goa.ServiceError): Role name already exists
- "invalid_parameters" (type *goa.ServiceError): Invalid input
- "internal_error" (type *goa.ServiceError): Internal server error
- "forbidden" (type *goa.ServiceError): Forbidden access
- "unauthorized" (type *goa.ServiceError): Unauthorized access
- error: internal error
func (*Client) DeleteRole ¶
func (c *Client) DeleteRole(ctx context.Context, p *DeleteRolePayload) (err error)
DeleteRole calls the "delete role" endpoint of the "roles" service. DeleteRole may return the following errors:
- "role_not_found" (type *goa.ServiceError): Role not found
- "invalid_parameters" (type *goa.ServiceError): Invalid input
- "internal_error" (type *goa.ServiceError): Internal server error
- "forbidden" (type *goa.ServiceError): Forbidden access
- "unauthorized" (type *goa.ServiceError): Unauthorized access
- error: internal error
func (*Client) ListRoles ¶
ListRoles calls the "list roles" endpoint of the "roles" service. ListRoles may return the following errors:
- "internal_error" (type *goa.ServiceError): Internal server error
- "unauthorized" (type *goa.ServiceError): Unauthorized access
- error: internal error
func (*Client) UnassignRoleToUser ¶
func (c *Client) UnassignRoleToUser(ctx context.Context, p *UnassignRoleToUserPayload) (err error)
UnassignRoleToUser calls the "unassign role to user" endpoint of the "roles" service. UnassignRoleToUser may return the following errors:
- "user_not_found" (type *goa.ServiceError): User not found
- "role_not_found" (type *goa.ServiceError): Role not found
- "invalid_parameters" (type *goa.ServiceError): Invalid input
- "internal_error" (type *goa.ServiceError): Internal server error
- "forbidden" (type *goa.ServiceError): Forbidden access
- "unauthorized" (type *goa.ServiceError): Unauthorized access
- error: internal error
type CreateRolePayload ¶
CreateRolePayload is the payload type of the roles service create role method.
type CreateRoleResult ¶
type CreateRoleResult struct {
// The name of the created role
Name string
// The color of the created role
Color string
// Unique identifier for the role
ID int
}
CreateRoleResult is the result type of the roles service create role method.
type DeleteRolePayload ¶
type DeleteRolePayload struct {
// ID of the role to delete
ID int
}
DeleteRolePayload is the payload type of the roles service delete role method.
type Endpoints ¶
type Endpoints struct {
ListRoles goa.Endpoint
CreateRole goa.Endpoint
DeleteRole goa.Endpoint
AssignRoleToUser goa.Endpoint
UnassignRoleToUser goa.Endpoint
}
Endpoints wraps the "roles" service endpoints.
func NewEndpoints ¶
func NewEndpoints(s Service, si ServerInterceptors) *Endpoints
NewEndpoints wraps the methods of the "roles" service with endpoints.
type IsAdminInfo ¶
type IsAdminInfo struct {
// contains filtered or unexported fields
}
IsAdminInfo provides metadata about the current interception. It includes service name, method name, and access to the endpoint.
func (*IsAdminInfo) CallType ¶
func (info *IsAdminInfo) CallType() goa.InterceptorCallType
CallType returns the type of call the interceptor is handling.
func (*IsAdminInfo) Method ¶
func (info *IsAdminInfo) Method() string
Method returns the name of the method handling the request.
func (*IsAdminInfo) RawPayload ¶
func (info *IsAdminInfo) RawPayload() any
RawPayload returns the raw payload of the request.
func (*IsAdminInfo) Service ¶
func (info *IsAdminInfo) Service() string
Service returns the name of the service handling the request.
type ServerInterceptors ¶
type ServerInterceptors interface {
// Server-side interceptor that validates JWT token for HTTP services
Authentified(ctx context.Context, info *AuthentifiedInfo, next goa.Endpoint) (any, error)
// Server-side interceptor that checks if the user has admin privileges
IsAdmin(ctx context.Context, info *IsAdminInfo, next goa.Endpoint) (any, error)
}
ServerInterceptors defines the interface for all server-side interceptors. Server interceptors execute after the request is decoded and before the payload is sent to the service. The implementation is responsible for calling next to complete the request.
type Service ¶
type Service interface {
// List all roles
ListRoles(context.Context) (res []*Role, err error)
// Create a new role
CreateRole(context.Context, *CreateRolePayload) (res *CreateRoleResult, err error)
// Delete a role byd id
DeleteRole(context.Context, *DeleteRolePayload) (err error)
// Assign a role to a user
AssignRoleToUser(context.Context, *AssignRoleToUserPayload) (err error)
// Unassign a role to a user
UnassignRoleToUser(context.Context, *UnassignRoleToUserPayload) (err error)
}
Roles service manages roles
type UnassignRoleToUserPayload ¶
type UnassignRoleToUserPayload struct {
// ID of the user to unassign the role to
UserID int
// ID of the role to unassign to the user
RoleID int
}
UnassignRoleToUserPayload is the payload type of the roles service unassign role to user method.