Source code for magpie.api.schemas

import uuid
from typing import TYPE_CHECKING

import colander
import six
from cornice import Service
from cornice.service import get_services
from cornice_swagger.swagger import CorniceSwagger
from pyramid.httpexceptions import (
    HTTPAccepted,
    HTTPBadRequest,
    HTTPConflict,
    HTTPCreated,
    HTTPForbidden,
    HTTPFound,
    HTTPGone,
    HTTPInternalServerError,
    HTTPMethodNotAllowed,
    HTTPNotAcceptable,
    HTTPNotFound,
    HTTPOk,
    HTTPUnauthorized,
    HTTPUnprocessableEntity
)
from pyramid.security import NO_PERMISSION_REQUIRED

from magpie import __meta__
from magpie.constants import get_constant
from magpie.models import UserGroupStatus, UserStatuses
from magpie.permissions import Access, Permission, PermissionType, Scope
from magpie.security import get_providers
from magpie.utils import (
    CONTENT_TYPE_HTML,
    CONTENT_TYPE_JSON,
    KNOWN_CONTENT_TYPES,
    SUPPORTED_ACCEPT_TYPES,
    SUPPORTED_FORMAT_TYPES
)

if TYPE_CHECKING:
    # pylint: disable=W0611,unused-import
    from typing import Any, Dict, List, Union

    from magpie.typedefs import JSON, Str

# ignore naming style of tags
# pylint: disable=C0103,invalid-name

