Documentation
¶
Overview ¶
Package ccsapi implements the HTTP handlers for the Credentials Config Service REST API. It provides CRUD operations for service configurations, matching the CCS OpenAPI specification for request/response formats.
Index ¶
- Constants
- func CreateService(repo database.ServiceRepository) gin.HandlerFunc
- func DeleteService(repo database.ServiceRepository) gin.HandlerFunc
- func GetAllServices(repo database.ServiceRepository) gin.HandlerFunc
- func GetService(repo database.ServiceRepository) gin.HandlerFunc
- func GetServiceScopes(repo database.ServiceRepository) gin.HandlerFunc
- func RegisterRoutes(router *gin.Engine, repo database.ServiceRepository)
- func ServiceRequestToConfiguredService(req ServiceRequest, id string) config.ConfiguredService
- func UpdateService(repo database.ServiceRepository) gin.HandlerFunc
- type ProblemDetails
- type ServiceRequest
- type ServiceResponse
- type ServicesListResponse
Constants ¶
const ( // ProblemTypeValidation is the problem type for request validation failures. ProblemTypeValidation = "https://fiware.github.io/VCVerifier/problem/validation-error" // ProblemTypeNotFound is the problem type for resource-not-found errors. ProblemTypeNotFound = "https://fiware.github.io/VCVerifier/problem/not-found" // ProblemTypeConflict is the problem type for resource-already-exists errors. ProblemTypeConflict = "https://fiware.github.io/VCVerifier/problem/conflict" // ProblemTypeInternal is the problem type for unexpected server errors. ProblemTypeInternal = "https://fiware.github.io/VCVerifier/problem/internal-error" )
Problem type URIs used in ProblemDetails responses.
const ( // DefaultPage is the default zero-based page index. DefaultPage = 0 // DefaultPageSize is the default number of services per page. DefaultPageSize = 100 )
Default pagination parameters used when query parameters are omitted.
Variables ¶
This section is empty.
Functions ¶
func CreateService ¶
func CreateService(repo database.ServiceRepository) gin.HandlerFunc
CreateService returns a Gin handler that creates a new service configuration. POST /service
On success, returns 201 Created with a Location header pointing to the new resource. Returns 400 for invalid input, 409 if the service ID already exists.
func DeleteService ¶
func DeleteService(repo database.ServiceRepository) gin.HandlerFunc
DeleteService returns a Gin handler that removes a service by ID. DELETE /service/:id
Returns 204 on success or 404 if not found.
func GetAllServices ¶
func GetAllServices(repo database.ServiceRepository) gin.HandlerFunc
GetAllServices returns a Gin handler that lists services with pagination. GET /service?page=0&pageSize=100
Returns 200 with a ServicesListResponse containing the requested page.
func GetService ¶
func GetService(repo database.ServiceRepository) gin.HandlerFunc
GetService returns a Gin handler that retrieves a single service by ID. GET /service/:id
Returns 200 with the service or 404 if not found.
func GetServiceScopes ¶
func GetServiceScopes(repo database.ServiceRepository) gin.HandlerFunc
GetServiceScopes returns a Gin handler that retrieves credential types for a service's scope. GET /service/:id/scope?oidcScope=<scope>
When oidcScope is omitted, the service's default scope is used. Returns 200 with a JSON array of credential type strings, or 404 if the service or scope is not found.
func RegisterRoutes ¶
func RegisterRoutes(router *gin.Engine, repo database.ServiceRepository)
RegisterRoutes registers all CCS API routes on the given Gin engine. Routes are registered under the /service path prefix, matching the Credentials Config Service OpenAPI specification:
POST /service — Create a new service GET /service — List services (paginated) GET /service/:id — Get a single service PUT /service/:id — Update a service DELETE /service/:id — Delete a service GET /service/:id/scope — Get credential types for a scope
func ServiceRequestToConfiguredService ¶
func ServiceRequestToConfiguredService(req ServiceRequest, id string) config.ConfiguredService
ServiceRequestToConfiguredService converts a ServiceRequest into a config.ConfiguredService for persistence via the repository layer.
func UpdateService ¶
func UpdateService(repo database.ServiceRepository) gin.HandlerFunc
UpdateService returns a Gin handler that replaces an existing service. PUT /service/:id
Returns 200 with the updated service, 400 for invalid input, or 404 if not found.
Types ¶
type ProblemDetails ¶
type ProblemDetails struct {
// Type is a URI reference that identifies the problem type.
Type string `json:"type"`
// Title is a short human-readable summary of the problem.
Title string `json:"title"`
// Status is the HTTP status code.
Status int `json:"status"`
// Detail is a human-readable explanation specific to this occurrence.
Detail string `json:"detail"`
// Instance is a URI reference that identifies the specific occurrence.
Instance string `json:"instance,omitempty"`
}
ProblemDetails represents an RFC 7807 Problem Details response used for error reporting. All CCS API error responses use this format.
type ServiceRequest ¶
type ServiceRequest struct {
// ID is the unique service identifier. Required for POST; ignored for PUT
// (the URL path parameter is used instead).
ID string `json:"id,omitempty"`
// DefaultOidcScope is the default OIDC scope name to use when none is specified.
DefaultOidcScope string `json:"defaultOidcScope"`
// OidcScopes maps scope names to their credential requirements.
OidcScopes map[string]config.ScopeEntry `json:"oidcScopes"`
// AuthorizationType describes the authorization mode (e.g., "oidc").
AuthorizationType string `json:"authorizationType,omitempty"`
}
ServiceRequest represents the JSON body for creating or updating a service. Fields match the CCS OpenAPI specification.
type ServiceResponse ¶
type ServiceResponse struct {
// ID is the unique service identifier.
ID string `json:"id"`
// DefaultOidcScope is the default OIDC scope name.
DefaultOidcScope string `json:"defaultOidcScope"`
// OidcScopes maps scope names to their credential requirements.
OidcScopes map[string]config.ScopeEntry `json:"oidcScopes"`
// AuthorizationType describes the authorization mode.
AuthorizationType string `json:"authorizationType,omitempty"`
}
ServiceResponse represents the JSON response body for a single service.
func ConfiguredServiceToResponse ¶
func ConfiguredServiceToResponse(svc config.ConfiguredService) ServiceResponse
ConfiguredServiceToResponse converts a config.ConfiguredService into a ServiceResponse for the API response body.
func ConfiguredServicesToResponses ¶
func ConfiguredServicesToResponses(services []config.ConfiguredService) []ServiceResponse
ConfiguredServicesToResponses converts a slice of config.ConfiguredService into a slice of ServiceResponse values.
type ServicesListResponse ¶
type ServicesListResponse struct {
// Total is the total number of services across all pages.
Total int `json:"total"`
// PageNumber is the zero-based page index returned.
PageNumber int `json:"pageNumber"`
// PageSize is the maximum number of services per page.
PageSize int `json:"pageSize"`
// Services is the list of services for the current page.
Services []ServiceResponse `json:"services"`
}
ServicesListResponse represents the paginated JSON response for listing services.