roles

package
v0.0.0-...-fc6304d Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Index

Constants

View Source
const APIName = "fishykeys"

APIName is the name of the API as defined in the design.

View Source
const APIVersion = "1.0"

APIVersion is the version of the API as defined in the design.

View Source
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

View Source
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

func NewAssignRoleToUserEndpoint(s Service) goa.Endpoint

NewAssignRoleToUserEndpoint returns an endpoint function that calls the method "assign role to user" of service "roles".

func NewCreateRoleEndpoint

func NewCreateRoleEndpoint(s Service) goa.Endpoint

NewCreateRoleEndpoint returns an endpoint function that calls the method "create role" of service "roles".

func NewDeleteRoleEndpoint

func NewDeleteRoleEndpoint(s Service) goa.Endpoint

NewDeleteRoleEndpoint returns an endpoint function that calls the method "delete role" of service "roles".

func NewListRolesEndpoint

func NewListRolesEndpoint(s Service) goa.Endpoint

NewListRolesEndpoint returns an endpoint function that calls the method "list roles" of service "roles".

func NewUnassignRoleToUserEndpoint

func NewUnassignRoleToUserEndpoint(s Service) goa.Endpoint

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

func (c *Client) ListRoles(ctx context.Context) (res []*Role, err error)

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

type CreateRolePayload struct {
	// Name or the role
	Name string
	// Color of the role
	Color string
}

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.

func (*Endpoints) Use

func (e *Endpoints) Use(m func(goa.Endpoint) goa.Endpoint)

Use applies the given middleware to all the "roles" service 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 Role

type Role struct {
	// Unique identifier for the role
	ID int
	// Name of the role
	Name string
	// Color associated with the role
	Color string
	// Is this role an admin role?
	Admin bool
	// Role creation timestamp
	CreatedAt string
	// Role last update timestamp
	UpdatedAt string
}

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.

Jump to

Keyboard shortcuts

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