[docs] TitleAPI = "Magpie REST API"
[docs] InfoAPI = { "description": __meta__.__description__, "contact": {"name": __meta__.__maintainer__, "email": __meta__.__email__, "url": __meta__.__url__} }
# Security
[docs] SecurityCookieAuthAPI = {"cookieAuth": {"type": "apiKey", "in": "cookie", "name": get_constant("MAGPIE_COOKIE_NAME")}}
[docs] SecurityDefinitionsAPI = {"securityDefinitions": SecurityCookieAuthAPI}
[docs] SecurityAuthenticatedAPI = [{"cookieAuth": []}]
[docs] SecurityAdministratorAPI = [{"cookieAuth": []}]
[docs] SecurityEveryoneAPI = [{}]
[docs] def get_security(service, method): definitions = service.definitions args = {} for definition in definitions: met, _, args = definition if met == method: break # automatically retrieve permission if specified within the view definition permission = args.get("permission") if permission == NO_PERMISSION_REQUIRED: return SecurityEveryoneAPI if permission == get_constant("MAGPIE_ADMIN_PERMISSION"): return SecurityAdministratorAPI # return default admin permission otherwise unless specified form cornice decorator return SecurityAdministratorAPI if "security" not in args else args["security"]
# Path definitions (from services and parameters)
[docs] def service_api_route_info(service_api, **kwargs): # type: (Service, **Any) -> Dict[Str, Any] kwargs.update({ "name": service_api.name, "pattern": service_api.path, }) kwargs.setdefault("traverse", getattr(service_api, "traverse", None)) kwargs.setdefault("factory", getattr(service_api, "factory", None)) return kwargs
# Service Routes
[docs] _LOGGED_USER_VALUE = get_constant("MAGPIE_LOGGED_USER")
[docs] LoggedUserBase = "/users/{}".format(_LOGGED_USER_VALUE)
[docs] SwaggerGenerator = Service( path="/json", name="swagger_schema_json")
[docs] SwaggerAPI = Service( path="/api", name="swagger_schema_ui", description="{} documentation".format(TitleAPI))
[docs] UsersAPI = Service( path="/users", name="Users")
[docs] UserAPI = Service( path="/users/{user_name}", name="User")
[docs] UserGroupsAPI = Service( path="/users/{user_name}/groups", name="UserGroups")
[docs] UserGroupAPI = Service( path="/users/{user_name}/groups/{group_name}", name="UserGroup")
[docs] UserResourcesAPI = Service( path="/users/{user_name}/resources", name="UserResources")
[docs] UserResourcePermissionsAPI = Service( path="/users/{user_name}/resources/{resource_id}/permissions", name="UserResourcePermissions")
[docs] UserResourcePermissionAPI = Service( path="/users/{user_name}/resources/{resource_id}/permissions/{permission_name}", name="UserResourcePermission")
[docs] UserServicesAPI = Service( path="/users/{user_name}/services", name="UserServices")
[docs] UserServiceAPI = Service( path="/users/{user_name}/services/{service_name}", name="UserService")
[docs] UserServiceResourcesAPI = Service( path="/users/{user_name}/services/{service_name}/resources", name="UserServiceResources")
[docs] UserServicePermissionsAPI = Service( path="/users/{user_name}/services/{service_name}/permissions", name="UserServicePermissions")
[docs] UserServicePermissionAPI = Service( path="/users/{user_name}/services/{service_name}/permissions/{permission_name}", name="UserServicePermission")
[docs] LoggedUserAPI = Service( path=LoggedUserBase, name="LoggedUser")
[docs] LoggedUserGroupsAPI = Service( path=LoggedUserBase + "/groups", name="LoggedUserGroups")
[docs] LoggedUserGroupAPI = Service( path=LoggedUserBase + "/groups/{group_name}", name="LoggedUserGroup")
[docs] LoggedUserResourcesAPI = Service( path=LoggedUserBase + "/resources", name="LoggedUserResources")
[docs] LoggedUserResourcePermissionAPI = Service( path=LoggedUserBase + "/resources/{resource_id}/permissions/{permission_name}", name="LoggedUserResourcePermission")
[docs] LoggedUserResourcePermissionsAPI = Service( path=LoggedUserBase + "/resources/{resource_id}/permissions", name="LoggedUserResourcePermissions")
[docs] LoggedUserServicesAPI = Service( path=LoggedUserBase + "/services", name="LoggedUserServices")
[docs] LoggedUserServiceResourcesAPI = Service( path=LoggedUserBase + "/services/{service_name}/resources", name="LoggedUserServiceResources")
[docs] LoggedUserServicePermissionsAPI = Service( path=LoggedUserBase + "/services/{service_name}/permissions", name="LoggedUserServicePermissions")
[docs] LoggedUserServicePermissionAPI = Service( path=LoggedUserBase + "/services/{service_name}/permissions/{permission_name}", name="LoggedUserServicePermission")
[docs] GroupsAPI = Service( path="/groups", name="Groups")
[docs] GroupAPI = Service( path="/groups/{group_name}", name="Group")
[docs] GroupUsersAPI = Service( path="/groups/{group_name}/users", name="GroupUsers")
[docs] GroupServicesAPI = Service( path="/groups/{group_name}/services", name="GroupServices")
[docs] GroupServicePermissionsAPI = Service( path="/groups/{group_name}/services/{service_name}/permissions", name="GroupServicePermissions")
[docs] GroupServicePermissionAPI = Service( path="/groups/{group_name}/services/{service_name}/permissions/{permission_name}", name="GroupServicePermission")
[docs] GroupServiceResourcesAPI = Service( path="/groups/{group_name}/services/{service_name}/resources", name="GroupServiceResources")
[docs] GroupResourcesAPI = Service( path="/groups/{group_name}/resources", name="GroupResources")
[docs] GroupResourcePermissionsAPI = Service( path="/groups/{group_name}/resources/{resource_id}/permissions", name="GroupResourcePermissions")
[docs] GroupResourcePermissionAPI = Service( path="/groups/{group_name}/resources/{resource_id}/permissions/{permission_name}", name="GroupResourcePermission")
[docs] PermissionsAPI = Service( path="/permissions", name="Permissions")
[docs] RegisterGroupsAPI = Service( path="/register/groups", name="RegisterGroups")
[docs] RegisterGroupAPI = Service( path="/register/groups/{group_name}", name="RegisterGroup")
[docs] RegisterUsersAPI = Service( path="/register/users", name="RegisterUsers")
[docs] RegisterUserAPI = Service( path="/register/users/{user_name}", name="RegisterUser")
[docs] ResourcesAPI = Service( path="/resources", name="Resources")
[docs] ResourceAPI = Service( path="/resources/{resource_id}", name="Resource")
[docs] ResourcePermissionsAPI = Service( path="/resources/{resource_id}/permissions", name="ResourcePermissions")
[docs] ResourceTypesAPI = Service( path="/resources/{resource_id}/types", name="ResourceTypes")
[docs] ServicesAPI = Service( path="/services", name="Services")
[docs] ServiceAPI = Service( path="/services/{service_name}", name="Service")
[docs] ServiceTypesAPI = Service( path="/services/types", name="ServiceTypes")
[docs] ServiceTypeAPI = Service( path="/services/types/{service_type}", name="ServiceType")
[docs] ServicePermissionsAPI = Service( path="/services/{service_name}/permissions", name="ServicePermissions")
[docs] ServiceResourcesAPI = Service( path="/services/{service_name}/resources", name="ServiceResources")
[docs] ServiceResourceAPI = Service( path="/services/{service_name}/resources/{resource_id}", name="ServiceResource")
[docs] ServiceTypeResourcesAPI = Service( path="/services/types/{service_type}/resources", name="ServiceTypeResources")
[docs] ServiceTypeResourceTypesAPI = Service( path="/services/types/{service_type}/resources/types", name="ServiceTypeResourceTypes")
[docs] ProvidersAPI = Service( path="/providers", name="Providers")
[docs] ProviderSigninAPI = Service( path="/providers/{provider_name}/signin", name="ProviderSignin")
[docs] SigninAPI = Service( path="/signin", name="signin")
[docs] SignoutAPI = Service( path="/signout", name="signout")
[docs] SessionAPI = Service( path="/session", name="Session")
[docs] VersionAPI = Service( path="/version", name="Version")
[docs] HomepageAPI = Service( path="/", name="homepage")
[docs] TemporaryUrlAPI = Service( path="/tmp/{token}", # nosec: B108 name="temporary_url")
# Path parameters
[docs] GroupNameParameter = colander.SchemaNode( colander.String(), description="Registered user group.", example="users",)
[docs] UserNameParameter = colander.SchemaNode( colander.String(), description="Registered local user.", example="toto",)
[docs] ProviderNameParameter = colander.SchemaNode( colander.String(), description="External identity provider.", example="DKRZ", validator=colander.OneOf(list(get_providers())))
[docs] PermissionNameParameter = colander.SchemaNode( colander.String(), description="Permissions applicable to the service/resource.", example=Permission.READ.value,)
[docs] ResourceIdParameter = colander.SchemaNode( colander.String(), description="Registered resource ID.", example="123")
[docs] ResourceTypeParameter = colander.SchemaNode( colander.String(), description="Known resource type.", example="process")
[docs] ServiceNameParameter = colander.SchemaNode( colander.String(), description="Registered service name.", example="my-wps")
[docs] ServiceTypeParameter = colander.SchemaNode( colander.String(), description="Known service type.", example="wps")
[docs] TokenParameter = colander.SchemaNode( colander.String(), description="Temporary URL token.", example=str(uuid.uuid4()))
[docs] class ServiceType_RequestPathSchema(colander.MappingSchema):
[docs] service_type = ServiceTypeParameter
[docs] class Service_RequestPathSchema(colander.MappingSchema):
[docs] service_name = ServiceNameParameter
[docs] class Resource_RequestPathSchema(colander.MappingSchema):
[docs] resource_id = ResourceIdParameter
[docs] class ServiceResource_RequestPathSchema(colander.MappingSchema):
[docs] service_name = ServiceNameParameter
[docs] resource_id = ResourceIdParameter
[docs] class Permission_RequestPathSchema(colander.MappingSchema):
[docs] permission_name = PermissionNameParameter
[docs] class Group_RequestPathSchema(colander.MappingSchema):
[docs] group_name = GroupNameParameter
[docs] class User_RequestPathSchema(colander.MappingSchema):
[docs] user_name = UserNameParameter
[docs] class UserGroup_RequestPathSchema(colander.MappingSchema):
[docs] user_name = UserNameParameter
[docs] group_name = GroupNameParameter
[docs] class GroupService_RequestPathSchema(colander.MappingSchema):
[docs] group_name = GroupNameParameter
[docs] service_name = UserNameParameter
[docs] class GroupServicePermission_RequestPathSchema(colander.MappingSchema):
[docs] group_name = GroupNameParameter
[docs] service_name = UserNameParameter
[docs] permission_name = PermissionNameParameter
[docs] class GroupResource_RequestPathSchema(colander.MappingSchema):
[docs] group_name = GroupNameParameter
[docs] resource_id = ResourceIdParameter
[docs] class GroupResourcePermission_RequestPathSchema(colander.MappingSchema):
[docs] group_name = GroupNameParameter
[docs] resource_id = ResourceIdParameter
[docs] permission_name = PermissionNameParameter
[docs] class UserService_RequestPathSchema(colander.MappingSchema):
[docs] user_name = UserNameParameter
[docs] service_name = UserNameParameter
[docs] class UserServicePermission_RequestPathSchema(colander.MappingSchema):
[docs] user_name = UserNameParameter
[docs] service_name = UserNameParameter
[docs] permission_name = PermissionNameParameter
[docs] class UserResource_RequestPathSchema(colander.MappingSchema):
[docs] user_name = UserNameParameter
[docs] resource_id = ResourceIdParameter
[docs] class UserResourcePermission_RequestPathSchema(colander.MappingSchema):
[docs] user_name = UserNameParameter
[docs] resource_id = ResourceIdParameter
[docs] permission_name = PermissionNameParameter
[docs] class Provider_RequestPathSchema(colander.MappingSchema):
[docs] provider_name = ProviderNameParameter
[docs] class TemporaryURL_RequestPathSchema(colander.MappingSchema):
[docs] token = TokenParameter
# Tags
[docs] APITag = "API"
[docs] SessionTag = "Session"
[docs] UsersTag = "User"
[docs] LoggedUserTag = "Logged User"
[docs] GroupsTag = "Group"
[docs] PermissionTag = "Permission"
[docs] RegisterTag = "Register"
[docs] ResourcesTag = "Resource"
[docs] ServicesTag = "Service"
[docs] TAG_DESCRIPTIONS = { APITag: "General information about the API.", SessionTag: "Session user management and available providers for authentication.", UsersTag: "Users information management and control of their applicable groups, services, resources and permissions.\n\n" "Administrator-level permissions are required to access most paths. Depending on context, some paths are " "permitted additional access if the logged session user corresponds to the path variable user.", LoggedUserTag: "Utility paths that correspond to their {} counterparts, but that automatically ".format(UserAPI.path) + "determine the applicable user from the logged session.\n\n" "If there is no active session, the public unauthenticated access is employed.", GroupsTag: "Groups management and control of their applicable users, services, resources and permissions.\n\n" "Administrator-level permissions are required to access most paths. ", PermissionTag: "Management of user or group permissions over services and resources definitions.", RegisterTag: "Registration paths for operations available to users (including non-administrators).", ResourcesTag: "Management of resources that reside under a given service and their applicable permissions.", ServicesTag: "Management of service definitions, children resources and their applicable permissions.", }
# Header definitions
[docs] class AcceptType(colander.SchemaNode):
[docs] schema_type = colander.String
[docs] default = CONTENT_TYPE_JSON
[docs] example = CONTENT_TYPE_JSON
[docs] missing = colander.drop
[docs] class ContentType(colander.SchemaNode):
[docs] schema_type = colander.String
[docs] name = "Content-Type"
[docs] default = CONTENT_TYPE_JSON
[docs] example = CONTENT_TYPE_JSON
[docs] missing = colander.drop
[docs] class RequestHeaderSchemaAPI(colander.MappingSchema):
[docs] accept = AcceptType(name="Accept", validator=colander.OneOf(SUPPORTED_ACCEPT_TYPES), description="Desired media-type for the response body content.")
[docs] content_type = ContentType(validator=colander.OneOf(KNOWN_CONTENT_TYPES), description="Media-type of the request body content.")
[docs] class RequestHeaderSchemaUI(colander.MappingSchema):
[docs] content_type = ContentType(default=CONTENT_TYPE_HTML, example=CONTENT_TYPE_HTML, description="Media-type of the request body content.")
[docs] class QueryRequestSchemaAPI(colander.MappingSchema):
[docs] format = AcceptType(validator=colander.OneOf(SUPPORTED_FORMAT_TYPES), description="Desired media-type for the response body content. " "This formatting alternative by query parameter overrides the Accept header.")
[docs] class QueryEffectivePermissions(colander.MappingSchema):
[docs] effective = colander.SchemaNode( colander.Boolean(), name="effective", default=False, missing=colander.drop, description=( "Obtain user's effective permissions resolved with corresponding service inheritance functionality. " "(Note: Group inheritance is enforced regardless of 'inherited' query parameter values.)" ) )
[docs] class QueryInheritGroupsPermissions(colander.MappingSchema):
[docs] inherit = colander.SchemaNode( colander.Boolean(), name="inherited", default=False, missing=colander.drop, description=( "Include the user's groups memberships inheritance to retrieve all possible permissions. " "(Note: Duplicate, redundant and even conflicting permissions can be obtained when considering " "multiple applied permissions individually applied from different group memberships or for the user " "itself. See 'resolve' query parameter to reduce the set into a single highest priority permission)." ) )
[docs] class QueryResolvedUserGroupsPermissions(colander.MappingSchema):
[docs] resolve = colander.SchemaNode( colander.Boolean(), name="resolve", default=False, missing=colander.drop, description=( "Combines corresponding direct user and groups inherited permissions into one, and locally resolves " "for every resource the applicable permission modifiers considering group precedence and priorities. " "(Note: Group permissions retrieval is enforced when using this option regardless of 'inherited' query " "parameter since they are required to perform resolution)." ) )
[docs] class QueryFilterResources(colander.MappingSchema):
[docs] filtered = colander.SchemaNode( colander.Boolean(), name="filtered", default=False, missing=colander.drop, description=( "Filter returned resources only where user has permissions on, either directly or inherited by groups " "according to other query parameters. Otherwise (default), return all existing resources " "with empty permission sets when user has no permission on them. Filtered view is enforced for " "non-admin request user." ) )
[docs] class QueryParentResources(colander.MappingSchema):
[docs] parents = colander.SchemaNode( colander.Boolean(), name="parents", default=False, missing=colander.drop, description=( "Obtain parent resources of the requested resource by ID instead of its children hierarchy. " "The requested resource by ID will be the top-most object with nested 'parent' field " "(instead of 'children' when 'parents=false') going all the way down to the root service of that resource. " "Contrary to children hierarchy representation that can branch out over multiple children resources, " "parent resources are guaranteed to have a single branch (each resource can only have one parent). " "For this reason, it is possible to combine this parameter with 'flatten' and 'invert' to list resources " "in a different order and/or format. These other queries are ignored when 'parents=false'." ) )
[docs] flatten = colander.SchemaNode( colander.Boolean(), name="flatten", default=False, missing=colander.drop, description=( "Applies only when 'parents=true'. Returns elements as a flattened list of JSON objects instead of default " "response format as nested objects with resource ID keys and parent resource definitions under them. " "Can be combined with 'invert' query to reverse the order of resource items in the returned list." ) )
[docs] invert = colander.SchemaNode( colander.Boolean(), name="invert", default=False, missing=colander.drop, description=( "Applies only when 'parents=true'. Returns elements in the inverse order, going from top-most service " "down to (at most) the requested resource by ID listing all its intermediate children. This is different " "than using 'parents=false' where the complete children hierarchy *under the requested resource ID* are " "returned, with all possible branches. When this option is combined with 'parent', only the resources " "on the specific branch directly linking the root service to the requested resource by ID are returned " "instead of the full hierarchy, effectively only returning the resource " "hierarchy *above the requested resource ID*. Note that for this reason, the requested resource will " "always be the last/deepest item returned, even if it could have more children resources in reality. " "Can be combined with 'flatten' query to obtain a list instead of nested objects." ) )
[docs] class QueryCascadeResourcesPermissions(colander.MappingSchema):
[docs] cascade = colander.SchemaNode( colander.Boolean(), name="cascade", default=False, missing=colander.drop, description=( "Display all services that has at least one permission at any level in his hierarchy " "(including all children resources). Otherwise (default), only returns services that have permissions " "explicitly set on them, ignoring permissions set on children resources." ) )
[docs] class QueryFlattenServices(colander.MappingSchema):
[docs] flatten = colander.SchemaNode( colander.Boolean(), name="flatten", default=False, missing=colander.drop, description=( "Return elements as a flattened list of JSON objects instead of default response format. " "Default is a nested JSON of service-type keys with children service-name keys, each containing " "their respective service definition as JSON object." ) )
[docs] class QueryFilterServiceType(colander.MappingSchema):
[docs] svc_type = colander.SchemaNode( colander.String(), name="type", missing=colander.drop, example="api,thredds", description=( "Comma-separated list of service-type for which to filter retrieved descriptions instead of all " "available ones. Provided types matching is case insensitive. Unknown types are ignored." ) )
[docs] class PhoenixServicePushOption(colander.SchemaNode):
[docs] schema_type = colander.Boolean
[docs] description = "Push service update to Phoenix if applicable"
[docs] missing = colander.drop
[docs] default = False
[docs] class BaseRequestSchemaAPI(colander.MappingSchema):
[docs] header = RequestHeaderSchemaAPI()
[docs] querystring = QueryRequestSchemaAPI()
[docs] class HeaderResponseSchema(colander.MappingSchema):
[docs] content_type = ContentType(validator=colander.OneOf(SUPPORTED_ACCEPT_TYPES), description="Media-type of the response body content.")
[docs] class BaseResponseSchemaAPI(colander.MappingSchema):
[docs] header = HeaderResponseSchema()
[docs] class BaseResponseBodySchema(colander.MappingSchema): def __init__(self, code, description, **kw): super(BaseResponseBodySchema, self).__init__(**kw) assert isinstance(code, int) # nosec: B101 assert isinstance(description, six.string_types) # nosec: B101 # update the values child_nodes = getattr(self, "children", []) child_nodes.append(colander.SchemaNode( colander.Integer(), name="code", description="HTTP response code", example=code)) child_nodes.append(colander.SchemaNode( colander.String(), name="type", description="Response content type", example=CONTENT_TYPE_JSON)) child_nodes.append(colander.SchemaNode( colander.String(), name="detail", description="Response status message", example=description))
[docs] class ErrorVerifyParamConditions(colander.MappingSchema):
[docs] not_none = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] not_empty = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] not_in = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] not_equal = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] is_none = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] is_empty = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] is_in = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] is_equal = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] is_true = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] is_false = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] is_type = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] matches = colander.SchemaNode(colander.Boolean(), missing=colander.drop)
[docs] class ErrorVerifyParamBodySchema(colander.MappingSchema):
[docs] name = colander.SchemaNode( colander.String(), description="Name of the failing condition parameter that caused the error.", missing=colander.drop)
[docs] value = colander.SchemaNode( colander.String(), description="Value of the failing condition parameter that caused the error.", default=None)
[docs] compare = colander.SchemaNode( colander.String(), description="Comparison value(s) employed for evaluation of the failing condition parameter.", missing=colander.drop)
[docs] conditions = ErrorVerifyParamConditions( description="Evaluated conditions on the parameter value with corresponding validation status. " "Some results are relative to the comparison value when provided.")
[docs] class ErrorFallbackBodySchema(colander.MappingSchema):
[docs] exception = colander.SchemaNode(colander.String(), description="Raise exception.")
[docs] error = colander.SchemaNode(colander.String(), description="Error message describing the cause of exception.")
[docs] class ErrorCallBodySchema(ErrorFallbackBodySchema):
[docs] detail = colander.SchemaNode(colander.String(), description="Contextual explanation about the cause of error.")
[docs] content = colander.MappingSchema(default=None, unknown="preserve", description="Additional contextual details that lead to the error. " "Can have any amount of sub-field to describe evaluated values.")
[docs] type = colander.SchemaNode(colander.String(), default=None, missing=colander.drop, description="Content-Type of the original call contents.")
[docs] class ErrorResponseBodySchema(BaseResponseBodySchema): def __init__(self, code, description, **kw): # type: (int, str, **Any) -> None super(ErrorResponseBodySchema, self).__init__(code, description, **kw) assert code >= 400 # nosec: B101
[docs] route_name = colander.SchemaNode( colander.String(), description="Route called that generated the error.", example="/users/toto" )
[docs] request_url = colander.SchemaNode( colander.String(), title="Request URL", description="Request URL that generated the error.", example="http://localhost:2001/magpie/users/toto", validator=colander.url, )
[docs] method = colander.SchemaNode( colander.String(), description="Request method that generated the error.", example="GET" )
[docs] param = ErrorVerifyParamBodySchema( title="Parameter", missing=colander.drop, description="Additional parameter details to explain the cause of error." )
[docs] call = ErrorCallBodySchema( missing=colander.drop, description="Additional details to explain failure reason of operation call or raised error." )
[docs] fallback = ErrorFallbackBodySchema( missing=colander.drop, description="Additional details to explain failure reason of fallback operation to cleanup call error." )
[docs] class InternalServerErrorResponseBodySchema(ErrorResponseBodySchema): def __init__(self, **kw): # type: (Any) -> None kw["code"] = HTTPInternalServerError.code super(InternalServerErrorResponseBodySchema, self).__init__(**kw)
[docs] class BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Required value for request is missing."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class UnauthorizedResponseBodySchema(ErrorResponseBodySchema): def __init__(self, **kw): # type: (Any) -> None kw["code"] = HTTPUnauthorized.code super(UnauthorizedResponseBodySchema, self).__init__(**kw)
[docs] route_name = colander.SchemaNode(colander.String(), description="Specified API route.")
[docs] request_url = colander.SchemaNode(colander.String(), description="Specified request URL.", validator=colander.url)
[docs] class UnauthorizedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Unauthorized access to this resource. Missing authentication headers or cookies."
[docs] body = UnauthorizedResponseBodySchema(code=HTTPUnauthorized.code, description=description)
[docs] class HTTPForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Forbidden operation for this resource or insufficient user privileges."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "The route resource could not be found."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class MethodNotAllowedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "The method is not allowed for this resource."
[docs] body = ErrorResponseBodySchema(code=HTTPMethodNotAllowed.code, description=description)
[docs] class NotAcceptableResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Unsupported Content-Type in 'Accept' header was specified."
[docs] body = ErrorResponseBodySchema(code=HTTPNotAcceptable.code, description=description)
[docs] class UnprocessableEntityResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid value specified."
[docs] body = ErrorResponseBodySchema(code=HTTPUnprocessableEntity.code, description=description)
[docs] class InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Internal Server Error. Unhandled exception occurred."
[docs] body = ErrorResponseBodySchema(code=HTTPInternalServerError.code, description=description)
[docs] class ProvidersListSchema(colander.SequenceSchema):
[docs] provider_name = colander.SchemaNode( colander.String(), description="Available login providers.", example="openid", )
[docs] class ResourceTypesListSchema(colander.SequenceSchema):
[docs] resource_type = colander.SchemaNode( colander.String(), description="Available resource type under root service.", example="file", )
[docs] class ChildrenResourceTypesListSchema(colander.SequenceSchema):
[docs] resource_type = colander.SchemaNode( colander.String(), description="Available children resource types under a resource within a service hierarchy.", example="file", )
[docs] class GroupNamesListSchema(colander.SequenceSchema):
[docs] group_name = GroupNameParameter
[docs] class UserNamesListSchema(colander.SequenceSchema):
[docs] user_name = UserNameParameter
[docs] class Permission_Check_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid permission format. Must be a permission string name or detailed JSON object."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class PermissionObjectSchema(colander.MappingSchema):
[docs] name = colander.SchemaNode( colander.String(), description="Permission name applicable to the service/resource.", example=Permission.READ.value )
[docs] access = colander.SchemaNode( colander.String(), description="Permission access rule to the service/resource.", default=Access.ALLOW.value, example=Access.ALLOW.value, )
[docs] scope = colander.SchemaNode( colander.String(), description="Permission scope over service/resource tree hierarchy.", default=Scope.RECURSIVE.value, example=Scope.RECURSIVE.value, )
[docs] class PermissionObjectTypeSchema(PermissionObjectSchema):
[docs] type = colander.SchemaNode( colander.String(), description="Permission type being displayed.", example=PermissionType.ALLOWED.value, )
[docs] reason = colander.SchemaNode( colander.String(), description="Description of user or group where this permission originated from.", example="user:123:my-user", missing=colander.drop, )
[docs] class PermissionObjectListSchema(colander.SequenceSchema):
[docs] permission = PermissionObjectTypeSchema()
[docs] class PermissionNameListSchema(colander.SequenceSchema):
[docs] permission_name = colander.SchemaNode( colander.String(), description="Permissions applicable to the service/resource", example=Permission.READ.value )
[docs] class PermissionPatchObjectSchema(colander.MappingSchema):
[docs] resource_name = colander.SchemaNode( colander.String(), description="Name of the resource associated with the permission. This resource will be created if missing." )
[docs] resource_type = colander.SchemaNode( colander.String(), description="Type of the resource. The first resource must be of the `service` type, and children " "resources must have a relevant resource type that is not of the `service` type.", example="service" )
[docs] user = colander.SchemaNode( colander.String(), description="Registered local user associated with the permission.", example="toto", missing=colander.drop )
[docs] group = colander.SchemaNode( colander.String(), description="Registered user group associated with the permission.", example="users", missing=colander.drop )
# FIXME: support oneOf(string, object), permission can actually be either a string or a PermissionObjectSchema(dict) # Currently not possible to have multiple type options with colander.
[docs] permission = PermissionObjectSchema( missing=colander.drop )
[docs] action = colander.SchemaNode( colander.String(), description="Action to apply on the permission.", example="create", default="create", validator=colander.OneOf(["create", "remove"]) )
[docs] class PermissionPatchListSchema(colander.SequenceSchema):
[docs] permission = PermissionPatchObjectSchema()
[docs] class Permissions_PATCH_RequestBodySchema(colander.MappingSchema):
[docs] permissions = PermissionPatchListSchema()
[docs] class Permissions_PATCH_RequestSchema(BaseRequestSchemaAPI):
[docs] body = Permissions_PATCH_RequestBodySchema()
[docs] class Permissions_PATCH_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update permissions successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Permissions_PATCH_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Missing or invalid parameters for permissions update."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Permissions_PATCH_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to update requested permissions."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class BaseUserInfoSchema(colander.MappingSchema):
[docs] user_name = UserNameParameter
[docs] email = colander.SchemaNode( colander.String(), description="Email of the user.", example="toto@mail.com", validator=colander.Email() )
[docs] status = colander.SchemaNode( colander.String(), description="Current status of the user account.", example=UserStatuses.OK.name, validator=colander.OneOf(UserStatuses.names()) )
[docs] class PendingUserInfoSchema(BaseUserInfoSchema): # any of those urls can be null if already processed, expired, or not applicable as per configuration
[docs] confirm_url = colander.SchemaNode( colander.String(), validator=colander.url, default=None, description="Temporary URL endpoint to call in order to confirm the email of the pending registration." )
[docs] approve_url = colander.SchemaNode( colander.String(), validator=colander.url, default=None, description="Temporary URL endpoint to call in order to approve the pending registration if applicable." )
[docs] decline_url = colander.SchemaNode( colander.String(), validator=colander.url, default=None, description="Temporary URL endpoint to call in order to decline the pending registration if applicable." )
[docs] class RegisteredUserInfoSchema(BaseUserInfoSchema):
[docs] user_id = colander.SchemaNode( colander.Integer(), missing=colander.drop, # if not registered or anonymous description="Registered user identifier. " "User entries that do not correspond to a registered account will not have this field." )
[docs] class UserBodySchema(RegisteredUserInfoSchema):
[docs] group_names = GroupNamesListSchema( example=["administrators", "users"] )
[docs] has_pending_group = colander.SchemaNode( colander.Bool(), description="Indicates if the user has any pending group requiring terms and conditions validation.", example=False )
[docs] class UserDetailListSchema(colander.SequenceSchema):
[docs] user = RegisteredUserInfoSchema()
[docs] class GroupBaseBodySchema(colander.MappingSchema):
[docs] group_name = colander.SchemaNode( colander.String(), description="Name of the group.", example="Administrators")
[docs] class GroupPublicBodySchema(GroupBaseBodySchema): # note: use an underscore to differentiate between the node and the parent 'description' metadata
[docs] description = "Publicly available group information."
[docs] _description = colander.SchemaNode( colander.String(), name="description", description="Description associated to the group.", example="", missing=colander.drop)
[docs] class GroupInfoBodySchema(GroupBaseBodySchema):
[docs] description = "Minimal information returned by administrative API routes."
[docs] group_id = colander.SchemaNode( colander.Integer(), description="ID of the group.", example=1)
[docs] class GroupDetailBodySchema(GroupPublicBodySchema, GroupInfoBodySchema):
[docs] description = "Detailed information of the group obtained by specifically requesting it."
[docs] terms = colander.SchemaNode( colander.String(), name="terms", description="Terms and conditions associated to the group.", example="", missing=colander.null)
[docs] member_count = colander.SchemaNode( colander.Integer(), description="Number of users member of the group.", example=2, missing=colander.drop)
[docs] user_names = UserNamesListSchema( example=["alice", "bob"], missing=colander.drop )
[docs] discoverable = colander.SchemaNode( colander.Boolean(), description="Indicates if this group is publicly accessible. " "Discoverable groups can be joined by any logged user.", example=True, default=False )
[docs] priority = colander.SchemaNode( colander.Integer(), description="Priority order of the group permission resolution, except administrators with enforced 'max'.", validator=colander.Range(min=-1, max=None), default=0, example=0 )
[docs] class ServiceConfigurationSchema(colander.MappingSchema):
[docs] description = ( "Custom configuration of the service. " "Expected format and fields specific to each service type. " "Service type must support custom configuration." )
[docs] missing = colander.drop
[docs] default = colander.null
[docs] class ServiceSummarySchema(colander.MappingSchema):
[docs] resource_id = colander.SchemaNode( colander.Integer(), description="Resource identification number", )
[docs] service_name = colander.SchemaNode( colander.String(), description="Name of the service", example="thredds" )
[docs] service_type = colander.SchemaNode( colander.String(), description="Type of the service", example="thredds" )
[docs] service_sync_type = colander.SchemaNode( colander.String(), description="Type of resource synchronization implementation.", example="thredds" )
[docs] service_configurable = colander.SchemaNode( colander.Boolean(), description="Indicates if the service supports custom configuration.", examble=False, )
[docs] public_url = colander.SchemaNode( colander.String(), description="Proxy URL available for public access with permissions", example="http://localhost/twitcher/ows/proxy/thredds", validator=colander.url, )
[docs] service_url = colander.SchemaNode( colander.String(), missing=colander.drop, # if listed with corresponding scope (users/groups/admin) description="Private URL of the service (restricted access)", example="http://localhost:9999/thredds", validator=colander.url, )
[docs] class ServiceBodySchema(ServiceSummarySchema):
[docs] permission_names = PermissionNameListSchema( description="List of service permissions applicable or effective for a given user/group according to context.", example=[Permission.READ.value, Permission.WRITE.value] )
[docs] permissions = PermissionObjectListSchema( description="List of detailed service permissions applicable or effective for user/group according to context." )
[docs] class ServiceDetailSchema(ServiceBodySchema):
[docs] configuration = ServiceConfigurationSchema()
[docs] class ResourceBodySchema(colander.MappingSchema):
[docs] resource_id = colander.SchemaNode( colander.Integer(), description="Resource identification number", )
[docs] resource_name = colander.SchemaNode( colander.String(), description="Name of the resource", example="thredds" )
[docs] resource_display_name = colander.SchemaNode( colander.String(), description="Display name of the resource", example="Birdhouse Thredds Data Server" )
[docs] resource_type = colander.SchemaNode( colander.String(), description="Type of the resource", example="service" )
[docs] parent_id = colander.SchemaNode( colander.Integer(), description="Parent resource identification number", default=colander.null, # if no parent missing=colander.drop # if not returned (basic_info = True) )
[docs] root_service_id = colander.SchemaNode( colander.Integer(), description="Resource tree root service identification number", default=colander.null, # if no parent missing=colander.drop # if not returned (basic_info = True) )
[docs] permission_names = PermissionNameListSchema( description="List of resource permissions applicable or effective for a given user/group according to context.", example=[Permission.READ.value, Permission.WRITE.value], default=colander.null, # if no parent missing=colander.drop # if not returned (basic_info = True) )
[docs] permissions = PermissionObjectListSchema( description="List of detailed resource permissions applicable or effective for user/group according to context." )
# FIXME: improve by making recursive resources work (?)
[docs] class Resource_ChildrenContainerWithoutChildResourceBodySchema(ResourceBodySchema):
[docs] children = colander.MappingSchema( default={}, description="Recursive '{}' schema for each applicable children resources.".format(ResourceBodySchema.__name__) )
[docs] class Resource_ChildResourceWithoutChildrenBodySchema(colander.MappingSchema):
[docs] id = Resource_ChildrenContainerWithoutChildResourceBodySchema(name="{resource_id}")
[docs] class Resource_ParentResourceWithChildrenContainerBodySchema(ResourceBodySchema):
[docs] children = Resource_ChildResourceWithoutChildrenBodySchema()
[docs] class Resource_ChildrenContainerWithChildResourceBodySchema(ResourceBodySchema):
[docs] children = Resource_ChildResourceWithoutChildrenBodySchema()
[docs] class Resource_ChildResourceWithChildrenContainerBodySchema(colander.MappingSchema):
[docs] id = Resource_ChildrenContainerWithChildResourceBodySchema(name="{resource_id}")
[docs] class Resource_ServiceWithChildrenResourcesContainerBodySchema(ServiceBodySchema):
[docs] resources = Resource_ChildResourceWithChildrenContainerBodySchema()
[docs] class Resource_ServiceType_geoserverapi_SchemaNode(colander.MappingSchema):
[docs] geoserver_api = Resource_ServiceWithChildrenResourcesContainerBodySchema(name="geoserver-api")
[docs] class Resource_ServiceType_ncwms_SchemaNode(colander.MappingSchema):
[docs] ncwms = Resource_ServiceWithChildrenResourcesContainerBodySchema()
[docs] class Resource_ServiceType_thredds_SchemaNode(colander.MappingSchema):
[docs] thredds = Resource_ServiceWithChildrenResourcesContainerBodySchema()
[docs] class ResourcesSchemaNode(colander.MappingSchema):
[docs] geoserver_api = Resource_ServiceType_geoserverapi_SchemaNode(name="geoserver-api")
[docs] ncwms = Resource_ServiceType_ncwms_SchemaNode()
[docs] thredds = Resource_ServiceType_thredds_SchemaNode()
[docs] class Resources_ResponseBodySchema(BaseResponseBodySchema):
[docs] resources = ResourcesSchemaNode()
[docs] class Resource_GET_RequestQuerySchema(QueryRequestSchemaAPI, QueryParentResources): pass
[docs] class Resource_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Resource_RequestPathSchema()
[docs] querystring = Resource_GET_RequestQuerySchema()
[docs] class Resource_MatchDictCheck_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Resource query by id refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Resource_MatchDictCheck_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Resource ID not found."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class Resource_MatchDictCheck_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Resource ID is an invalid literal for 'int' type."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Resource_GET_ResponseBodySchema(BaseResponseBodySchema): # FIXME: OneOf required for alternatives (keys "parents" instead of "children", list representation) # When using list, 'resources' is used since many are under the same array field.
[docs] resource = Resource_ParentResourceWithChildrenContainerBodySchema()
[docs] class Resource_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get resource successful."
[docs] body = Resource_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Resource_GET_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed building resource hierarchy into JSON formatted tree."
[docs] body = InternalServerErrorResponseBodySchema(code=HTTPInternalServerError.code, description=description)
[docs] class Resource_PATCH_RequestBodySchema(colander.MappingSchema):
[docs] resource_name = colander.SchemaNode( colander.String(), description="New name to apply to the resource to update", )
[docs] service_push = PhoenixServicePushOption()
[docs] class Resource_PATCH_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Resource_RequestPathSchema()
[docs] body = Resource_PATCH_RequestBodySchema()
[docs] class Resource_PATCH_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource_id = colander.SchemaNode( colander.String(), description="Updated resource identification number." )
[docs] resource_name = colander.SchemaNode( colander.String(), description="Updated resource name (from object)." )
[docs] old_resource_name = colander.SchemaNode( colander.String(), description="Resource name before update." )
[docs] new_resource_name = colander.SchemaNode( colander.String(), description="Resource name after update." )
[docs] class Resource_PATCH_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update resource successful."
[docs] body = Resource_PATCH_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Resource_PATCH_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Cannot update resource with provided new name."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Resource_PATCH_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to update resource with new name."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Resource_PATCH_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Resource name already exists at requested tree level for update."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class Resource_DELETE_RequestBodySchema(colander.MappingSchema):
[docs] service_push = PhoenixServicePushOption()
[docs] class Resource_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Resource_RequestPathSchema()
[docs] body = Resource_DELETE_RequestBodySchema()
[docs] class Resource_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete resource successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Resource_DELETE_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete resource from db failed."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Resources_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get resources successful."
[docs] body = Resources_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Resources_POST_RequestBodySchema(colander.MappingSchema):
[docs] resource_name = colander.SchemaNode( colander.String(), description="Name of the resource to create." )
[docs] resource_display_name = colander.SchemaNode( colander.String(), description="Display name of the resource to create, defaults to resource_name.", missing=colander.drop )
[docs] resource_type = colander.SchemaNode( colander.String(), description="Type of the resource to create." )
[docs] parent_id = colander.SchemaNode( colander.Int(), description="ID of parent resource under which the new resource should be created.", missing=colander.drop )
[docs] class Resources_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] body = Resources_POST_RequestBodySchema()
[docs] class Resource_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource = Resource_ChildResourceWithChildrenContainerBodySchema()
[docs] class Resources_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Create resource successful."
[docs] body = Resource_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs] class Resources_POST_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid ['resource_name'|'resource_type'|'parent_id'] specified for child resource creation."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Resources_POST_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to insert new resource in service tree using parent id."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Resources_POST_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Could not find specified resource parent id."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class Resources_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Resource name already exists at requested tree level for creation."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class ResourcePermissions_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Resource_RequestPathSchema()
[docs] class ResourcePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionNameListSchema( description="List of permissions applicable for the referenced resource.", example=[Permission.READ.value, Permission.WRITE.value] )
[docs] permissions = PermissionObjectListSchema( description="List of detailed permissions applicable for the referenced resource." )
[docs] class ResourcePermissions_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get resource permissions successful."
[docs] body = ResourcePermissions_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class ResourcePermissions_GET_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid resource type to extract permissions."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class ResourceTypes_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Resource_RequestPathSchema()
[docs] class ResourceTypes_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource_name = colander.SchemaNode( colander.String(), description="Name of the specified resource." )
[docs] resource_type = colander.SchemaNode( colander.String(), description="Type of the specified resource." )
[docs] children_resource_types = ChildrenResourceTypesListSchema( description="All resource types applicable as children under the specified resource. " )
[docs] children_resource_allowed = colander.SchemaNode( colander.Boolean(), description="Indicates if the resource allows any children resources." )
[docs] root_service_id = colander.SchemaNode( colander.Integer(), description="Resource tree root service identification number.", default=colander.null, # if no parent missing=colander.drop # if not returned (basic_info = True) )
[docs] root_service_name = colander.SchemaNode( colander.Integer(), description="Resource tree root service name.", default=colander.null, # if no parent missing=colander.drop # if not returned (basic_info = True) )
[docs] root_service_type = colander.SchemaNode( colander.Integer(), description="Resource tree root service type.", default=colander.null, # if no parent missing=colander.drop # if not returned (basic_info = True) )
[docs] class ResourceTypes_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get applicable children resource types under resource successful."
[docs] body = ResourceTypes_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class ServiceResourcesBodySchema(ServiceBodySchema):
[docs] children = ResourcesSchemaNode()
[docs] class ServiceType_access_SchemaNode(colander.MappingSchema):
[docs] title = "Services typed for Access"
[docs] description = "These services are all-or-nothing root endpoint access."
[docs] frontend = ServiceBodySchema(missing=colander.drop)
[docs] geoserver_web = ServiceBodySchema(missing=colander.drop, name="geoserver-web")
[docs] magpie = ServiceBodySchema(missing=colander.drop)
[docs] class ServiceType_geoserverapi_SchemaNode(colander.MappingSchema):
[docs] name = "geoserver-api"
[docs] title = "Services typed for GeoServer-API"
[docs] geoserver_api = ServiceBodySchema(missing=colander.drop, name="geoserver-api")
[docs] class ServiceType_geoserverwms_SchemaNode(colander.MappingSchema):
[docs] title = "Services typed for GeoServer-WMS"
[docs] geoserverwms = ServiceBodySchema(missing=colander.drop)
[docs] class ServiceType_ncwms_SchemaNode(colander.MappingSchema):
[docs] title = "Services typed for ncWMS2"
[docs] ncwms = ServiceBodySchema(missing=colander.drop, name="ncWMS2")
[docs] class ServiceType_projectapi_SchemaNode(colander.MappingSchema):
[docs] name = "project-api"
[docs] title = "Services typed for Project-API"
[docs] project_api = ServiceBodySchema(missing=colander.drop, name="project-api")
[docs] class ServiceType_thredds_SchemaNode(colander.MappingSchema):
[docs] title = "Services typed for Thredds"
[docs] thredds = ServiceBodySchema(missing=colander.drop)
[docs] class ServiceType_wfs_SchemaNode(colander.MappingSchema):
[docs] title = "Services typed for WFS"
[docs] geoserver = ServiceBodySchema(missing=colander.drop)
[docs] class ServiceType_wps_SchemaNode(colander.MappingSchema):
[docs] title = "Services typed for WPS"
[docs] lb_flyingpigeon = ServiceBodySchema(missing=colander.drop)
[docs] flyingpigeon = ServiceBodySchema(missing=colander.drop)
[docs] project = ServiceBodySchema(missing=colander.drop)
[docs] catalog = ServiceBodySchema(missing=colander.drop)
[docs] malleefowl = ServiceBodySchema(missing=colander.drop)
[docs] hummingbird = ServiceBodySchema(missing=colander.drop)
[docs] class ServiceTypesList(colander.SequenceSchema):
[docs] service_type = colander.SchemaNode( colander.String(), description="Available service type.", example="api", )
[docs] class ServiceListingQuerySchema(QueryRequestSchemaAPI, QueryFlattenServices): pass
[docs] class ServiceTypes_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] querystring = ServiceListingQuerySchema()
[docs] class ServiceTypes_GET_OkResponseBodySchema(BaseResponseBodySchema):
[docs] service_types = ServiceTypesList(description="List of available service types.")
[docs] class ServiceTypes_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get service types successful."
[docs] body = ServiceTypes_GET_OkResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class ServicesCategorizedSchemaNode(colander.MappingSchema):
[docs] description = "Registered services categorized by supported service-type. " + \ "Listed service-types depend on Magpie version."
[docs] access = ServiceType_access_SchemaNode()
[docs] geoserver_api = ServiceType_geoserverapi_SchemaNode(missing=colander.drop)
[docs] geoserverwms = ServiceType_geoserverwms_SchemaNode(missing=colander.drop)
[docs] ncwms = ServiceType_ncwms_SchemaNode()
[docs] project_api = ServiceType_projectapi_SchemaNode(missing=colander.drop)
[docs] thredds = ServiceType_thredds_SchemaNode()
[docs] wfs = ServiceType_wfs_SchemaNode(missing=colander.drop)
[docs] wps = ServiceType_wps_SchemaNode(missing=colander.drop)
[docs] class Service_SummaryBodyResponseSchema(BaseResponseBodySchema):
[docs] service = ServiceSummarySchema()
[docs] class Service_SuccessBodyResponseSchema(BaseResponseBodySchema):
[docs] service = ServiceBodySchema()
[docs] class Service_DetailBodyResponseSchema(BaseResponseBodySchema):
[docs] service = ServiceDetailSchema()
[docs] class ServicesListingSchemaNode(colander.SequenceSchema):
[docs] service = ServiceBodySchema()
[docs] class Service_MatchDictCheck_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Service query by name refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Service_MatchDictCheck_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Service name not found."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class Service_CheckConfig_UnprocessableEntityResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Service configuration must be formatted as JSON or null."
[docs] body = ErrorResponseBodySchema(code=HTTPUnprocessableEntity.code, description=description)
[docs] class ServicesQuerySchema(QueryRequestSchemaAPI, QueryFlattenServices, QueryFilterServiceType): pass
[docs] class Services_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] querystring = ServicesQuerySchema()
[docs] class Service_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Service_RequestPathSchema()
[docs] class Service_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] service = ServiceDetailSchema()
[docs] class Service_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get service successful."
[docs] body = Service_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Services_GET_ResponseBodySchema(BaseResponseBodySchema): # FIXME: add support schema OneOf(ServicesCategorizedSchemaNode, ServicesListingSchemaNode) # requires https://github.com/fmigneault/cornice.ext.swagger/tree/oneOf-objects
[docs] services = ServicesCategorizedSchemaNode()
[docs] class Services_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get services successful."
[docs] body = Services_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Services_GET_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'service_type' value does not correspond to any of the existing service types."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Services_POST_BodySchema(colander.MappingSchema):
[docs] service_name = colander.SchemaNode( colander.String(), description="Name of the service to create", example="my_service" )
[docs] service_type = colander.SchemaNode( colander.String(), description="Type of the service to create", example="wps" )
[docs] service_sync_type = colander.SchemaNode( colander.String(), description="Type of the service to create", example="wps" )
[docs] service_url = colander.SchemaNode( colander.String(), description="Private URL of the service to create", example="http://localhost:9000/my_service", validator=colander.url, )
[docs] configuration = ServiceConfigurationSchema()
[docs] class Services_POST_RequestBodySchema(BaseRequestSchemaAPI):
[docs] body = Services_POST_BodySchema()
[docs] class Services_POST_CreatedResponseBodySchema(BaseResponseBodySchema):
[docs] service = ServiceDetailSchema()
[docs] class Services_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Service registration to db successful."
[docs] body = Services_POST_CreatedResponseBodySchema(code=HTTPCreated.code, description=description)
[docs] class Services_POST_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'service_type' value does not correspond to any of the existing service types."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Services_POST_Params_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid parameter value for service creation."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Services_POST_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Service registration forbidden by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Services_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Specified 'service_name' value already exists."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class Services_POST_UnprocessableEntityResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Service creation for registration failed."
[docs] body = ErrorResponseBodySchema(code=HTTPUnprocessableEntity.code, description=description)
[docs] class Services_POST_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Service registration status could not be validated."
[docs] body = ErrorResponseBodySchema(code=HTTPInternalServerError.code, description=description)
[docs] class Service_PATCH_RequestBodySchema(colander.MappingSchema):
[docs] description = ( "New parameters to apply for service update. Any combination of new values can be provided. " "At least one field must be provided with a different value than the current service parameters." )
[docs] service_name = colander.SchemaNode( colander.String(), description="New service name to apply to service specified in path", missing=colander.drop, default=colander.null, example="my_service_new_name" )
[docs] service_url = colander.SchemaNode( colander.String(), description="New service private URL to apply to service specified in path", missing=colander.drop, default=colander.null, example="http://localhost:9000/new_service_name", validator=colander.url, )
[docs] service_push = PhoenixServicePushOption()
[docs] configuration = ServiceConfigurationSchema( description="New service configuration to be applied. " "Must be a valid JSON object definition different than the currently active configuration. " "If explicitly provided with null value, instead erase the current service configuration." )
[docs] class Service_PATCH_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Service_RequestPathSchema()
[docs] body = Service_PATCH_RequestBodySchema()
[docs] class Service_PATCH_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update service successful."
[docs] body = Service_DetailBodyResponseSchema(code=HTTPOk.code, description=description)
[docs] class Service_PATCH_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Registered service values are already equal to update values."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Service_PATCH_ForbiddenResponseSchema_ReservedKeyword(BaseResponseSchemaAPI):
[docs] description = "Update service name to 'types' not allowed (reserved keyword)."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Service_PATCH_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update service failed during value assignment."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Service_PATCH_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Specified 'service_name' already exists."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class Service_PATCH_UnprocessableEntityResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Specified value is in incorrectly or unsupported format."
[docs] body = ErrorResponseBodySchema(code=HTTPUnprocessableEntity.code, description=description)
[docs] Service_DELETE_RequestBodySchema = Resource_DELETE_RequestBodySchema
[docs] class Service_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Service_RequestPathSchema()
[docs] body = Service_DELETE_RequestBodySchema()
[docs] class Service_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete service successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Service_DELETE_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete service from db refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class ServicePermissions_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionNameListSchema( description="List of permissions applicable to the service.", example=[Permission.READ.value, Permission.WRITE.value] )
[docs] permissions = PermissionObjectListSchema( description="List of detailed permissions applicable to the service." )
[docs] class ServicePermissions_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get service permissions successful."
[docs] path = Service_RequestPathSchema()
[docs] body = ServicePermissions_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class ServicePermissions_GET_BadRequestResponseBodySchema(ErrorResponseBodySchema):
[docs] service = ServiceBodySchema()
[docs] class ServicePermissions_GET_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid service type specified by service."
[docs] body = ServicePermissions_GET_BadRequestResponseBodySchema(code=HTTPBadRequest.code, description=description)
# create service's resource use same method as direct resource create
[docs] class ServiceResources_POST_RequestSchema(Resources_POST_RequestSchema):
[docs] path = Service_RequestPathSchema()
[docs] ServiceResources_POST_CreatedResponseSchema = Resources_POST_CreatedResponseSchema
[docs] ServiceResources_POST_NotFoundResponseSchema = Resources_POST_NotFoundResponseSchema
[docs] ServiceResources_POST_ConflictResponseSchema = Resources_POST_ConflictResponseSchema
[docs] class ServiceResources_POST_ForbiddenResponseSchema(Resources_POST_ForbiddenResponseSchema):
[docs] description = "Invalid 'parent_id' specified for child resource creation under requested service."
[docs] class ServiceResources_POST_UnprocessableEntityResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Provided 'parent_id' value is invalid."
[docs] body = ErrorResponseBodySchema(code=HTTPUnprocessableEntity.code, description=description)
[docs] class ServiceResource_GET_RequestSchema(Resource_GET_RequestSchema):
[docs] service_name = ServiceNameParameter
# delete service's resource use same method as direct resource delete
[docs] class ServiceResource_DELETE_RequestSchema(Resource_DELETE_RequestSchema):
[docs] service_name = ServiceNameParameter
[docs] ServiceResource_DELETE_ForbiddenResponseSchema = Resource_DELETE_ForbiddenResponseSchema
[docs] ServiceResource_DELETE_OkResponseSchema = Resource_DELETE_OkResponseSchema
[docs] class ServiceResources_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Service_RequestPathSchema()
[docs] class ServiceResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] service_name = Resource_ServiceWithChildrenResourcesContainerBodySchema(name="{service_name}")
[docs] class ServiceResources_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get service resources successful."
[docs] body = ServiceResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class ServiceTypeResources_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = ServiceType_RequestPathSchema()
[docs] class ResourceTypesAllowed(colander.SequenceSchema):
[docs] description = "List of all allowed resource types at some level within the service hierarchy."
[docs] res_type_path = colander.SchemaNode( colander.String(), description="Allowed resource type under the service hierarchy." )
[docs] class ResourceTypeChildrenAllowed(colander.SequenceSchema):
[docs] title = "ResourceTypeChildrenAllowed"
[docs] res_type = colander.SchemaNode( colander.String(), description="Allowed child resource type." )
[docs] class ResourceStructuresAllowed(colander.MappingSchema):
[docs] description = ( "Mapping of allowed combinations of nested resource type structures under the service. " "If undefined, the service does not impose any specific resource type hierarchy other " "than whether individual resource types themselves allow children resources." )
[docs] unknown = "preserve"
[docs] res_type = ResourceTypeChildrenAllowed( name="{resource_type}", description="List of children resource types in structure allowed under the parent resource type." )
[docs] class ServiceTypeResourceInfo(colander.MappingSchema):
[docs] resource_type = colander.SchemaNode( colander.String(), description="Resource type." )
[docs] resource_child_allowed = colander.SchemaNode( colander.Boolean(), description="Indicates if the service allows any child resources." )
[docs] resource_types_allowed = ResourceTypesAllowed()
[docs] resource_structure_allowed = ResourceStructuresAllowed()
[docs] permission_names = PermissionNameListSchema( description="Permissions applicable to the specific resource type.", example=[Permission.READ.value, Permission.WRITE.value] )
[docs] permissions = PermissionObjectListSchema( description="List of detailed permissions applicable to the specific resource type." )
[docs] class ServiceTypeResourcesList(colander.SequenceSchema):
[docs] resource_type = ServiceTypeResourceInfo(description="Resource type detail for specific service type.")
[docs] class ServiceTypeResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource_types = ServiceTypeResourcesList(description="Supported resources types under specific service type.")
[docs] class ServiceTypeResources_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get service type resources successful."
[docs] body = ServiceTypeResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class ServiceTypeResources_GET_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to obtain resource types for specified service type."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class ServiceTypeResources_GET_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'service_type' does not exist to obtain its resource types."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class ServiceTypeResourceTypes_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = ServiceType_RequestPathSchema()
[docs] class ServiceTypeResourceTypes_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource_types = ResourceTypesListSchema()
[docs] class ServiceTypeResourceTypes_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get service type resource types successful."
[docs] body = ServiceTypeResourceTypes_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class ServiceTypeResourceTypes_GET_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to obtain resource types for specified service type."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class ServiceTypeResourceTypes_GET_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'service_type' does not exist to obtain its resource types."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class UsersQuery(QueryRequestSchemaAPI):
[docs] status = colander.SchemaNode( colander.Integer(), missing=colander.drop, description="Obtain the user name list filtered by their account status. " "Can be any combination of comma-separated list of known status values. " "Returns all *registered* users if not provided. " "Otherwise, 'all' can return every user regardless of registration status.", validator=colander.OneOf(UserStatuses.allowed()) )
[docs] detail = colander.SchemaNode( colander.Boolean(), default=False, desiption="Request that more user details be returned in the response. " "Each item in the list will be a user detail JSON object instead of the list of string names. " "Only user names are returned by default for backward compatibility." )
[docs] class Users_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] querystring = UsersQuery()
[docs] class Users_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] user_names = UserNamesListSchema(missing=colander.drop, description="User names when no detail is requested.")
[docs] users = UserDetailListSchema(missing=colander.drop, description="List of user details when it is requested.")
[docs] class Users_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get users successful."
[docs] body = Users_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Users_GET_BadRequestSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid search parameter provided."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Users_GET_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get users query refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Users_CheckInfo_UserNameValue_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'user_name' value specified."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Users_CheckInfo_UserNameValueExtraRegex_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'user_name' value specified. Does not match the extra user name regex."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Users_CheckInfo_UserNameSize_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'user_name' length specified (>{length} characters)." \ .format(length=get_constant("MAGPIE_USER_NAME_MAX_LENGTH"))
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Users_CheckInfo_Email_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'email' value specified."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Users_CheckInfo_PasswordValue_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'password' value specified."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Users_CheckInfo_PasswordSize_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'password' length specified (<{length} characters)." \ .format(length=get_constant("MAGPIE_PASSWORD_MIN_LENGTH"))
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Users_CheckInfo_GroupName_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'group_name' value specified."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Users_CheckInfo_ReservedKeyword_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'user_name' not allowed (reserved keyword)."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
# alias for readability across code, but we actually do the same check
[docs] User_Check_BadRequestResponseSchema = Users_CheckInfo_UserNameValue_BadRequestResponseSchema
[docs] class User_Check_Status_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'status' value specified."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class User_Check_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User check query was refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class User_Check_Name_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User name matches an already existing user name."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class User_Check_Email_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User email matches an already existing user email."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class User_POST_RequestBodySchema(colander.MappingSchema):
[docs] user_name = colander.SchemaNode( colander.String(), description="New name to apply to the user", example="john", )
[docs] email = colander.SchemaNode( colander.String(), description="New email to apply to the user", example="john@mail.com", validator=colander.Email(), )
[docs] password = colander.SchemaNode( colander.String(), description="New password to apply to the user", example="itzaseekit", )
[docs] group_name = colander.SchemaNode( colander.String(), description="New password to apply to the user", example="users", )
[docs] class Users_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] body = User_POST_RequestBodySchema()
[docs] class Users_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] user = UserBodySchema()
[docs] class Users_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Add user to db successful."
[docs] body = Users_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs] class Users_POST_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to add user to db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class UserNew_POST_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "New user query was refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class User_PATCH_RequestBodySchema(colander.MappingSchema):
[docs] user_name = colander.SchemaNode( colander.String(), description="New name to apply to the user (admin-only operation).", missing=colander.drop, example="john", )
[docs] email = colander.SchemaNode( colander.String(), description="New email to apply to the user (admin or logged user operation).", missing=colander.drop, example="john@mail.com", validator=colander.Email(), )
[docs] password = colander.SchemaNode( colander.String(), description="New password to apply to the user (admin or logged user operation).", missing=colander.drop, example="itzaseekit", )
[docs] status = colander.SchemaNode( colander.Integer(), missing=colander.drop, description="New status to apply to the user (admin-only operation).", validator=colander.OneOf(UserStatuses.values()) )
[docs] class User_PATCH_RequestSchema(BaseRequestSchemaAPI):
[docs] path = User_RequestPathSchema()
[docs] body = User_PATCH_RequestBodySchema()
[docs] class Users_PATCH_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update user successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class User_PATCH_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Missing parameters to update user or parameters do not provide any modification."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class User_PATCH_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Targeted user update not allowed by requesting user."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class User_PATCH_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "New name user already exists."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class User_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = User_RequestPathSchema()
[docs] class User_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] user = UserBodySchema()
[docs] class User_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get user successful."
[docs] body = User_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class User_CheckAnonymous_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Anonymous user refused for this operation."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class User_CheckAnonymous_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Anonymous user not found."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class User_GET_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User access forbidden for this resource."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class User_GET_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User name query refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPInternalServerError.code, description=description)
[docs] class User_GET_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User name not found."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class User_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = User_RequestPathSchema()
[docs] body = colander.MappingSchema(default={})
[docs] class User_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete user successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class User_DELETE_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User could not be deleted."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class UserGroup_Check_Status_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'status' value specified."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class UserGroupsQuery(QueryRequestSchemaAPI):
[docs] status = colander.SchemaNode( colander.String(), default=UserGroupStatus.ACTIVE.value, missing=colander.drop, description="Obtain the user-groups filtered by statuses [all, active, pending]. " "Returns active user-groups if not provided. ", validator=colander.OneOf(UserGroupStatus.allowed()) )
[docs] class UserGroups_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = User_RequestPathSchema()
[docs] querystring = UserGroupsQuery()
[docs] class UserGroups_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] group_names = GroupNamesListSchema()
[docs] class UserGroups_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get user groups successful."
[docs] body = UserGroups_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class UserGroups_POST_RequestBodySchema(colander.MappingSchema):
[docs] group_name = colander.SchemaNode( colander.String(), description="Name of the group in the user-group relationship", example="users", )
[docs] class UserGroups_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] path = User_RequestPathSchema()
[docs] body = UserGroups_POST_RequestBodySchema()
[docs] class UserGroups_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] user_name = colander.SchemaNode( colander.String(), description="Name of the user in the user-group relationship", example="toto", )
[docs] group_name = colander.SchemaNode( colander.String(), description="Name of the group in the user-group relationship", example="users", )
[docs] class UserGroups_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Create user-group assignation successful. User is a member of the group."
[docs] body = UserGroups_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs] class UserGroups_POST_AcceptedResponseSchema(BaseResponseSchemaAPI):
[docs] description = ( "Accepted request to add user to the group. Group requires accepting terms and conditions. " "Pending confirmation by the user." )
[docs] body = UserGroups_POST_ResponseBodySchema(code=HTTPAccepted.code, description=description)
[docs] class UserGroups_POST_GroupNotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Cannot find the group to assign to."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class UserGroups_POST_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group query by name refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class UserGroups_POST_RelationshipForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User-Group relationship creation refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class UserGroups_POST_ConflictResponseBodySchema(ErrorResponseBodySchema):
[docs] param = ErrorVerifyParamBodySchema()
[docs] user_name = colander.SchemaNode( colander.String(), description="Name of the user in the user-group relationship", example="toto", )
[docs] group_name = colander.SchemaNode( colander.String(), description="Name of the group in the user-group relationship", example="users", )
[docs] class UserGroups_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User already belongs to this group."
[docs] body = UserGroups_POST_ConflictResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class UserGroup_Check_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid group name to associate to user."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class UserGroup_GET_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group query was refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class UserGroup_Check_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group for new user doesn't exist."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class UserGroup_Check_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to add user-group to db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class UserGroup_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] body = colander.MappingSchema(default={})
[docs] class UserGroup_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete user-group successful. User is not a member of the group anymore."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class UserGroup_DELETE_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete user-group relationship not permitted for this combination."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class UserGroup_DELETE_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Could not remove user from group. Could not find any matching group membership for user."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class UserResources_GET_QuerySchema( QueryRequestSchemaAPI, QueryInheritGroupsPermissions, QueryResolvedUserGroupsPermissions, QueryFilterResources, QueryFilterServiceType ): pass
[docs] class UserResources_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = User_RequestPathSchema()
[docs] querystring = UserResources_GET_QuerySchema()
[docs] class UserResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] resources = ResourcesSchemaNode()
[docs] class UserResources_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get user resources successful."
[docs] body = UserResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class UserResources_GET_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to populate user resources."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class UserResourcePermissions_Check_ParamResponseBodySchema(colander.MappingSchema):
[docs] name = colander.SchemaNode(colander.String(), description="Specified parameter.", example="permission_name")
[docs] value = colander.SchemaNode(colander.String(), description="Specified parameter value.")
[docs] class UserResourcePermissions_Check_ErrorResponseBodySchema(ErrorResponseBodySchema):
[docs] user_name = colander.SchemaNode(colander.String(), description="Specified user name.")
[docs] resource_id = colander.SchemaNode(colander.String(), description="Specified service/resource id.")
[docs] permission_name = colander.SchemaNode(colander.String(), description="Specified permission name.")
[docs] permission = PermissionObjectTypeSchema(description="Specific permission extended definition.")
[docs] param = UserResourcePermissions_Check_ParamResponseBodySchema(missing=colander.drop)
[docs] class UserResourcePermissions_Check_ErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Lookup of similar permission on service/resource for user refused by db."
[docs] body = UserResourcePermissions_Check_ErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description )
[docs] class UserResourcePermissions_GET_QuerySchema( QueryRequestSchemaAPI, QueryInheritGroupsPermissions, QueryResolvedUserGroupsPermissions, QueryEffectivePermissions ): pass
[docs] class UserResourcePermissions_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = UserResource_RequestPathSchema()
[docs] querystring = UserResourcePermissions_GET_QuerySchema()
[docs] class UserResourcePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionNameListSchema( description="List of resource permissions applied or effective for the referenced user.", example=[Permission.READ.value, Permission.WRITE.value] )
[docs] permissions = PermissionObjectListSchema( description="List of detailed resource permissions applied or effective to the referenced user." )
[docs] class UserResourcePermissions_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get user resource permissions successful."
[docs] body = UserResourcePermissions_GET_ResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class UserResourcePermissions_GET_BadRequestParamResponseSchema(colander.MappingSchema):
[docs] name = colander.SchemaNode(colander.String(), description="name of the parameter tested", example="resource_type")
[docs] value = colander.SchemaNode(colander.String(), description="value of the parameter tested")
[docs] compare = colander.SchemaNode(colander.String(), description="comparison value of the parameter tested", missing=colander.drop)
[docs] class UserResourcePermissions_GET_BadRequestResponseBodySchema(colander.MappingSchema):
[docs] param = UserResourcePermissions_GET_BadRequestParamResponseSchema()
[docs] class UserResourcePermissions_GET_BadRequestRootServiceResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'resource' specified for resource permission retrieval."
[docs] body = UserResourcePermissions_GET_BadRequestResponseBodySchema( code=HTTPBadRequest.code, description=description)
[docs] class UserResourcePermissions_GET_BadRequestResourceResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'resource' specified for resource permission retrieval."
[docs] body = UserResourcePermissions_GET_BadRequestResponseBodySchema( code=HTTPBadRequest.code, description=description)
[docs] class UserResourcePermissions_GET_BadRequestResourceTypeResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'resource_type' for corresponding service resource permission retrieval."
[docs] body = UserResourcePermissions_GET_BadRequestResponseBodySchema( code=HTTPBadRequest.code, description=description)
[docs] class UserResourcePermissions_GET_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Specified user or resource not found to obtain permissions."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class UserResourcePermissions_POST_RequestBodySchema(colander.MappingSchema):
[docs] permission_name = colander.SchemaNode( colander.String(), description="Permission name (implicit or explicit) to create on the resource for the user.", missing=colander.drop )
[docs] permission = PermissionObjectSchema( description="Detailed permission definition to create on the resource for the user.", missing=colander.drop )
[docs] class UserResourcePermissions_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] path = UserResource_RequestPathSchema()
[docs] body = UserResourcePermissions_POST_RequestBodySchema()
[docs] UserResourcePermissions_PUT_RequestSchema = UserResourcePermissions_POST_RequestSchema
[docs] class UserResourcePermissions_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource_id = colander.SchemaNode( colander.Integer(), description="Resource for which to create the user permission." )
[docs] user_id = colander.SchemaNode( colander.Integer(), description="User for which to create the permission on the resource." )
[docs] permission_name = colander.SchemaNode( colander.String(), description="Permission name (implicit or explicit) to create on the resource for the user.", missing=colander.drop )
[docs] permission = PermissionObjectSchema( description="Detailed permission definition to create on the resource for the user.", missing=colander.drop )
[docs] class UserResourcePermissions_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Create user resource permission successful."
[docs] body = UserResourcePermissions_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs] class UserResourcePermissions_POST_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Permission not allowed for specified 'resource_type'."
[docs] body = UserResourcePermissions_Check_ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class UserResourcePermissions_POST_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Creation of permission on resource for user refused by db."
[docs] body = UserResourcePermissions_Check_ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class UserResourcePermissions_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Similar permission already exist on resource for user."
[docs] body = UserResourcePermissions_Check_ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class UserResourcePermissions_PUT_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update user resource permission successful."
[docs] body = UserResourcePermissions_POST_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] UserResourcePermissions_PUT_CreatedResponseSchema = UserResourcePermissions_POST_CreatedResponseSchema
[docs] UserResourcePermissions_PUT_BadRequestResponseSchema = UserResourcePermissions_POST_BadRequestResponseSchema
[docs] UserResourcePermissions_PUT_ForbiddenResponseSchema = UserResourcePermissions_POST_ForbiddenResponseSchema
# using same definitions
[docs] UserResourcePermissionName_DELETE_ErrorResponseBodySchema = UserResourcePermissions_Check_ErrorResponseBodySchema
[docs] UserResourcePermissionName_DELETE_BadRequestResponseSchema = UserResourcePermissions_POST_BadRequestResponseSchema
[docs] class UserResourcePermissionName_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = UserResourcePermission_RequestPathSchema()
[docs] body = colander.MappingSchema(default={})
[docs] class UserResourcePermissionName_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete user resource permission successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class UserResourcePermissionName_DELETE_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Could not find user resource permission to delete from db."
[docs] body = UserResourcePermissionName_DELETE_ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class UserResourcePermissions_DELETE_RequestBodySchema(colander.MappingSchema):
[docs] permission = PermissionObjectSchema(description="Permission to be deleted.")
[docs] class UserResourcePermissions_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = UserResource_RequestPathSchema()
[docs] body = UserResourcePermissions_DELETE_RequestBodySchema()
[docs] UserResourcePermissions_DELETE_OkResponseSchema = UserResourcePermissionName_DELETE_OkResponseSchema
[docs] UserResourcePermissions_DELETE_BadRequestResponseSchema = UserResourcePermissionName_DELETE_BadRequestResponseSchema
[docs] UserResourcePermissions_DELETE_NotFoundResponseSchema = UserResourcePermissionName_DELETE_NotFoundResponseSchema
[docs] class UserServiceResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] service = ServiceResourcesBodySchema()
[docs] class UserServiceResources_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get user service resources successful."
[docs] body = UserServiceResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class UserServiceResources_GET_QuerySchema( QueryRequestSchemaAPI, QueryInheritGroupsPermissions, QueryResolvedUserGroupsPermissions ): pass
[docs] class UserServiceResources_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = UserService_RequestPathSchema()
[docs] querystring = UserServiceResources_GET_QuerySchema()
[docs] class UserServicePermissions_POST_RequestBodySchema(colander.MappingSchema):
[docs] permission_name = colander.SchemaNode( colander.String(), description="Permission name (implicit or explicit) to create on the service for the user.", missing=colander.drop )
[docs] permission = PermissionObjectSchema( description="Detailed permission definition to create on the service for the user.", missing=colander.drop )
[docs] class UserServicePermissions_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] path = UserService_RequestPathSchema()
[docs] body = UserServicePermissions_POST_RequestBodySchema()
[docs] UserServicePermissions_PUT_RequestSchema = UserServicePermissions_POST_RequestSchema
[docs] class UserServicePermissions_DELETE_RequestBodySchema(colander.MappingSchema):
[docs] permission = PermissionObjectSchema(description="Permission to be deleted.")
[docs] class UserServicePermissions_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = UserService_RequestPathSchema()
[docs] body = UserResourcePermissions_DELETE_RequestBodySchema()
[docs] class UserServicePermissionName_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = UserServicePermission_RequestPathSchema()
[docs] body = colander.MappingSchema(default={})
[docs] class UserServices_GET_QuerySchema( QueryRequestSchemaAPI, QueryCascadeResourcesPermissions, QueryInheritGroupsPermissions, QueryFlattenServices, QueryFilterServiceType ): pass
[docs] class UserServices_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = User_RequestPathSchema()
[docs] querystring = UserServices_GET_QuerySchema()
[docs] class UserServices_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] services = ServicesCategorizedSchemaNode()
[docs] class UserServices_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get user services successful."
[docs] body = UserServices_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class UserServicePermissions_GET_QuerySchema( QueryRequestSchemaAPI, QueryInheritGroupsPermissions, QueryResolvedUserGroupsPermissions ): pass
[docs] class UserServicePermissions_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = UserService_RequestPathSchema()
[docs] querystring = UserServicePermissions_GET_QuerySchema()
[docs] class UserServicePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionNameListSchema( description="List of service permissions applied or effective for the referenced user.", example=[Permission.READ.value, Permission.WRITE.value] )
[docs] permissions = PermissionObjectListSchema( description="List of detailed service permissions applied or effective to the referenced user." )
[docs] class UserServicePermissions_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get user service permissions successful."
[docs] body = UserServicePermissions_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class UserServicePermissions_GET_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Could not find permissions using specified 'service_name' and 'user_name'."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class Group_MatchDictCheck_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group query by name refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Group_MatchDictCheck_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group name not found."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class Groups_CheckInfo_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User name not found."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class Groups_CheckInfo_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to obtain groups of user."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Groups_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] group_names = GroupNamesListSchema()
[docs] class Groups_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get groups successful."
[docs] body = Groups_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Groups_GET_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Obtain group names refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Groups_POST_RequestBodySchema(colander.MappingSchema):
[docs] group_name = colander.SchemaNode(colander.String(), description="Name of the group to create.")
[docs] description = colander.SchemaNode(colander.String(), default="", description="Description to apply to the group to create.")
[docs] discoverable = colander.SchemaNode(colander.Boolean(), default=False, description="Discoverability status of the group to create.")
[docs] terms = colander.SchemaNode(colander.String(), default="", description="Terms and conditions of the group to create.")
[docs] class Groups_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] body = Groups_POST_RequestBodySchema()
[docs] class Groups_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] group = GroupInfoBodySchema()
[docs] class Groups_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Create group successful."
[docs] body = Groups_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs] class Groups_POST_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid parameter for group creation."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Groups_POST_ForbiddenCreateResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Create new group by name refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Groups_POST_ForbiddenAddResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Add new group by name refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Groups_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group name matches an already existing group name."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class Group_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Group_RequestPathSchema()
[docs] class Group_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] group = GroupDetailBodySchema()
[docs] class Group_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group successful."
[docs] body = Group_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Group_GET_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group name was not found."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class Group_PATCH_RequestBodySchema(colander.MappingSchema):
[docs] group_name = colander.SchemaNode(colander.String(), missing=colander.drop, description="New name to apply to the group.")
[docs] description = colander.SchemaNode(colander.String(), missing=colander.drop, description="New description to apply to the group.")
[docs] discoverable = colander.SchemaNode(colander.Boolean(), missing=colander.drop, description="New discoverable status to apply to the group.")
[docs] class Group_PATCH_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Group_RequestPathSchema()
[docs] body = Group_PATCH_RequestBodySchema()
[docs] class Group_PATCH_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update group successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Group_PATCH_None_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Missing new group parameters to update."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Group_PATCH_Name_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'group_name' value specified."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Group_PATCH_Size_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'group_name' length specified (>{length} characters)." \ .format(length=get_constant("MAGPIE_USER_NAME_MAX_LENGTH"))
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Group_PATCH_ReservedKeyword_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update of reserved keyword or special group forbidden."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Group_PATCH_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group name already exists."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class Group_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Group_RequestPathSchema()
[docs] body = colander.MappingSchema(default={})
[docs] class Group_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete group successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Group_DELETE_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete group forbidden by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Group_DELETE_ReservedKeyword_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Deletion of reserved keyword or special group forbidden."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class GroupUsers_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Group_RequestPathSchema()
[docs] querystring = UserGroupsQuery()
[docs] class GroupUsers_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] user_names = UserNamesListSchema()
[docs] class GroupUsers_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group users successful."
[docs] body = GroupUsers_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class GroupUsers_GET_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to obtain group user names from db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class GroupServices_GET_QuerySchema(QueryRequestSchemaAPI, QueryFilterServiceType): pass
[docs] class GroupServices_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Group_RequestPathSchema()
[docs] querystring = GroupServices_GET_QuerySchema()
[docs] class GroupServices_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] services = ServicesCategorizedSchemaNode()
[docs] class GroupServices_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group services successful."
[docs] body = GroupServices_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class GroupServices_InternalServerErrorResponseBodySchema(InternalServerErrorResponseBodySchema):
[docs] group = GroupInfoBodySchema()
[docs] class GroupServices_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to populate group services."
[docs] body = GroupServices_InternalServerErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description)
[docs] class GroupServicePermissions_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = GroupService_RequestPathSchema()
[docs] class GroupServicePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionNameListSchema( description="List of service permissions applied to the referenced group.", example=[Permission.READ.value, Permission.WRITE.value] )
[docs] permissions = PermissionObjectListSchema( description="List of detailed service permissions applied to the referenced group." )
[docs] class GroupServicePermissions_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group service permissions successful."
[docs] body = GroupServicePermissions_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class GroupServicePermissions_GET_InternalServerErrorResponseBodySchema(InternalServerErrorResponseBodySchema):
[docs] group = GroupInfoBodySchema()
[docs] service = ServiceBodySchema()
[docs] class GroupServicePermissions_GET_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to extract permissions names from group-service."
[docs] body = GroupServicePermissions_GET_InternalServerErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description)
[docs] class GroupServicePermissions_POST_RequestBodySchema(colander.MappingSchema):
[docs] permission_name = colander.SchemaNode( colander.String(), description="Permission name (implicit or explicit) to create on the service for the group.", missing=colander.drop )
[docs] permission = PermissionObjectSchema( description="Detailed permission definition to create on the service for the group.", missing=colander.drop )
[docs] class GroupServicePermissions_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] path = GroupService_RequestPathSchema()
[docs] body = GroupServicePermissions_POST_RequestBodySchema()
[docs] class GroupResourcePermissions_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] path = GroupResource_RequestPathSchema()
[docs] body = GroupServicePermissions_POST_RequestBodySchema()
[docs] class GroupResourcePermissions_Check_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_name = colander.SchemaNode(colander.String(), description="Name of the permission requested.")
[docs] permission = PermissionObjectTypeSchema(description="Detailed permission definition.")
[docs] resource = ResourceBodySchema()
[docs] group = GroupInfoBodySchema()
[docs] class GroupResourcePermissions_Check_ErrorResponseBodySchema(ErrorResponseBodySchema): pass
[docs] class GroupResourcePermissions_Check_ErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Lookup of similar permission on service/resource for group refused by db."
[docs] body = GroupResourcePermissions_Check_ErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description )
[docs] class GroupResourcePermissions_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Create group resource permission successful."
[docs] body = GroupResourcePermissions_Check_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs] class GroupResourcePermissions_POST_ForbiddenAddResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Add group resource permission refused by db."
[docs] body = GroupResourcePermissions_Check_ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class GroupResourcePermissions_POST_ForbiddenCreateResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Create group resource permission failed."
[docs] body = GroupResourcePermissions_Check_ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class GroupResourcePermissions_POST_ForbiddenGetResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group resource permission failed."
[docs] body = GroupResourcePermissions_Check_ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class GroupResourcePermissions_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Similar permission already exists on resource for group."
[docs] body = GroupResourcePermissions_Check_ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] GroupResourcePermissions_PUT_RequestSchema = GroupResourcePermissions_POST_RequestSchema
[docs] GroupResourcePermissions_PUT_CreatedResponseSchema = GroupResourcePermissions_POST_CreatedResponseSchema
[docs] GroupResourcePermissions_PUT_ForbiddenResponseSchema = GroupResourcePermissions_POST_ForbiddenGetResponseSchema
[docs] class GroupResourcePermissions_PUT_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update group resource permission successful."
[docs] body = GroupResourcePermissions_Check_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class GroupResourcePermissionName_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = GroupResourcePermission_RequestPathSchema()
[docs] body = colander.MappingSchema(default={})
[docs] class GroupResourcePermissions_DELETE_RequestBodySchema(colander.MappingSchema):
[docs] permission = PermissionObjectSchema( description="Detailed permission definition to delete from the resource for the group.", missing=colander.drop )
[docs] class GroupResourcePermissions_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = GroupResource_RequestPathSchema()
[docs] body = GroupResourcePermissions_DELETE_RequestBodySchema()
[docs] class GroupResourcesPermissions_InternalServerErrorResponseBodySchema(InternalServerErrorResponseBodySchema):
[docs] group = colander.SchemaNode(colander.String(), description="Object representation of the group.")
[docs] resource_ids = colander.SchemaNode(colander.String(), description="Object representation of the resource ids.")
[docs] resource_types = colander.SchemaNode(colander.String(), description="Object representation of the resource types.")
[docs] class GroupResourcesPermissions_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to build group resources json tree."
[docs] body = GroupResourcesPermissions_InternalServerErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description)
[docs] class GroupResourcePermissions_InternalServerErrorResponseBodySchema(InternalServerErrorResponseBodySchema):
[docs] group = colander.SchemaNode(colander.String(), description="Object representation of the group.")
[docs] resource = colander.SchemaNode(colander.String(), description="Object representation of the resource.")
[docs] class GroupResourcePermissions_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to obtain group resource permissions."
[docs] body = GroupResourcePermissions_InternalServerErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description)
[docs] class GroupResources_GET_QuerySchema(QueryRequestSchemaAPI, QueryFilterServiceType): pass
[docs] class GroupResources_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Group_RequestPathSchema()
[docs] querystring = GroupResources_GET_QuerySchema()
[docs] class GroupResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] resources = ResourcesSchemaNode()
[docs] class GroupResources_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group resources successful."
[docs] body = GroupResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class GroupResources_GET_InternalServerErrorResponseBodySchema(InternalServerErrorResponseBodySchema):
[docs] group = colander.SchemaNode(colander.String(), description="Object representation of the group.")
[docs] class GroupResources_GET_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to build group resources json tree."
[docs] body = GroupResources_GET_InternalServerErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description)
[docs] class GroupResourcePermissions_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = GroupResource_RequestPathSchema()
[docs] class GroupResourcePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permissions_names = PermissionNameListSchema( description="List of resource permissions applied to the referenced group.", example=[Permission.READ.value, Permission.WRITE.value] )
[docs] permissions = PermissionObjectListSchema( description="List of detailed resource permissions applied to the referenced group." )
[docs] class GroupResourcePermissions_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group resource permissions successful."
[docs] body = GroupResourcePermissions_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class GroupServiceResources_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = GroupService_RequestPathSchema()
[docs] class GroupServiceResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] service = ServiceResourcesBodySchema()
[docs] class GroupServiceResources_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group service resources successful."
[docs] body = GroupServiceResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] GroupServicePermissions_PUT_RequestSchema = GroupServicePermissions_POST_RequestSchema
[docs] GroupServicePermissions_DELETE_RequestSchema = GroupResourcePermissions_DELETE_RequestSchema
[docs] class GroupServicePermission_DELETE_RequestBodySchema(colander.MappingSchema):
[docs] permission_name = colander.SchemaNode(colander.String(), description="Name of the permission to delete.")
[docs] class GroupServicePermissionName_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = GroupServicePermission_RequestPathSchema()
[docs] body = GroupServicePermission_DELETE_RequestBodySchema()
[docs] class GroupServicePermission_DELETE_ResponseBodySchema(BaseResponseBodySchema):
[docs] group = GroupInfoBodySchema()
[docs] resource = ResourceBodySchema()
[docs] permission_name = colander.SchemaNode( colander.String(), description="Permission name (implicit or explicit) to be created.", missing=colander.drop )
[docs] permission = PermissionObjectSchema( description="Detailed permission to be created", missing=colander.drop )
[docs] class GroupServicePermission_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete group resource permission successful."
[docs] body = GroupServicePermission_DELETE_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class GroupServicePermission_DELETE_ForbiddenGetResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group resource permission failed."
[docs] body = GroupServicePermission_DELETE_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class GroupServicePermission_DELETE_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete group resource permission refused by db."
[docs] body = GroupServicePermission_DELETE_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class GroupServicePermission_DELETE_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Permission not found for corresponding group and resource."
[docs] body = GroupServicePermission_DELETE_ResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class RegisterGroup_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Could not find any discoverable group matching provided name."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class RegisterGroups_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] group_names = GroupNamesListSchema(description="List of discoverable group names.")
[docs] class RegisterGroups_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get discoverable groups successful."
[docs] body = RegisterGroups_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class RegisterGroups_GET_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Obtain discoverable groups refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class RegisterGroup_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Group_RequestPathSchema()
[docs] class RegisterGroup_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] group = GroupPublicBodySchema() # not detailed because authenticated route has limited information
[docs] class RegisterGroup_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get discoverable group successful."
[docs] body = RegisterGroup_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class RegisterGroup_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Group_RequestPathSchema()
[docs] body = colander.MappingSchema(description="Nothing required.")
[docs] class RegisterGroup_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] user_name = colander.SchemaNode( colander.String(), description="Name of the user in the user-group relationship.", example="logged-user", )
[docs] group_name = colander.SchemaNode( colander.String(), description="Name of the group in the user-group relationship.", example="public-group", )
[docs] class RegisterGroup_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Logged user successfully joined the discoverable group. User is now a member of the group."
[docs] body = RegisterGroup_POST_ResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class RegisterGroup_POST_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group membership was not permitted for the logged user."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class RegisterGroup_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Logged user is already a member of the group."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class RegisterGroup_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Group_RequestPathSchema()
[docs] body = colander.MappingSchema(description="Nothing required.")
[docs] class RegisterGroup_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Logged user successfully removed from the group. User is not a member of the group anymore."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
# check done using same util function
[docs] RegisterGroup_DELETE_ForbiddenResponseSchema = UserGroup_DELETE_ForbiddenResponseSchema
[docs] RegisterGroup_DELETE_NotFoundResponseSchema = UserGroup_DELETE_NotFoundResponseSchema
[docs] class RegisterUsers_GET_RequestSchema(BaseRequestSchemaAPI): pass # no query string in this case (see Users_GET_RequestSchema)
[docs] class RegisterUsers_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] registrations = UserNamesListSchema()
[docs] class RegisterUsers_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get users pending registration successful."
[docs] body = RegisterUsers_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] RegisterUsers_GET_ForbiddenResponseSchema = Users_GET_ForbiddenResponseSchema
[docs] class RegisterUsers_POST_RequestSchema(colander.MappingSchema):
[docs] user_name = colander.SchemaNode( colander.String(), description="Name to employ for new user registration.", example="john", )
[docs] email = colander.SchemaNode( colander.String(), description="Email to employ for new user registration.", example="john@mail.com", validator=colander.Email(), )
[docs] password = colander.SchemaNode( colander.String(), description="Password to employ for new user registration.", example="itzaseekit", )
[docs] class RegisterUserBodySchema(colander.MappingSchema):
[docs] user_name = colander.SchemaNode( colander.String(), description="Pending user registration name.", example="toto" )
[docs] email = colander.SchemaNode( colander.String(), description="Pending user registration email.", example="toto@mail.com", validator=colander.Email(), )
[docs] class RegisterUsers_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] registration = RegisterUserBodySchema()
[docs] class RegisterUsers_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get users pending registration successful."
[docs] body = RegisterUsers_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs] RegisterUser_Check_BadRequestResponseSchema = User_Check_BadRequestResponseSchema
[docs] RegisterUsers_POST_ForbiddenResponseSchema = Users_POST_ForbiddenResponseSchema
[docs] class RegisterUser_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = User_RequestPathSchema()
[docs] class RegisterUser_Check_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Pending user registration could not be found."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class RegisterUser_Check_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User registration is already pending approval."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class RegisterUser_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] registration = PendingUserInfoSchema()
[docs] class RegisterUser_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get pending user registration details successful."
[docs] body = RegisterUser_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class RegisterUser_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] path = User_RequestPathSchema()
[docs] body = colander.MappingSchema(default={})
[docs] class RegisterUser_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete pending user registration successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class TemporaryURL_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = TemporaryURL_RequestPathSchema()
[docs] class TemporaryURL_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Successful operation from provided temporary URL token."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class TemporaryURL_GET_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Operation matching temporary URL token could not be found or was already processed."
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class TemporaryURL_GET_GoneResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Temporary URL token is expired."
[docs] body = BaseResponseBodySchema(code=HTTPGone.code, description=description)
[docs] class TemporaryToken_POST_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to add token to db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Session_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] user = UserBodySchema(missing=colander.drop)
[docs] authenticated = colander.SchemaNode( colander.Boolean(), description="Indicates if any user session is currently authenticated (user logged in).")
[docs] class Session_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get session successful."
[docs] body = Session_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Session_GET_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Failed to get session details."
[docs] body = InternalServerErrorResponseSchema()
[docs] class ProvidersBodySchema(colander.MappingSchema):
[docs] internal = ProvidersListSchema()
[docs] external = ProvidersListSchema()
[docs] class Providers_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] providers = ProvidersBodySchema()
[docs] class Providers_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get providers successful."
[docs] body = Providers_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class ProviderSignin_GET_RequestHeaderSchema(RequestHeaderSchemaAPI):
[docs] Authorization = colander.SchemaNode( colander.String(), missing=colander.drop, example="Bearer MyF4ncy4ccEsT0k3n", description="Access token to employ for direct signin with external provider bypassing the login procedure. " "Access token must have been validated with the corresponding provider beforehand. " "Supported format is 'Authorization: Bearer MyF4ncy4ccEsT0k3n'")
[docs] HomepageRoute = colander.SchemaNode( colander.String(), missing=colander.drop, example="/session", default="Magpie UI Homepage", name="Homepage-Route", description="Alternative redirection homepage after signin. " "Must be a relative path to Magpie for security reasons.")
[docs] class ProviderSignin_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] path = Provider_RequestPathSchema()
[docs] header = ProviderSignin_GET_RequestHeaderSchema()
[docs] class ProviderSignin_GET_FoundResponseBodySchema(BaseResponseBodySchema):
[docs] homepage_route = colander.SchemaNode(colander.String(), description="Route to be used for following redirection.")
[docs] class ProviderSignin_GET_FoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "External login homepage route found. Temporary status before redirection to 'Homepage-Route' header."
[docs] body = ProviderSignin_GET_FoundResponseBodySchema(code=HTTPFound.code, description=description)
[docs] class ProviderSignin_GET_BadRequestResponseBodySchema(ErrorResponseBodySchema):
[docs] reason = colander.SchemaNode(colander.String(), description="Additional detail about the error.")
[docs] class ProviderSignin_GET_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Incorrectly formed 'Authorization: Bearer <access_token>' header."
[docs] body = ProviderSignin_GET_BadRequestResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class ProviderSignin_GET_UnauthorizedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Unauthorized 'UserInfo' update using provided Authorization headers."
[docs] body = ErrorResponseBodySchema(code=HTTPUnauthorized.code, description=description)
[docs] class ProviderSignin_GET_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Forbidden 'Homepage-Route' host not matching Magpie refused for security reasons."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class ProviderSignin_GET_NotFoundResponseBodySchema(ErrorResponseBodySchema):
[docs] param = ErrorVerifyParamBodySchema()
[docs] provider_name = colander.SchemaNode(colander.String())
[docs] providers = ProvidersListSchema()
[docs] class ProviderSignin_GET_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Invalid 'provider_name' not found within available providers."
[docs] body = ProviderSignin_GET_NotFoundResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs] class Signin_BaseRequestSchema(colander.MappingSchema):
[docs] user_name = colander.SchemaNode(colander.String(), description="User name to use for sign in. " "Can also be the email provided during registration.")
[docs] password = colander.SchemaNode(colander.String(), description="Password to use for sign in.")
[docs] provider_name = colander.SchemaNode(colander.String(), description="Provider to use for sign in. " "Required for external provider login.", default=get_constant("MAGPIE_DEFAULT_PROVIDER"), missing=colander.drop)
[docs] class SigninQueryParamSchema(QueryRequestSchemaAPI, Signin_BaseRequestSchema): pass
[docs] class Signin_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] querystring = SigninQueryParamSchema()
[docs] class Signin_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] body = Signin_BaseRequestSchema()
[docs] class Signin_POST_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Login successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Signin_POST_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Missing credentials."
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs] class Signin_POST_UnauthorizedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Incorrect credentials."
[docs] body = ErrorResponseBodySchema(code=HTTPUnauthorized.code, description=description)
[docs] class Signin_POST_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Login was refused for this user."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs] class Signin_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Add external user identity refused by db because it already exists."
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs] class Signin_POST_InternalServerErrorBodySchema(InternalServerErrorResponseBodySchema):
[docs] user_name = colander.SchemaNode(colander.String(), description="Specified user retrieved from the request.")
[docs] provider_name = colander.SchemaNode(colander.String(), description="Specified provider retrieved from the request.")
[docs] class Signin_POST_Internal_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Unknown login error."
[docs] body = Signin_POST_InternalServerErrorBodySchema(code=HTTPInternalServerError.code, description=description)
[docs] class Signin_POST_External_InternalServerErrorResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Error occurred while signing in with external provider."
[docs] body = Signin_POST_InternalServerErrorBodySchema(code=HTTPInternalServerError.code, description=description)
[docs] class Signout_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Sign out successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Version_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] version = colander.SchemaNode( colander.String(), description="Magpie version string", example=__meta__.__version__)
[docs] db_version = colander.SchemaNode( colander.String(), description="Database version string", exemple="a395ef9d3fe6")
[docs] class Version_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get version successful."
[docs] body = Version_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class Homepage_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get homepage successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs] class SwaggerAPI_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = TitleAPI
[docs] header = RequestHeaderSchemaUI()
[docs] body = colander.SchemaNode(colander.String(), example="This page!")
# Responses for specific views
[docs] Resource_GET_responses = { "200": Resource_GET_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": Resource_GET_InternalServerErrorResponseSchema() }
[docs] Resource_PATCH_responses = { "200": Resource_PATCH_OkResponseSchema(), "400": Resource_PATCH_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": Resource_PATCH_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": Resource_PATCH_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Resources_GET_responses = { "200": Resources_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), "500": Resource_GET_InternalServerErrorResponseSchema(), }
[docs] Resources_POST_responses = { "201": Resources_POST_CreatedResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Resources_POST_ForbiddenResponseSchema(), "404": Resources_POST_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": Resources_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Resources_DELETE_responses = { "200": Resource_DELETE_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": Resource_DELETE_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ResourcePermissions_GET_responses = { "200": ResourcePermissions_GET_OkResponseSchema(), "400": ResourcePermissions_GET_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ResourceTypes_GET_responses = { "200": ResourceTypes_GET_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ServiceTypes_GET_responses = { "200": ServiceTypes_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ServiceType_GET_responses = { "200": Services_GET_OkResponseSchema(), "400": Services_GET_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Services_GET_responses = { "200": Services_GET_OkResponseSchema(), "400": Services_GET_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Services_POST_responses = { "201": Services_POST_CreatedResponseSchema(), "400": Services_POST_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": Services_POST_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "409": Services_POST_ConflictResponseSchema(), "422": Services_POST_UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Service_GET_responses = { "200": Service_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Service_PATCH_responses = { "200": Service_PATCH_OkResponseSchema(), "400": Service_PATCH_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": Service_PATCH_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "409": Service_PATCH_ConflictResponseSchema(), "422": Service_CheckConfig_UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Service_DELETE_responses = { "200": Service_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_DELETE_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ServicePermissions_GET_responses = { "200": ServicePermissions_GET_OkResponseSchema(), "400": ServicePermissions_GET_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": Service_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ServiceResources_GET_responses = { "200": ServiceResources_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ServiceResources_POST_responses = { "201": ServiceResources_POST_CreatedResponseSchema(), "401": UnauthorizedResponseSchema(), "403": ServiceResources_POST_ForbiddenResponseSchema(), "404": ServiceResources_POST_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": ServiceResources_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ServiceTypeResources_GET_responses = { "200": ServiceTypeResources_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": ServiceTypeResources_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": ServiceTypeResources_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ServiceTypeResourceTypes_GET_responses = { "200": ServiceTypeResourceTypes_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": ServiceTypeResourceTypes_GET_ForbiddenResponseSchema(), "404": ServiceTypeResourceTypes_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ServiceResource_GET_responses = Resource_GET_responses
[docs] ServiceResource_DELETE_responses = { "200": ServiceResource_DELETE_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": ServiceResource_DELETE_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Permissions_PATCH_responses = { "200": Permissions_PATCH_OkResponseSchema(), "400": Permissions_PATCH_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": Permissions_PATCH_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Users_GET_responses = { "200": Users_GET_OkResponseSchema(), "400": Users_GET_BadRequestSchema(), "401": UnauthorizedResponseSchema(), "403": Users_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Users_POST_responses = { "201": Users_POST_CreatedResponseSchema(), "400": User_Check_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Users_POST_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "409": User_Check_Name_ConflictResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] User_GET_responses = { "200": User_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] User_PATCH_responses = { "200": Users_PATCH_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": UserGroup_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "409": User_Check_Name_ConflictResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] User_DELETE_responses = { "200": User_DELETE_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserResources_GET_responses = { "200": UserResources_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": UserResources_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserGroups_GET_responses = { "200": UserGroups_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserGroups_POST_responses = { "201": UserGroups_POST_CreatedResponseSchema(), "202": UserGroups_POST_AcceptedResponseSchema(), "400": User_Check_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": UserGroups_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserGroup_DELETE_responses = { "200": UserGroup_DELETE_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": UserGroup_DELETE_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": UserGroup_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserResourcePermissions_GET_responses = { "200": UserResourcePermissions_GET_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserResourcePermissions_POST_responses = { "201": UserResourcePermissions_POST_CreatedResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "400": UserResourcePermissions_POST_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": UserResourcePermissions_POST_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "409": UserResourcePermissions_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
# same method handles operations/results/messages, but conflict will not occur
[docs] UserResourcePermissions_PUT_responses = { "200": UserResourcePermissions_PUT_OkResponseSchema(), # updated "201": UserResourcePermissions_PUT_CreatedResponseSchema(), # created "401": UnauthorizedResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": UserResourcePermissions_PUT_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), # 409: not applicable "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserResourcePermissions_DELETE_responses = { "200": UserResourcePermissions_DELETE_OkResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "400": UserResourcePermissions_DELETE_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "404": UserResourcePermissions_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserResourcePermissionName_DELETE_responses = { "200": UserResourcePermissionName_DELETE_OkResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "400": UserResourcePermissionName_DELETE_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "404": UserResourcePermissionName_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserServices_GET_responses = { "200": UserServices_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": User_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": User_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserServicePermissions_GET_responses = { "200": UserServicePermissions_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": User_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": UserServicePermissions_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserServiceResources_GET_responses = { "200": UserServiceResources_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": User_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] UserServicePermissions_POST_responses = UserResourcePermissions_POST_responses
[docs] UserServicePermissions_PUT_responses = UserResourcePermissions_PUT_responses
[docs] UserServicePermissions_DELETE_responses = UserResourcePermissions_DELETE_responses
[docs] UserServicePermissionName_DELETE_responses = UserResourcePermissionName_DELETE_responses
[docs] LoggedUser_GET_responses = { "200": User_GET_OkResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUser_PATCH_responses = { "200": Users_PATCH_OkResponseSchema(), "400": User_PATCH_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": User_PATCH_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "409": User_PATCH_ConflictResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUser_DELETE_responses = { "200": User_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserResources_GET_responses = { "200": UserResources_GET_OkResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": UserResources_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserGroups_GET_responses = { "200": UserGroups_GET_OkResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserGroups_POST_responses = { "201": UserGroups_POST_CreatedResponseSchema(), "202": UserGroups_POST_AcceptedResponseSchema(), "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": UserGroups_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserGroup_DELETE_responses = { "200": UserGroup_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserResourcePermissions_GET_responses = { "200": UserResourcePermissions_GET_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserResourcePermissions_POST_responses = { "201": UserResourcePermissions_POST_CreatedResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "400": UserResourcePermissions_POST_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), "409": UserResourcePermissions_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
# same method handles operations/results/messages, but conflict will not occur
[docs] LoggedUserResourcePermissions_PUT_responses = { "200": UserResourcePermissions_PUT_OkResponseSchema(), # updated "201": UserResourcePermissions_PUT_CreatedResponseSchema(), # created "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), # 409: not applicable "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserResourcePermissions_DELETE_responses = { "200": UserResourcePermissions_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "404": UserResourcePermissions_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserResourcePermissionName_DELETE_responses = { "200": UserResourcePermissionName_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "404": UserResourcePermissionName_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserServices_GET_responses = { "200": UserServices_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": User_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserServicePermissions_GET_responses = { "200": UserServicePermissions_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": UserServicePermissions_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserServiceResources_GET_responses = { "200": UserServiceResources_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] LoggedUserServicePermissions_POST_responses = LoggedUserResourcePermissions_POST_responses
[docs] LoggedUserServicePermissions_PUT_responses = LoggedUserResourcePermissions_PUT_responses
[docs] LoggedUserServicePermissions_DELETE_responses = LoggedUserResourcePermissions_DELETE_responses
[docs] LoggedUserServicePermissionName_DELETE_responses = LoggedUserResourcePermissionName_DELETE_responses
[docs] Groups_GET_responses = { "200": Groups_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Groups_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Groups_POST_responses = { "201": Groups_POST_CreatedResponseSchema(), "400": Groups_POST_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": Groups_POST_ForbiddenCreateResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "409": Groups_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Group_GET_responses = { "200": Group_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Group_PATCH_responses = { "200": Group_PATCH_OkResponseSchema(), "400": Group_PATCH_Name_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": UnauthorizedResponseSchema(), "403": Group_PATCH_ReservedKeyword_ForbiddenResponseSchema(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": Group_PATCH_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Group_DELETE_responses = { "200": Group_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_DELETE_ReservedKeyword_ForbiddenResponseSchema(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] GroupUsers_GET_responses = { "200": GroupUsers_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": GroupUsers_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] GroupServices_GET_responses = { "200": GroupServices_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": GroupServices_InternalServerErrorResponseSchema(), }
[docs] GroupServicePermissions_GET_responses = { "200": GroupServicePermissions_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": GroupServicePermissions_GET_InternalServerErrorResponseSchema(), }
[docs] GroupServiceResources_GET_responses = { "200": GroupServiceResources_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] GroupResourcePermissions_POST_responses = { "201": GroupResourcePermissions_POST_CreatedResponseSchema(), "401": UnauthorizedResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": GroupResourcePermissions_POST_ForbiddenGetResponseSchema(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": GroupResourcePermissions_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] GroupServicePermissions_POST_responses = GroupResourcePermissions_POST_responses
[docs] GroupResourcePermissions_PUT_responses = { "200": GroupResourcePermissions_PUT_OkResponseSchema(), # updated "201": GroupResourcePermissions_PUT_CreatedResponseSchema(), # created "401": UnauthorizedResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": GroupResourcePermissions_PUT_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), # 409: not applicable "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] GroupServicePermissions_PUT_responses = GroupResourcePermissions_PUT_responses
[docs] GroupServicePermissionName_DELETE_responses = { "200": GroupServicePermission_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "403": GroupServicePermission_DELETE_ForbiddenResponseSchema(), "404": GroupServicePermission_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] GroupServicePermissions_DELETE_responses = GroupServicePermissionName_DELETE_responses
[docs] GroupResourcePermissions_DELETE_responses = GroupServicePermissions_DELETE_responses
[docs] GroupResourcePermissionName_DELETE_responses = GroupServicePermissionName_DELETE_responses
[docs] GroupResources_GET_responses = { "200": GroupResources_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": GroupResources_GET_InternalServerErrorResponseSchema(), }
[docs] GroupResourcePermissions_GET_responses = { "200": GroupResourcePermissions_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_MatchDictCheck_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] RegisterGroups_GET_responses = { "200": RegisterGroups_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": RegisterGroups_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "500": InternalServerErrorResponseSchema(), }
[docs] RegisterGroup_GET_responses = { "200": RegisterGroup_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "404": RegisterGroup_NotFoundResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] RegisterGroup_POST_responses = { "201": RegisterGroup_POST_CreatedResponseSchema(), "202": UserGroups_POST_AcceptedResponseSchema(), "401": UnauthorizedResponseSchema(), "403": RegisterGroup_POST_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": RegisterGroup_NotFoundResponseSchema(), "409": RegisterGroup_POST_ConflictResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] RegisterGroup_DELETE_responses = { "200": RegisterGroup_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": RegisterGroup_DELETE_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": RegisterGroup_DELETE_NotFoundResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] RegisterUsers_GET_responses = { "200": RegisterUsers_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": RegisterUsers_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] RegisterUsers_POST_responses = { "201": RegisterUsers_POST_CreatedResponseSchema(), "400": RegisterUser_Check_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": RegisterUsers_POST_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "406": NotAcceptableResponseSchema(), "409": RegisterUser_Check_ConflictResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] RegisterUser_GET_responses = { "200": RegisterUser_GET_OkResponseSchema(), "400": RegisterUser_Check_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": HTTPForbiddenResponseSchema(), "404": RegisterUser_Check_NotFoundResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] RegisterUser_DELETE_responses = { "200": RegisterUser_DELETE_OkResponseSchema(), "400": RegisterUser_Check_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": HTTPForbiddenResponseSchema(), "404": RegisterUser_Check_NotFoundResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] TemporaryURL_GET_responses = { "200": TemporaryURL_GET_OkResponseSchema(), "404": TemporaryURL_GET_NotFoundResponseSchema(), "410": TemporaryURL_GET_GoneResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Providers_GET_responses = { "200": Providers_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] ProviderSignin_GET_responses = { "302": ProviderSignin_GET_FoundResponseSchema(), "400": ProviderSignin_GET_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": ProviderSignin_GET_UnauthorizedResponseSchema(), "403": ProviderSignin_GET_ForbiddenResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "404": ProviderSignin_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Signin_POST_responses = { "200": Signin_POST_OkResponseSchema(), "400": Signin_POST_BadRequestResponseSchema(), # FIXME: https://github.com/Ouranosinc/Magpie/issues/359 "401": Signin_POST_UnauthorizedResponseSchema(), "403": Signin_POST_ForbiddenResponseSchema(), "404": ProviderSignin_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": Signin_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": Signin_POST_Internal_InternalServerErrorResponseSchema(), }
[docs] Signin_GET_responses = Signin_POST_responses
[docs] Signout_GET_responses = { "200": Signout_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Session_GET_responses = { "200": Session_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(), "500": Session_GET_InternalServerErrorResponseSchema(), }
[docs] Version_GET_responses = { "200": Version_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] Homepage_GET_responses = { "200": Homepage_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] SwaggerAPI_GET_responses = { "200": SwaggerAPI_GET_OkResponseSchema(), "500": InternalServerErrorResponseSchema(), }
[docs] def generate_api_schema(swagger_base_spec): # type: (Dict[Str, Union[Str, List[Str]]]) -> JSON """ Return JSON Swagger specifications of Magpie REST API. Uses Cornice Services and Schemas to return swagger specification. :param swagger_base_spec: dictionary that specifies the 'host' and list of HTTP 'schemes' to employ. """ generator = CorniceSwagger(get_services()) # function docstrings are used to create the route's summary in Swagger-UI generator.summary_docstrings = True generator.default_security = get_security swagger_base_spec.update(SecurityDefinitionsAPI) generator.swagger = swagger_base_spec json_api_spec = generator.generate(title=TitleAPI, version=__meta__.__version__, info=InfoAPI) for tag in json_api_spec["tags"]: tag["description"] = TAG_DESCRIPTIONS[tag["name"]] return json_api_spec