Source code for magpie.api.schemas

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 (
    HTTPBadRequest,
    HTTPConflict,
    HTTPCreated,
    HTTPForbidden,
    HTTPFound,
    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.permissions import Permission
from magpie.security import get_provider_names
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 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__}
} # Tags
[docs]APITag = "API"
[docs]SessionTag = "Session"
[docs]UsersTag = "User"
[docs]LoggedUserTag = "Logged User"
[docs]GroupsTag = "Group"
[docs]RegisterTag = "Register"
[docs]ResourcesTag = "Resource"
[docs]ServicesTag = "Service"
# 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"]
# Service Routes
[docs]def service_api_route_info(service_api, **kwargs): 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
[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]UserResourceTypesAPI = Service( path="/users/{user_name}/resources/types/{resource_type}", name="UserResourceTypes")
[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]LoggedUserResourceTypesAPI = Service( path=LoggedUserBase + "/resources/types/{resource_type}", name="LoggedUserResourceTypes")
[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]GroupResourceTypesAPI = Service( path="/groups/{group_name}/resources/types/{resource_type}", name="GroupResourceTypes")
[docs]RegisterGroupsAPI = Service( path="/register/groups", name="RegisterGroups")
[docs]RegisterGroupAPI = Service( path="/register/groups/{group_name}", name="RegisterGroup")
[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]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]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. If there is no active session, the public anonymous " "access is employed.\n\nNOTE: Value '{}' depends on Magpie configuration.".format(_LOGGED_USER_VALUE), GroupsTag: "Groups management and control of their applicable users, services, resources and permissions.\n\n" "Administrator-level permissions are required to access most paths. ", 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.",
} # Common 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(get_provider_names())
)
[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]ServiceNameParameter = colander.SchemaNode( colander.String(), description="Registered service name.", example="my-wps")
[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 HeaderRequestSchemaAPI(colander.MappingSchema):
[docs] accept = AcceptType(name="Accept", validator=colander.OneOf(SUPPORTED_ACCEPT_TYPES), description="Desired MIME type for the response body content.")
[docs] content_type = ContentType(validator=colander.OneOf(KNOWN_CONTENT_TYPES), description="MIME content type of the request body.")
[docs]class HeaderRequestSchemaUI(colander.MappingSchema):
[docs] content_type = ContentType(default=CONTENT_TYPE_HTML, example=CONTENT_TYPE_HTML, description="MIME content type of the request body.")
[docs]class QueryRequestSchemaAPI(colander.MappingSchema):
[docs] format = AcceptType(validator=colander.OneOf(SUPPORTED_FORMAT_TYPES), description="Desired MIME type for the response body content. "
"This formatting alternative by query parameter overrides the Accept header.")
[docs]QueryEffectivePermissions = 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 other query parameter values).")
[docs]QueryInheritGroupsPermissions = colander.SchemaNode( colander.Boolean(), name="inherited", default=False, missing=colander.drop, description="Include the user's groups memberships inheritance to resolve permissions.")
[docs]QueryFilterResources = 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]QueryCascadeResourcesPermissions = 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]QueryFlattenServices = 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 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 = HeaderRequestSchemaAPI()
[docs] querystring = QueryRequestSchemaAPI()
[docs]class HeaderResponseSchema(colander.MappingSchema):
[docs] content_type = ContentType(validator=colander.OneOf(SUPPORTED_ACCEPT_TYPES), description="MIME content type of the response body.")
[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 self.__code = code self.__desc = description # 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]class ErrorResponseBodySchema(BaseResponseBodySchema): def __init__(self, code, description, **kw): 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")
[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): 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): 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.")
[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 GroupNamesListSchema(colander.SequenceSchema):
[docs] group_name = GroupNameParameter
[docs]class UserNamesListSchema(colander.SequenceSchema):
[docs] user_name = UserNameParameter
[docs]class PermissionListSchema(colander.SequenceSchema):
[docs] permission_name = colander.SchemaNode( colander.String(), description="Permissions applicable to the service/resource", example=Permission.READ.value
)
[docs]class UserBodySchema(colander.MappingSchema):
[docs] user_name = UserNameParameter
[docs] email = colander.SchemaNode( colander.String(), description="Email of the user.", example="toto@mail.com")
[docs] group_names = GroupNamesListSchema( example=["administrators", "users"]
)
[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] 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]class ServiceBodySchema(colander.MappingSchema):
[docs] resource_id = colander.SchemaNode( colander.Integer(), description="Resource identification number",
)
[docs] permission_names = PermissionListSchema( description="List of service permissions applicable or effective for a given user/group according to context.", example=[Permission.READ.value, Permission.WRITE.value]
)
[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] public_url = colander.SchemaNode( colander.String(), description="Proxy URL available for public access with permissions", example="http://localhost/twitcher/ows/proxy/thredds"
)
[docs] service_url = colander.SchemaNode( colander.String(), description="Private URL of the service (restricted access)", example="http://localhost:9999/thredds"
)
[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 = PermissionListSchema(example=[Permission.READ.value, Permission.WRITE.value], description="List of resource permissions applicable or effective "
"for a given user/group according to context.")
[docs] permission_names.default = colander.null # if no parent
[docs] permission_names.missing = colander.drop # if not returned (basic_info = True)
# 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_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):
[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 children 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] body = Resource_PATCH_RequestBodySchema()
[docs] resource_id = ResourceIdParameter
[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] body = Resource_DELETE_RequestBodySchema()
[docs] resource_id = ResourceIdParameter
[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_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionListSchema( description="List of permissions applicable for the referenced resource.", example=[Permission.READ.value, Permission.WRITE.value]
)
[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 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 GeoServer 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):
[docs] flatten = QueryFlattenServices
[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 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]Services_GET_RequestSchema = ServiceTypes_GET_RequestSchema
[docs]class Service_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] service = ServiceBodySchema()
[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"
)
[docs]class Services_POST_RequestBodySchema(BaseRequestSchemaAPI):
[docs] body = Services_POST_BodySchema()
[docs]class Services_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Service registration to db successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.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_ResponseBodySchema(colander.MappingSchema):
[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"
)
[docs] service_push = PhoenixServicePushOption()
[docs]class Service_PATCH_RequestBodySchema(BaseRequestSchemaAPI):
[docs] body = Service_PATCH_ResponseBodySchema()
[docs]class Service_SuccessBodyResponseSchema(BaseResponseBodySchema):
[docs] service = ServiceBodySchema()
[docs]class Service_PATCH_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Update service successful."
[docs] body = Service_SuccessBodyResponseSchema(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_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] body = Resource_DELETE_RequestBodySchema()
[docs] service_name = ServiceNameParameter
[docs]class Service_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete service successful."
[docs] body = ServiceBodySchema(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 = PermissionListSchema(example=[Permission.READ.value, Permission.WRITE.value])
[docs]class ServicePermissions_GET_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get service permissions successful."
[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] service_name = ServiceNameParameter
[docs]ServiceResources_POST_CreatedResponseSchema = Resources_POST_CreatedResponseSchema
[docs]ServiceResources_POST_ForbiddenResponseSchema = Resources_POST_ForbiddenResponseSchema
[docs]ServiceResources_POST_NotFoundResponseSchema = Resources_POST_NotFoundResponseSchema
[docs]ServiceResources_POST_ConflictResponseSchema = Resources_POST_ConflictResponseSchema
[docs]class ServiceResources_POST_BadRequestResponseSchema(Resources_POST_BadRequestResponseSchema):
[docs] description = "Invalid 'parent_id' specified for child resource creation under requested service."
# 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_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 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 resource type allows child resources."
)
[docs] permission_names = PermissionListSchema( description="Permissions applicable to the specific resource type.", example=[Permission.READ.value, Permission.WRITE.value]
)
[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_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 Users_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] user_names = UserNamesListSchema()
[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_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_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_ForbiddenResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User check query was refused by db."
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class User_Check_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "User name matches an already existing user name."
[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",
)
[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", missing=colander.drop, example="john",
)
[docs] email = colander.SchemaNode( colander.String(), description="New email to apply to the user", missing=colander.drop, example="john@mail.com",
)
[docs] password = colander.SchemaNode( colander.String(), description="New password to apply to the user", missing=colander.drop, example="itzaseekit",
)
[docs]class User_PATCH_RequestSchema(BaseRequestSchemaAPI):
[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 new user parameters to update."
[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_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 query refused by db."
[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] body = colander.MappingSchema(default={})
[docs]class User_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete user successful."
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.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_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 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] body = UserGroups_POST_RequestBodySchema()
[docs] user_name = UserNameParameter
[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_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_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):
[docs] inherited = QueryInheritGroupsPermissions
[docs] filtered = QueryFilterResources
[docs]class UserResources_GET_RequestSchema(BaseRequestSchemaAPI):
[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_GET_QuerySchema(QueryRequestSchemaAPI):
[docs] inherited = QueryInheritGroupsPermissions
[docs] effective = QueryEffectivePermissions
[docs]class UserResourcePermissions_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] querystring = UserResourcePermissions_GET_QuerySchema()
[docs]class UserResourcePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionListSchema( description="List of resource permissions effective for the referenced user.", example=[Permission.READ.value, Permission.WRITE.value]
)
[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 not found to obtain resource 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 of the created user-resource-permission reference.")
[docs]class UserResourcePermissions_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] body = UserResourcePermissions_POST_RequestBodySchema()
[docs] resource_id = ResourceIdParameter
[docs] user_name = UserNameParameter
[docs]class UserResourcePermissions_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource_id = colander.SchemaNode( colander.Integer(), description="resource_id of the created user-resource-permission reference.")
[docs] user_id = colander.SchemaNode( colander.Integer(), description="user_id of the created user-resource-permission reference.")
[docs] permission_name = colander.SchemaNode( colander.String(), description="permission_name of the created user-resource-permission reference.")
[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_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_POST_BadResponseBodySchema(BaseResponseBodySchema):
[docs] user_name = colander.SchemaNode(colander.String(), description="Specified user name.")
[docs] resource_id = colander.SchemaNode(colander.String(), description="Specified resource id.")
[docs] permission_name = colander.SchemaNode(colander.String(), description="Specified permission name.")
[docs] param = UserResourcePermissions_POST_ParamResponseBodySchema(missing=colander.drop)
[docs]class UserResourcePermissions_POST_BadRequestResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Permission not allowed for specified 'resource_type'."
[docs] body = UserResourcePermissions_POST_BadResponseBodySchema(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_POST_BadResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class UserResourcePermissions_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Permission already exist on resource for user."
[docs] body = UserResourcePermissions_POST_ResponseBodySchema(code=HTTPConflict.code, description=description)
# using same definitions
[docs]UserResourcePermissions_DELETE_BadResponseBodySchema = UserResourcePermissions_POST_ResponseBodySchema
[docs]UserResourcePermissions_DELETE_BadRequestResponseSchema = UserResourcePermissions_POST_BadRequestResponseSchema
[docs]class UserResourcePermission_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] body = colander.MappingSchema(default={})
[docs] user_name = UserNameParameter
[docs] resource_id = ResourceIdParameter
[docs] permission_name = PermissionNameParameter
[docs]class UserResourcePermissions_DELETE_OkResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Delete user resource permission successful."
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class UserResourcePermissions_DELETE_NotFoundResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Could not find user resource permission to delete from db."
[docs] body = UserResourcePermissions_DELETE_BadResponseBodySchema(code=HTTPOk.code, description=description)
[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):
[docs] inherited = QueryInheritGroupsPermissions
[docs]class UserServiceResources_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] querystring = UserServiceResources_GET_QuerySchema()
[docs] user_name = UserNameParameter
[docs] service_name = ServiceNameParameter
[docs]class UserServicePermissions_POST_RequestBodySchema(colander.MappingSchema):
[docs] permission_name = colander.SchemaNode(colander.String(), description="Name of the permission to create.")
[docs]class UserServicePermissions_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] body = UserServicePermissions_POST_RequestBodySchema()
[docs] user_name = UserNameParameter
[docs] service_name = ServiceNameParameter
[docs]class UserServicePermission_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] body = colander.MappingSchema(default={})
[docs] user_name = UserNameParameter
[docs] service_name = ServiceNameParameter
[docs] permission_name = PermissionNameParameter
[docs]class UserServices_GET_QuerySchema(QueryRequestSchemaAPI):
[docs] cascade = QueryCascadeResourcesPermissions
[docs] inherit = QueryInheritGroupsPermissions
[docs] flatten = QueryFlattenServices
[docs]class UserServices_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] querystring = UserServices_GET_QuerySchema()
[docs] user_name = UserNameParameter
[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):
[docs] inherited = QueryInheritGroupsPermissions
[docs]class UserServicePermissions_GET_RequestSchema(BaseRequestSchemaAPI):
[docs] querystring = UserServicePermissions_GET_QuerySchema()
[docs] user_name = UserNameParameter
[docs] service_name = ServiceNameParameter
[docs]class UserServicePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionListSchema( description="List of service permissions effective for the referenced user.", example=[Permission.READ.value, Permission.WRITE.value]
)
[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 created group.")
[docs] discoverable = colander.SchemaNode(colander.Boolean(), default=False, description="Discoverability status of the created group.")
[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_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] body = Group_PATCH_RequestBodySchema()
[docs] group_name = GroupNameParameter
[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] body = colander.MappingSchema(default={})
[docs] group_name = GroupNameParameter
[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_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_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_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionListSchema( description="List of service permissions effective for the referenced group.", example=[Permission.READ.value, Permission.WRITE.value]
)
[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="Name of the permission to create.")
[docs]class GroupServicePermissions_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] body = GroupServicePermissions_POST_RequestBodySchema()
[docs] group_name = GroupNameParameter
[docs] service_name = ServiceNameParameter
[docs]class GroupResourcePermissions_POST_RequestSchema(BaseRequestSchemaAPI):
[docs] body = GroupServicePermissions_POST_RequestBodySchema()
[docs] group_name = GroupNameParameter
[docs] resource_id = ResourceIdParameter
[docs]class GroupResourcePermissions_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_name = colander.SchemaNode(colander.String(), description="Name of the permission requested.")
[docs] resource = ResourceBodySchema()
[docs] group = GroupInfoBodySchema()
[docs]class GroupResourcePermissions_POST_CreatedResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Create group resource permission successful."
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs]class GroupResourcePermissions_POST_ForbiddenAddResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Add group resource permission refused by db."
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class GroupResourcePermissions_POST_ForbiddenCreateResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Create group resource permission failed."
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class GroupResourcePermissions_POST_ForbiddenGetResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Get group resource permission failed."
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class GroupResourcePermissions_POST_ConflictResponseSchema(BaseResponseSchemaAPI):
[docs] description = "Group resource permission already exists."
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPConflict.code, description=description)
[docs]class GroupResourcePermission_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] body = colander.MappingSchema(default={})
[docs] group_name = GroupNameParameter
[docs] resource_id = ResourceIdParameter
[docs] permission_name = PermissionNameParameter
[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_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_ResponseBodySchema(BaseResponseBodySchema):
[docs] permissions_names = PermissionListSchema( description="List of resource permissions effective for the referenced group.", example=[Permission.READ.value, Permission.WRITE.value]
)
[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_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]class GroupServicePermission_DELETE_RequestBodySchema(colander.MappingSchema):
[docs] permission_name = colander.SchemaNode(colander.String(), description="Name of the permission to delete.")
[docs]class GroupServicePermission_DELETE_RequestSchema(BaseRequestSchemaAPI):
[docs] body = GroupServicePermission_DELETE_RequestBodySchema()
[docs] group_name = GroupNameParameter
[docs] service_name = ServiceNameParameter
[docs] permission_name = PermissionNameParameter
[docs]class GroupServicePermission_DELETE_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_name = colander.SchemaNode(colander.String(), description="Name of the permission requested.")
[docs] resource = ResourceBodySchema()
[docs] group = GroupInfoBodySchema()
[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_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] body = colander.MappingSchema(description="Nothing required.")
[docs] group_name = GroupNameParameter
[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] body = colander.MappingSchema(description="Nothing required.")
[docs] group_name = GroupNameParameter
[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 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_HeaderRequestSchema(HeaderRequestSchemaAPI):
[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] header = ProviderSignin_GET_HeaderRequestSchema()
[docs] provider_name = ProviderNameParameter
[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 = "Could not verify 'user_name'."
[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 = HeaderRequestSchemaUI()
[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(), "401": UnauthorizedResponseSchema(), "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": Resource_GET_InternalServerErrorResponseSchema()
}
[docs]Resource_PATCH_responses = { "200": Resource_PATCH_OkResponseSchema(), "400": Resource_PATCH_BadRequestResponseSchema(), "403": Resource_PATCH_ForbiddenResponseSchema(), "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(), "400": Resources_POST_BadRequestResponseSchema(), "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(), "401": UnauthorizedResponseSchema(), "403": Resource_DELETE_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]ResourcePermissions_GET_responses = { "200": ResourcePermissions_GET_OkResponseSchema(), "400": ResourcePermissions_GET_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "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(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Services_GET_responses = { "200": Services_GET_OkResponseSchema(), "400": Services_GET_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Services_POST_responses = { "201": Services_POST_CreatedResponseSchema(), "400": Services_POST_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Services_POST_ForbiddenResponseSchema(), "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(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Service_PATCH_responses = { "200": Service_PATCH_OkResponseSchema(), "400": Service_PATCH_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_PATCH_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "409": Service_PATCH_ConflictResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Service_DELETE_responses = { "200": Service_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_DELETE_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]ServicePermissions_GET_responses = { "200": ServicePermissions_GET_OkResponseSchema(), "400": ServicePermissions_GET_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_MatchDictCheck_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]ServiceResources_GET_responses = { "200": ServiceResources_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_MatchDictCheck_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]ServiceResources_POST_responses = { "201": ServiceResources_POST_CreatedResponseSchema(), "400": ServiceResources_POST_BadRequestResponseSchema(), "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(), "404": ServiceTypeResources_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]ServiceTypeResourceTypes_GET_responses = { "200": ServiceTypeResourceTypes_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": ServiceTypeResourceTypes_GET_ForbiddenResponseSchema(), "404": ServiceTypeResourceTypes_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]ServiceResource_DELETE_responses = { "200": ServiceResource_DELETE_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": ServiceResource_DELETE_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Users_GET_responses = { "200": Users_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Users_GET_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Users_POST_responses = { "201": Users_POST_CreatedResponseSchema(), "400": User_Check_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Users_POST_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "409": User_Check_ConflictResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]User_GET_responses = { "200": User_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), "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(), "406": NotAcceptableResponseSchema(), "409": User_Check_ConflictResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]User_DELETE_responses = { "200": User_DELETE_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), "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(), "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(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]UserGroups_POST_responses = { "201": UserGroups_POST_CreatedResponseSchema(), "400": User_Check_BadRequestResponseSchema(), "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(), "401": UnauthorizedResponseSchema(), "403": UserGroup_DELETE_ForbiddenResponseSchema(), "404": UserGroup_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]UserResourcePermissions_GET_responses = { "200": UserResourcePermissions_GET_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]UserResourcePermissions_POST_responses = { "201": UserResourcePermissions_POST_CreatedResponseSchema(), "400": UserResourcePermissions_POST_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": UserResourcePermissions_POST_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "409": UserResourcePermissions_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]UserResourcePermission_DELETE_responses = { "200": UserResourcePermissions_DELETE_OkResponseSchema(), "400": UserResourcePermissions_DELETE_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "404": UserResourcePermissions_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]UserServices_GET_responses = { "200": UserServices_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": User_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]UserServicePermissions_GET_responses = { "200": UserServicePermissions_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": UserServicePermissions_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]UserServiceResources_GET_responses = { "200": UserServiceResources_GET_OkResponseSchema(), "400": User_Check_BadRequestResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]UserServicePermissions_POST_responses = UserResourcePermissions_POST_responses
[docs]UserServicePermission_DELETE_responses = UserResourcePermission_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(), "401": UnauthorizedResponseSchema(), "403": User_PATCH_ForbiddenResponseSchema(), "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(), "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(), "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]LoggedUserResourcePermissions_POST_responses = { "201": UserResourcePermissions_POST_CreatedResponseSchema(), "400": UserResourcePermissions_POST_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), "409": UserResourcePermissions_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]LoggedUserResourcePermission_DELETE_responses = { "200": UserResourcePermissions_DELETE_OkResponseSchema(), "400": UserResourcePermissions_DELETE_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "404": UserResourcePermissions_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]LoggedUserServices_GET_responses = { "200": UserServices_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": User_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]LoggedUserServicePermissions_GET_responses = { "200": UserServicePermissions_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": UserServicePermissions_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]LoggedUserServiceResources_GET_responses = { "200": UserServiceResources_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]LoggedUserServicePermissions_POST_responses = LoggedUserResourcePermissions_POST_responses
[docs]LoggedUserServicePermission_DELETE_responses = LoggedUserResourcePermission_DELETE_responses
[docs]Groups_GET_responses = { "200": Groups_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Groups_GET_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Groups_POST_responses = { "201": Groups_POST_CreatedResponseSchema(), "400": Groups_POST_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Groups_POST_ForbiddenCreateResponseSchema(), "406": NotAcceptableResponseSchema(), "409": Groups_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Group_GET_responses = { "200": Group_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_MatchDictCheck_ForbiddenResponseSchema(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Group_PATCH_responses = { "200": Group_PATCH_OkResponseSchema(), "400": Group_PATCH_Name_BadRequestResponseSchema(), "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(), "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(), "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(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]GroupResourcePermissions_POST_responses = { "201": GroupResourcePermissions_POST_CreatedResponseSchema(), "401": UnauthorizedResponseSchema(), "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]GroupServicePermission_DELETE_responses = { "200": GroupServicePermission_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": GroupServicePermission_DELETE_ForbiddenResponseSchema(), "404": GroupServicePermission_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]GroupResources_GET_responses = { "200": GroupResources_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_MatchDictCheck_ForbiddenResponseSchema(), "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(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]GroupResourcePermission_DELETE_responses = GroupServicePermission_DELETE_responses
[docs]RegisterGroups_GET_responses = { "200": RegisterGroups_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": RegisterGroups_GET_ForbiddenResponseSchema(), "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(), "401": UnauthorizedResponseSchema(), "403": RegisterGroup_POST_ForbiddenResponseSchema(), "404": RegisterGroup_NotFoundResponseSchema(), "409": RegisterGroup_POST_ConflictResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]RegisterGroup_DELETE_responses = { "200": RegisterGroup_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": RegisterGroup_DELETE_ForbiddenResponseSchema(), "404": RegisterGroup_DELETE_NotFoundResponseSchema(), "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(), "401": ProviderSignin_GET_UnauthorizedResponseSchema(), "403": ProviderSignin_GET_ForbiddenResponseSchema(), "404": ProviderSignin_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "500": InternalServerErrorResponseSchema(),
}
[docs]Signin_POST_responses = { "200": Signin_POST_OkResponseSchema(), "400": Signin_POST_BadRequestResponseSchema(), "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