Source code for magpie.api.schemas

from magpie.definitions.cornice_definitions import colander, Service, CorniceSwagger, get_services
from magpie.definitions.pyramid_definitions import (
    HTTPOk,
    HTTPCreated,
    HTTPFound,
    HTTPBadRequest,
    HTTPUnauthorized,
    HTTPForbidden,
    HTTPNotFound,
    HTTPMethodNotAllowed,
    HTTPNotAcceptable,
    HTTPConflict,
    HTTPUnprocessableEntity,
    HTTPInternalServerError,
    NO_PERMISSION_REQUIRED,
)
from magpie.constants import get_constant
from magpie.permissions import Permission
from magpie.utils import get_magpie_url, CONTENT_TYPE_JSON, CONTENT_TYPE_HTML
# from magpie.security import get_provider_names
from magpie import __meta__
import six


[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]LoginTag = "Login"
[docs]UsersTag = "User"
[docs]LoggedUserTag = "Logged User"
[docs]GroupsTag = "Group"
[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]SecurityAdministratorAPI = [{"cookieAuth": []}]
[docs]SecurityEveryoneAPI = [{}]
[docs]def get_security(service, method): definitions = service.definitions args = {} for definition in definitions: met, view, 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 elif 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): return {"name": service_api.name, "pattern": service_api.path}
[docs]LoggedUserBase = "/users/{}".format(get_constant("MAGPIE_LOGGED_USER"))
[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]UserInheritedResourcesAPI = Service( path="/users/{user_name}/inherited_resources", name="UserInheritedResources")
[docs]UserResourcesAPI = Service( path="/users/{user_name}/resources", name="UserResources")
[docs]UserResourceInheritedPermissionsAPI = Service( path="/users/{user_name}/resources/{resource_id}/inherited_permissions", name="UserResourceInheritedPermissions")
[docs]UserResourcePermissionAPI = Service( path="/users/{user_name}/resources/{resource_id}/permissions/{permission_name}", name="UserResourcePermission")
[docs]UserResourcePermissionsAPI = Service( path="/users/{user_name}/resources/{resource_id}/permissions", name="UserResourcePermissions")
[docs]UserResourceTypesAPI = Service( path="/users/{user_name}/resources/types/{resource_type}", name="UserResourceTypes")
[docs]UserInheritedServicesAPI = Service( path="/users/{user_name}/inherited_services", name="UserInheritedServices")
[docs]UserServicesAPI = Service( path="/users/{user_name}/services", name="UserServices")
[docs]UserServiceAPI = Service( path="/users/{user_name}/services/{service_name}", name="UserService")
[docs]UserServiceInheritedResourcesAPI = Service( path="/users/{user_name}/services/{service_name}/inherited_resources", name="UserServiceInheritedResources")
[docs]UserServiceResourcesAPI = Service( path="/users/{user_name}/services/{service_name}/resources", name="UserServiceResources")
[docs]UserServiceInheritedPermissionsAPI = Service( path="/users/{user_name}/services/{service_name}/inherited_permissions", name="UserServiceInheritedPermissions")
[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]LoggedUserInheritedResourcesAPI = Service( path=LoggedUserBase + "/inherited_resources", name="LoggedUserInheritedResources")
[docs]LoggedUserResourcesAPI = Service( path=LoggedUserBase + "/resources", name="LoggedUserResources")
[docs]LoggedUserResourceInheritedPermissionsAPI = Service( path=LoggedUserBase + "/resources/{resource_id}/inherited_permissions", name="LoggedUserResourceInheritedPermissions")
[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]LoggedUserInheritedServicesAPI = Service( path=LoggedUserBase + "/inherited_services", name="LoggedUserInheritedServices")
[docs]LoggedUserServicesAPI = Service( path=LoggedUserBase + "/services", name="LoggedUserServices")
[docs]LoggedUserServiceInheritedResourcesAPI = Service( path=LoggedUserBase + "/services/{service_name}/inherited_resources", name="LoggedUserServiceInheritedResources")
[docs]LoggedUserServiceResourcesAPI = Service( path=LoggedUserBase + "/services/{service_name}/resources", name="LoggedUserServiceResources")
[docs]LoggedUserServiceInheritedPermissionsAPI = Service( path=LoggedUserBase + "/services/{service_name}/inherited_permissions", name="LoggedUserServiceInheritedPermissions")
[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]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")
# 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 HeaderResponseSchema(colander.MappingSchema):
[docs] content_type = colander.SchemaNode( colander.String(), default=CONTENT_TYPE_JSON, example=CONTENT_TYPE_JSON, description="Content type of the response body.",
)
[docs] content_type.name = "Content-Type"
[docs]class HeaderRequestSchemaAPI(colander.MappingSchema):
[docs] content_type = colander.SchemaNode( colander.String(), default=CONTENT_TYPE_JSON, example=CONTENT_TYPE_JSON, missing=colander.drop,
)
[docs] content_type.name = "Content-Type"
[docs]class HeaderRequestSchemaUI(colander.MappingSchema):
[docs] content_type = colander.SchemaNode( colander.String(), default=CONTENT_TYPE_HTML, example=CONTENT_TYPE_HTML, missing=colander.drop,
)
[docs] content_type.name = "Content-Type"
[docs]QueryEffectivePermissions = colander.SchemaNode( colander.Boolean(), default=False, missing=colander.drop, description="User groups effective permissions resolved with corresponding service inheritance functionality. "
"(Note: group inheritance is enforced regardless of any 'inherit' flag).")
[docs]QueryInheritGroupsPermissions = colander.SchemaNode( colander.Boolean(), default=False, missing=colander.drop, description="User groups memberships inheritance to resolve service resource permissions.")
[docs]QueryCascadeResourcesPermissions = colander.SchemaNode( colander.Boolean(), default=False, missing=colander.drop, description="Display any service that has at least one sub-resource user permission, "
"or only services that have user permissions directly set on them.", )
[docs]class BaseResponseBodySchema(colander.MappingSchema): def __init__(self, code, description, **kw): super(BaseResponseBodySchema, self).__init__(**kw) assert isinstance(code, int) assert isinstance(description, six.string_types) 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 ErrorVerifyParamBodySchema(colander.MappingSchema):
[docs] name = colander.SchemaNode( colander.String(), description="Name of the failing condition parameter.", missing=colander.drop)
[docs] value = colander.SchemaNode( colander.String(), description="Value of the failing condition parameter.")
[docs] compare = colander.SchemaNode( colander.String(), description="Test comparison value of the failing condition parameter.", missing=colander.drop)
[docs]class ErrorResponseBodySchema(BaseResponseBodySchema): def __init__(self, code, description, **kw): super(ErrorResponseBodySchema, self).__init__(code, description, **kw) assert code >= 400
[docs] route_name = colander.SchemaNode( colander.String(), description="Route called that generated the error.", example="/users/toto")
[docs] request_url = colander.SchemaNode( colander.String(), 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]class InternalServerErrorResponseBodySchema(ErrorResponseBodySchema): def __init__(self, **kw): kw["code"] = HTTPInternalServerError.code super(InternalServerErrorResponseBodySchema, self).__init__(**kw)
[docs]class UnauthorizedResponseBodySchema(BaseResponseBodySchema): def __init__(self, **kw): kw["code"] = HTTPUnauthorized.code super(UnauthorizedResponseBodySchema, self).__init__(**kw)
[docs] route_name = colander.SchemaNode(colander.String(), description="Specified route")
[docs] request_url = colander.SchemaNode(colander.String(), description="Specified url")
[docs]class UnauthorizedResponseSchema(colander.MappingSchema):
[docs] description = "Unauthorized access to this resource. " + \ "Insufficient user privileges or missing authentication headers."
[docs] header = HeaderResponseSchema()
[docs] body = UnauthorizedResponseBodySchema(code=HTTPUnauthorized.code, description=description)
[docs]class HTTPForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Forbidden operation under this resource."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "The route resource could not be found."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class MethodNotAllowedResponseSchema(colander.MappingSchema):
[docs] description = "The method is not allowed for this resource."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPMethodNotAllowed.code, description=description)
[docs]class NotAcceptableResponseSchema(colander.MappingSchema):
[docs] description = "Unsupported 'Accept Header' was specified."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPNotAcceptable.code, description=description)
[docs]class UnprocessableEntityResponseSchema(colander.MappingSchema):
[docs] description = "Invalid value specified."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPUnprocessableEntity.code, description=description)
[docs]class InternalServerErrorResponseSchema(colander.MappingSchema):
[docs] description = "Internal Server Error. Unhandled exception occurred."
[docs] header = HeaderResponseSchema()
[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 GroupBodySchema(colander.MappingSchema):
[docs] group_name = colander.SchemaNode( colander.String(), description="Name of the group.", example="Administrators")
[docs] group_id = colander.SchemaNode( colander.Integer(), description="ID of the group.", example=1)
[docs]class GroupDetailBodySchema(GroupBodySchema):
[docs] description = colander.SchemaNode( colander.String(), description="Description associated to the group.", example="", missing=colander.drop)
[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]class ServiceBodySchema(colander.MappingSchema):
[docs] resource_id = colander.SchemaNode( colander.Integer(), description="Resource identification number",
)
[docs] permission_names = PermissionListSchema( 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])
[docs] permission_names.default = colander.null # if no parent
[docs] permission_names.missing = colander.drop # if not returned (basic_info = True)
# TODO: improve by making recursive resources work (?)
[docs]class Resource_ChildrenContainerWithoutChildResourceBodySchema(ResourceBodySchema):
[docs] children = colander.MappingSchema(default={})
[docs]class Resource_ChildResourceWithoutChildrenBodySchema(colander.MappingSchema):
[docs] id = Resource_ChildrenContainerWithoutChildResourceBodySchema()
[docs] id.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()
[docs] id.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()
[docs] geoserver_api.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()
[docs] geoserver_api.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(colander.MappingSchema):
[docs] description = "Resource query by id refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Resource_MatchDictCheck_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Resource ID not found in db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class Resource_MatchDictCheck_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Resource ID is an invalid literal for 'int' type."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Resource_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource = Resource_ParentResourceWithChildrenContainerBodySchema()
[docs]class Resource_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get resource successful."
[docs] header = HeaderResponseSchema()
[docs] body = Resource_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Resource_GET_InternalServerErrorResponseSchema(colander.MappingSchema):
[docs] description = "Failed building resource children json formatted tree."
[docs] header = HeaderResponseSchema()
[docs] body = InternalServerErrorResponseBodySchema(code=HTTPInternalServerError.code, description=description)
[docs]class Resource_PUT_RequestBodySchema(colander.MappingSchema):
[docs] resource_name = colander.SchemaNode( colander.String(), description="New name to apply to the resource to update",
)
[docs] service_push = colander.SchemaNode( colander.Boolean(), description="Push service resource update to Phoenix", missing=False,
)
[docs]class Resource_PUT_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = Resource_PUT_RequestBodySchema()
[docs] resource_id = ResourceIdParameter
[docs]class Resource_PUT_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_PUT_OkResponseSchema(colander.MappingSchema):
[docs] description = "Update resource successful."
[docs] header = HeaderResponseSchema()
[docs] body = Resource_PUT_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Resource_PUT_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Failed to update resource with new name."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Resource_DELETE_RequestBodySchema(colander.MappingSchema):
[docs] service_push = colander.SchemaNode( colander.Boolean(), description="Push service update to Phoenix if applicable", missing=colander.drop, default=False,
)
[docs]class Resource_DELETE_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = Resource_DELETE_RequestBodySchema()
[docs] resource_id = ResourceIdParameter
[docs]class Resource_DELETE_OkResponseSchema(colander.MappingSchema):
[docs] description = "Delete resource successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Resource_DELETE_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Delete resource from db failed."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Resources_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get resources successful."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = Resources_POST_RequestBodySchema()
[docs]class Resource_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource = Resource_ChildResourceWithChildrenContainerBodySchema()
[docs]class Resources_POST_CreatedResponseSchema(colander.MappingSchema):
[docs] description = "Create resource successful."
[docs] header = HeaderResponseSchema()
[docs] body = Resource_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs]class Resources_POST_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid ['resource_name'|'resource_type'|'parent_id'] specified for child resource creation."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Resources_POST_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Failed to insert new resource in service tree using parent id."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Resources_POST_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Could not find specified resource parent id."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class Resources_POST_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "Resource name already exists at requested tree level for creation."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPConflict.code, description=description)
[docs]class ResourcePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionListSchema(example=[Permission.READ.value, Permission.WRITE.value])
[docs]class ResourcePermissions_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get resource permissions successful."
[docs] header = HeaderResponseSchema()
[docs] body = ResourcePermissions_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class ResourcePermissions_GET_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid resource type to extract permissions."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class ServiceResourcesBodySchema(ServiceBodySchema):
[docs] children = ResourcesSchemaNode()
[docs]class ServiceType_access_SchemaNode(colander.MappingSchema):
[docs] frontend = ServiceBodySchema(missing=colander.drop)
[docs] geoserver_web = ServiceBodySchema(missing=colander.drop)
[docs] geoserver_web.name = "geoserver-web"
[docs] magpie = ServiceBodySchema(missing=colander.drop)
[docs]class ServiceType_geoserverapi_SchemaNode(colander.MappingSchema):
[docs] geoserver_api = ServiceBodySchema(missing=colander.drop)
[docs] geoserver_api.name = "geoserver-api"
[docs]class ServiceType_geoserverwms_SchemaNode(colander.MappingSchema):
[docs] geoserverwms = ServiceBodySchema(missing=colander.drop)
[docs]class ServiceType_ncwms_SchemaNode(colander.MappingSchema):
[docs] ncwms = ServiceBodySchema(missing=colander.drop)
[docs] ncwms.name = "ncWMS2"
[docs]class ServiceType_projectapi_SchemaNode(colander.MappingSchema):
[docs] project_api = ServiceBodySchema(missing=colander.drop)
[docs] project_api.name = "project-api"
[docs]class ServiceType_thredds_SchemaNode(colander.MappingSchema):
[docs] thredds = ServiceBodySchema(missing=colander.drop)
[docs]class ServiceType_wfs_SchemaNode(colander.MappingSchema):
[docs] geoserver = ServiceBodySchema(missing=colander.drop)
[docs]class ServiceType_wps_SchemaNode(colander.MappingSchema):
[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 ServiceTypes_GET_OkResponseBodySchema(BaseResponseBodySchema):
[docs] service_types = ServiceTypesList(description="List of available service types.")
[docs]class ServiceTypes_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get service types successful."
[docs] header = HeaderResponseSchema()
[docs] body = ServiceTypes_GET_OkResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class ServicesSchemaNode(colander.MappingSchema):
[docs] access = ServiceType_access_SchemaNode()
[docs] geoserver_api = ServiceType_geoserverapi_SchemaNode(missing=colander.drop)
[docs] geoserver_api.name = "geoserver-api"
[docs] geoserverwms = ServiceType_geoserverwms_SchemaNode(missing=colander.drop)
[docs] ncwms = ServiceType_ncwms_SchemaNode()
[docs] project_api = ServiceType_projectapi_SchemaNode(missing=colander.drop)
project_api.name = "project-api"
[docs] thredds = ServiceType_thredds_SchemaNode()
[docs] wfs = ServiceType_wfs_SchemaNode(missing=colander.drop)
[docs] wps = ServiceType_wps_SchemaNode(missing=colander.drop)
[docs]class Service_FailureBodyResponseSchema(BaseResponseBodySchema):
[docs] service_name = colander.SchemaNode( colander.String(), description="Service name extracted from path"
)
[docs]class Service_MatchDictCheck_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Service query by name refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Service_MatchDictCheck_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Service name not found in db."
[docs] header = HeaderResponseSchema()
[docs] body = Service_FailureBodyResponseSchema(code=HTTPNotFound.code, description=description)
[docs]class Service_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] service = ServiceBodySchema()
[docs]class Service_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get service successful."
[docs] header = HeaderResponseSchema()
[docs] body = Service_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Services_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] services = ServicesSchemaNode()
[docs]class Services_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get services successful."
[docs] header = HeaderResponseSchema()
[docs] body = Services_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Services_GET_BadRequestResponseBodySchema(BaseResponseBodySchema):
[docs] service_type = colander.SchemaNode( colander.String(), description="Name of the service type filter employed when applicable", missing=colander.drop)
[docs]class Services_GET_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'service_type' value does not correspond to any of the existing service types."
[docs] header = HeaderResponseSchema()
[docs] body = Services_GET_BadRequestResponseBodySchema(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(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = Services_POST_BodySchema()
[docs]class Services_POST_CreatedResponseSchema(colander.MappingSchema):
[docs] description = "Service registration to db successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Services_POST_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'service_type' value does not correspond to any of the existing service types."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Services_POST_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Service registration forbidden by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Services_POST_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "Specified 'service_name' value already exists."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPConflict.code, description=description)
[docs]class Services_POST_UnprocessableEntityResponseSchema(colander.MappingSchema):
[docs] description = "Service creation for registration failed."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPUnprocessableEntity.code, description=description)
[docs]class Services_POST_InternalServerErrorResponseSchema(colander.MappingSchema):
[docs] description = "Service registration status could not be validated."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPInternalServerError.code, description=description)
[docs]class Service_PUT_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 = colander.SchemaNode( colander.Boolean(), description="Push service update to Phoenix if applicable", missing=colander.drop, default=False,
)
[docs]class Service_PUT_RequestBodySchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = Service_PUT_ResponseBodySchema()
[docs]class Service_SuccessBodyResponseSchema(BaseResponseBodySchema):
[docs] service = ServiceBodySchema()
[docs]class Service_PUT_OkResponseSchema(colander.MappingSchema):
[docs] description = "Update service successful."
[docs] header = HeaderResponseSchema()
[docs] body = Service_SuccessBodyResponseSchema(code=HTTPOk.code, description=description)
[docs]class Service_PUT_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Registered service values are already equal to update values."
[docs] header = HeaderResponseSchema()
[docs] body = Service_FailureBodyResponseSchema(code=HTTPBadRequest.code, description=description)
[docs]class Service_PUT_BadRequestResponseSchema_ReservedKeyword(colander.MappingSchema):
[docs] description = "Update service name to 'types' not allowed (reserved keyword)."
[docs] header = HeaderResponseSchema()
[docs] body = Service_FailureBodyResponseSchema(code=HTTPBadRequest.code, description=description)
[docs]class Service_PUT_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Update service failed during value assignment."
[docs] header = HeaderResponseSchema()
[docs] body = Service_FailureBodyResponseSchema(code=HTTPForbidden.code, description=description)
[docs]class Service_PUT_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "Specified 'service_name' already exists."
[docs] header = HeaderResponseSchema()
[docs] body = Service_FailureBodyResponseSchema(code=HTTPConflict.code, description=description)
[docs]class Service_DELETE_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = Resource_DELETE_RequestBodySchema()
[docs] service_name = ServiceNameParameter
[docs]class Service_DELETE_OkResponseSchema(colander.MappingSchema):
[docs] description = "Delete service successful."
[docs] header = HeaderResponseSchema()
[docs] body = ServiceBodySchema(code=HTTPOk.code, description=description)
[docs]class Service_DELETE_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Delete service from db refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = Service_FailureBodyResponseSchema(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(colander.MappingSchema):
[docs] description = "Get service permissions successful."
[docs] header = HeaderResponseSchema()
[docs] body = ServicePermissions_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class ServicePermissions_GET_BadRequestResponseBodySchema(BaseResponseBodySchema):
[docs] service = ServiceBodySchema()
[docs]class ServicePermissions_GET_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid service type specified by service."
[docs] header = HeaderResponseSchema()
[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_BadRequestResponseSchema = Resources_POST_BadRequestResponseSchema
[docs]ServiceResources_POST_ForbiddenResponseSchema = Resources_POST_ForbiddenResponseSchema
[docs]ServiceResources_POST_NotFoundResponseSchema = Resources_POST_NotFoundResponseSchema
[docs]ServiceResources_POST_ConflictResponseSchema = Resources_POST_ConflictResponseSchema
# 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()
[docs] service_name.name = '{service_name}'
[docs]class ServiceResources_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get service resources successful."
[docs] header = HeaderResponseSchema()
[docs] body = ServiceResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class ServiceTypeResourceTypes_GET_FailureBodyResponseSchema(BaseResponseBodySchema):
[docs] service_type = colander.SchemaNode(colander.String(), description="Service type retrieved from route path.")
[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(colander.MappingSchema):
[docs] description = "Get service type resources successful."
[docs] header = HeaderResponseSchema()
[docs] body = ServiceTypeResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class ServiceTypeResources_GET_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Failed to obtain resource types for specified service type."
[docs] header = HeaderResponseSchema()
[docs] body = ServiceTypeResourceTypes_GET_FailureBodyResponseSchema(code=HTTPForbidden.code, description=description)
[docs]class ServiceTypeResources_GET_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'service_type' does not exist to obtain its resource types."
[docs] header = HeaderResponseSchema()
[docs] body = ServiceTypeResourceTypes_GET_FailureBodyResponseSchema(code=HTTPNotFound.code, description=description)
[docs]class ServiceTypeResourceTypes_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] resource_types = ResourceTypesListSchema()
[docs]class ServiceTypeResourceTypes_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get service type resource types successful."
[docs] header = HeaderResponseSchema()
[docs] body = ServiceTypeResourceTypes_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class ServiceTypeResourceTypes_GET_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Failed to obtain resource types for specified service type."
[docs] header = HeaderResponseSchema()
[docs] body = ServiceTypeResourceTypes_GET_FailureBodyResponseSchema(code=HTTPForbidden.code, description=description)
[docs]class ServiceTypeResourceTypes_GET_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'service_type' does not exist to obtain its resource types."
[docs] header = HeaderResponseSchema()
[docs] body = ServiceTypeResourceTypes_GET_FailureBodyResponseSchema(code=HTTPNotFound.code, description=description)
[docs]class Users_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] user_names = UserNamesListSchema()
[docs]class Users_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get users successful."
[docs] header = HeaderResponseSchema()
[docs] body = Users_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Users_GET_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Get users query refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Users_CheckInfo_ResponseBodySchema(BaseResponseBodySchema):
[docs] param = ErrorVerifyParamBodySchema()
[docs]class Users_CheckInfo_Name_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'user_name' value specified."
[docs] header = HeaderResponseSchema()
[docs] body = Users_CheckInfo_ResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Users_CheckInfo_Size_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'user_name' length specified (>{length} characters)." \ .format(length=get_constant('MAGPIE_USER_NAME_MAX_LENGTH'))
[docs] header = HeaderResponseSchema()
[docs] body = Users_CheckInfo_ResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Users_CheckInfo_Email_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'email' value specified."
[docs] header = HeaderResponseSchema()
[docs] body = Users_CheckInfo_ResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Users_CheckInfo_Password_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'password' value specified."
[docs] header = HeaderResponseSchema()
[docs] body = Users_CheckInfo_ResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Users_CheckInfo_GroupName_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'group_name' value specified."
[docs] header = HeaderResponseSchema()
[docs] body = Users_CheckInfo_ResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Users_CheckInfo_ReservedKeyword_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'user_name' not allowed (reserved keyword)."
[docs] header = HeaderResponseSchema()
[docs] body = Users_CheckInfo_ResponseBodySchema(code=HTTPConflict.code, description=description)
[docs]class User_Check_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "User check query was refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class User_Check_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "User name matches an already existing user name."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.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(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = User_POST_RequestBodySchema()
[docs]class Users_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] user = UserBodySchema()
[docs]class Users_POST_CreatedResponseSchema(colander.MappingSchema):
[docs] description = "Add user to db successful."
[docs] header = HeaderResponseSchema()
[docs] body = Users_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs]class Users_POST_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Failed to add user to db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class UserNew_POST_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "New user query was refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class User_PUT_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_PUT_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = User_PUT_RequestBodySchema()
[docs]class Users_PUT_OkResponseSchema(colander.MappingSchema):
[docs] description = "Update user successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class User_PUT_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Missing new user parameters to update."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class User_PUT_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Failed user verification with db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class User_PUT_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "New name user already exists."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPConflict.code, description=description)
[docs]class User_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] user = UserBodySchema()
[docs]class User_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get user successful."
[docs] header = HeaderResponseSchema()
[docs] body = User_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class User_CheckAnonymous_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Anonymous user query refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class User_CheckAnonymous_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Anonymous user not found in db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class User_GET_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "User name query refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class User_GET_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "User name not found in db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class User_DELETE_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = colander.MappingSchema(default={})
[docs]class User_DELETE_OkResponseSchema(colander.MappingSchema):
[docs] description = "Delete user successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class User_DELETE_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Delete user by name refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class UserGroup_Check_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Group for new user doesn't exist."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class UserGroup_GET_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Group query was refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class UserGroup_Check_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Failed to add user-group to db."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class UserGroups_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] group_names = GroupNamesListSchema()
[docs]class UserGroups_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get user groups successful."
[docs] header = HeaderResponseSchema()
[docs] body = UserGroups_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class UserGroups_POST_RequestBodySchema(colander.MappingSchema):
[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_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[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(colander.MappingSchema):
[docs] description = "Create user-group assignation successful."
[docs] header = HeaderResponseSchema()
[docs] body = UserGroups_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs]class UserGroups_POST_GroupNotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Can't find the group to assign to."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class UserGroups_POST_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Group query by name refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class UserGroups_POST_RelationshipForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "User-Group relationship creation refused by db."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] description = "User already belongs to this group."
[docs] header = HeaderResponseSchema()
[docs] body = UserGroups_POST_ConflictResponseBodySchema(code=HTTPConflict.code, description=description)
[docs]class UserGroup_DELETE_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = colander.MappingSchema(default={})
[docs]class UserGroup_DELETE_OkResponseSchema(colander.MappingSchema):
[docs] description = "Delete user-group successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class UserGroup_DELETE_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Invalid user-group combination for delete."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class UserResources_GET_QuerySchema(colander.MappingSchema):
[docs] inherit = QueryInheritGroupsPermissions
[docs]class UserResources_GET_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] querystring = UserResources_GET_QuerySchema()
[docs]class UserResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] resources = ResourcesSchemaNode()
[docs]class UserResources_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get user resources successful."
[docs] header = HeaderResponseSchema()
[docs] body = UserResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class UserResources_GET_NotFoundResponseBodySchema(BaseResponseBodySchema):
[docs] user_name = colander.SchemaNode(colander.String(), description="User name value read from path")
[docs] resource_types = ResourceTypesListSchema(description="Resource types searched for")
[docs]class UserResources_GET_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Failed to populate user resources."
[docs] header = HeaderResponseSchema()
[docs] body = UserResources_GET_NotFoundResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class UserResourcePermissions_GET_QuerySchema(colander.MappingSchema):
[docs] inherit = QueryInheritGroupsPermissions
[docs] effective = QueryEffectivePermissions
[docs]class UserResourcePermissions_GET_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] querystring = UserResourcePermissions_GET_QuerySchema()
[docs]class UserResourcePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionListSchema(example=[Permission.READ.value, Permission.WRITE.value])
[docs]class UserResourcePermissions_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get user resource permissions successful."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] description = "Invalid 'resource' specified for resource permission retrieval."
[docs] header = HeaderResponseSchema()
[docs] body = UserResourcePermissions_GET_BadRequestResponseBodySchema( code=HTTPBadRequest.code, description=description)
[docs]class UserResourcePermissions_GET_BadRequestResourceResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'resource' specified for resource permission retrieval."
[docs] header = HeaderResponseSchema()
[docs] body = UserResourcePermissions_GET_BadRequestResponseBodySchema( code=HTTPBadRequest.code, description=description)
[docs]class UserResourcePermissions_GET_BadRequestResourceTypeResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'resource_type' for corresponding service resource permission retrieval."
[docs] header = HeaderResponseSchema()
[docs] body = UserResourcePermissions_GET_BadRequestResponseBodySchema( code=HTTPBadRequest.code, description=description)
[docs]class UserResourcePermissions_GET_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Specified user not found to obtain resource permissions."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[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(colander.MappingSchema):
[docs] description = "Create user resource permission successful."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] description = "Permission not allowed for specified 'resource_type'."
[docs] header = HeaderResponseSchema()
[docs] body = UserResourcePermissions_POST_BadResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class UserResourcePermissions_POST_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Creation of permission on resource for user refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = UserResourcePermissions_POST_BadResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class UserResourcePermissions_POST_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "Permission already exist on resource for user."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = colander.MappingSchema(default={})
[docs] user_name = UserNameParameter
[docs] resource_id = ResourceIdParameter
[docs] permission_name = PermissionNameParameter
[docs]class UserResourcePermissions_DELETE_OkResponseSchema(colander.MappingSchema):
[docs] description = "Delete user resource permission successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class UserResourcePermissions_DELETE_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Could not find user resource permission to delete from db."
[docs] header = HeaderResponseSchema()
[docs] body = UserResourcePermissions_DELETE_BadResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class UserServiceResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] service = ServiceResourcesBodySchema()
[docs]class UserServiceResources_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get user service resources successful."
[docs] header = HeaderResponseSchema()
[docs] body = UserServiceResources_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class UserServiceResources_GET_QuerySchema(colander.MappingSchema):
[docs] inherit = QueryInheritGroupsPermissions
[docs]class UserServiceResources_GET_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[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(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = UserServicePermissions_POST_RequestBodySchema()
[docs] user_name = UserNameParameter
[docs] service_name = ServiceNameParameter
[docs]class UserServicePermission_DELETE_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = colander.MappingSchema(default={})
[docs] user_name = UserNameParameter
[docs] service_name = ServiceNameParameter
[docs] permission_name = PermissionNameParameter
[docs]class UserServices_GET_QuerySchema(colander.MappingSchema):
[docs] cascade = QueryCascadeResourcesPermissions
[docs] inherit = QueryInheritGroupsPermissions
[docs] list = colander.SchemaNode( colander.Boolean(), default=False, missing=colander.drop, description='Return services as a list of dicts. Default is a dict by service type, and by service name.')
[docs]class UserServices_GET_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] querystring = UserServices_GET_QuerySchema()
[docs] user_name = UserNameParameter
[docs]class UserServices_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] services = ServicesSchemaNode()
[docs]class UserServices_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get user services successful."
[docs] header = HeaderResponseSchema()
[docs] body = UserServices_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class UserServicePermissions_GET_QuerySchema(colander.MappingSchema):
[docs] inherit = QueryInheritGroupsPermissions
[docs]class UserServicePermissions_GET_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] querystring = UserServicePermissions_GET_QuerySchema()
[docs] user_name = UserNameParameter
[docs] service_name = ServiceNameParameter
[docs]class UserServicePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionListSchema(example=[Permission.READ.value, Permission.WRITE.value])
[docs]class UserServicePermissions_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get user service permissions successful."
[docs] header = HeaderResponseSchema()
[docs] body = UserServicePermissions_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class UserServicePermissions_GET_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Could not find permissions using specified 'service_name' and 'user_name'."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class Group_MatchDictCheck_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Group query by name refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Group_MatchDictCheck_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Group name not found in db."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class Groups_CheckInfo_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "User name not found in db."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class Groups_CheckInfo_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Failed to obtain groups of user."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Groups_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] group_names = GroupNamesListSchema()
[docs]class Groups_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get groups successful."
[docs] header = HeaderResponseSchema()
[docs] body = Groups_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Groups_GET_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Obtain group names refused by db."
[docs] header = HeaderResponseSchema()
[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]class Groups_POST_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = Groups_POST_RequestBodySchema()
[docs]class Groups_POST_ResponseBodySchema(BaseResponseBodySchema):
[docs] group = GroupBodySchema()
[docs]class Groups_POST_CreatedResponseSchema(colander.MappingSchema):
[docs] description = "Create group successful."
[docs] header = HeaderResponseSchema()
[docs] body = Groups_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs]class Groups_POST_ForbiddenCreateResponseSchema(colander.MappingSchema):
[docs] description = "Create new group by name refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = Groups_POST_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Groups_POST_ForbiddenAddResponseSchema(colander.MappingSchema):
[docs] description = "Add new group by name refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = Groups_POST_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Groups_POST_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "Group name matches an already existing group name."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs]class Group_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] group = GroupDetailBodySchema()
[docs]class Group_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get group successful."
[docs] header = HeaderResponseSchema()
[docs] body = Group_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Group_GET_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Group name was not found."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class Group_PUT_RequestBodySchema(colander.MappingSchema):
[docs] group_name = colander.SchemaNode(colander.String(), description="New name to apply to the group.")
[docs]class Group_PUT_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = Group_PUT_RequestBodySchema()
[docs] group_name = GroupNameParameter
[docs]class Group_PUT_OkResponseSchema(colander.MappingSchema):
[docs] description = "Update group successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Group_PUT_Name_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'group_name' value specified."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Group_PUT_Size_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'group_name' length specified (>{length} characters)." \ .format(length=get_constant('MAGPIE_USER_NAME_MAX_LENGTH'))
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Group_PUT_Same_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Invalid 'group_name' must be different than current name."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Group_PUT_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "Group name already exists."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPConflict.code, description=description)
[docs]class Group_DELETE_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = colander.MappingSchema(default={})
[docs] group_name = GroupNameParameter
[docs]class Group_DELETE_OkResponseSchema(colander.MappingSchema):
[docs] description = "Delete group successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Group_DELETE_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Delete group forbidden by db."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class GroupUsers_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] user_names = UserNamesListSchema()
[docs]class GroupUsers_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get group users successful."
[docs] header = HeaderResponseSchema()
[docs] body = GroupUsers_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class GroupUsers_GET_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Failed to obtain group user names from db."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class GroupServices_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] services = ServicesSchemaNode()
[docs]class GroupServices_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get group services successful."
[docs] header = HeaderResponseSchema()
[docs] body = GroupServices_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class GroupServices_InternalServerErrorResponseBodySchema(InternalServerErrorResponseBodySchema):
[docs] group = GroupBodySchema()
[docs]class GroupServices_InternalServerErrorResponseSchema(colander.MappingSchema):
[docs] description = "Failed to populate group services."
[docs] header = HeaderResponseSchema()
[docs] body = GroupServices_InternalServerErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description)
[docs]class GroupServicePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permission_names = PermissionListSchema(example=[Permission.READ.value, Permission.WRITE.value])
[docs]class GroupServicePermissions_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get group service permissions successful."
[docs] header = HeaderResponseSchema()
[docs] body = GroupServicePermissions_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class GroupServicePermissions_GET_InternalServerErrorResponseBodySchema(InternalServerErrorResponseBodySchema):
[docs] group = GroupBodySchema()
[docs] service = ServiceBodySchema()
[docs]class GroupServicePermissions_GET_InternalServerErrorResponseSchema(colander.MappingSchema):
[docs] description = "Failed to extract permissions names from group-service."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = GroupServicePermissions_POST_RequestBodySchema()
[docs] group_name = GroupNameParameter
[docs] service_name = ServiceNameParameter
[docs]class GroupResourcePermissions_POST_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[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 = GroupBodySchema()
[docs]class GroupResourcePermissions_POST_CreatedResponseSchema(colander.MappingSchema):
[docs] description = "Create group resource permission successful."
[docs] header = HeaderResponseSchema()
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPCreated.code, description=description)
[docs]class GroupResourcePermissions_POST_ForbiddenAddResponseSchema(colander.MappingSchema):
[docs] description = "Add group resource permission refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class GroupResourcePermissions_POST_ForbiddenCreateResponseSchema(colander.MappingSchema):
[docs] description = "Create group resource permission failed."
[docs] header = HeaderResponseSchema()
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class GroupResourcePermissions_POST_ForbiddenGetResponseSchema(colander.MappingSchema):
[docs] description = "Get group resource permission failed."
[docs] header = HeaderResponseSchema()
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class GroupResourcePermissions_POST_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "Group resource permission already exists."
[docs] header = HeaderResponseSchema()
[docs] body = GroupResourcePermissions_POST_ResponseBodySchema(code=HTTPConflict.code, description=description)
[docs]class GroupResourcePermission_DELETE_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[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(colander.MappingSchema):
[docs] description = "Failed to build group resources json tree."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] description = "Failed to obtain group resource permissions."
[docs] header = HeaderResponseSchema()
[docs] body = GroupResourcePermissions_InternalServerErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description)
[docs]class GroupResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] resources = ResourcesSchemaNode()
[docs]class GroupResources_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get group resources successful."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] description = "Failed to build group resources json tree."
[docs] header = HeaderResponseSchema()
[docs] body = GroupResources_GET_InternalServerErrorResponseBodySchema( code=HTTPInternalServerError.code, description=description)
[docs]class GroupResourcePermissions_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] permissions_names = PermissionListSchema(example=[Permission.READ.value, Permission.WRITE.value])
[docs]class GroupResourcePermissions_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get group resource permissions successful."
[docs] header = HeaderResponseSchema()
[docs] body = GroupResourcePermissions_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class GroupServiceResources_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] service = ServiceResourcesBodySchema()
[docs]class GroupServiceResources_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get group service resources successful."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[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 = GroupBodySchema()
[docs]class GroupServicePermission_DELETE_OkResponseSchema(colander.MappingSchema):
[docs] description = "Delete group resource permission successful."
[docs] header = HeaderResponseSchema()
[docs] body = GroupServicePermission_DELETE_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class GroupServicePermission_DELETE_ForbiddenGetResponseSchema(colander.MappingSchema):
[docs] description = "Get group resource permission failed."
[docs] header = HeaderResponseSchema()
[docs] body = GroupServicePermission_DELETE_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class GroupServicePermission_DELETE_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Delete group resource permission refused by db."
[docs] header = HeaderResponseSchema()
[docs] body = GroupServicePermission_DELETE_ResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Signout_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Sign out successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class GroupServicePermission_DELETE_NotFoundResponseSchema(colander.MappingSchema):
[docs] description = "Permission not found for corresponding group and resource."
[docs] header = HeaderResponseSchema()
[docs] body = GroupServicePermission_DELETE_ResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class Session_GET_ResponseBodySchema(BaseResponseBodySchema):
[docs] user = UserBodySchema(missing=colander.drop)
[docs] authenticated = colander.SchemaNode( colander.Boolean(), description="Indicates if any user session is currently authenticated (user logged in).")
[docs]class Session_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get session successful."
[docs] header = HeaderResponseSchema()
[docs] body = Session_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Session_GET_InternalServerErrorResponseSchema(colander.MappingSchema):
[docs] description = "Failed to get session details."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] description = "Get providers successful."
[docs] header = HeaderResponseSchema()
[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', description="Alternative redirection homepage after signin. "
"Must be a relative path to Magpie for security reasons.")
[docs] HomepageRoute.name = "Homepage-Route"
[docs]class ProviderSignin_GET_RequestSchema(colander.MappingSchema):
[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(colander.MappingSchema):
[docs] description = "External login homepage route found. Temporary status before redirection to 'Homepage-Route' header."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] description = "Incorrectly formed 'Authorization: Bearer <access_token>' header."
[docs] header = HeaderResponseSchema()
[docs] body = ProviderSignin_GET_BadRequestResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class ProviderSignin_GET_UnauthorizedResponseSchema(colander.MappingSchema):
[docs] description = "Unauthorized 'UserInfo' update using provided Authorization headers."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPUnauthorized.code, description=description)
[docs]class ProviderSignin_GET_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Forbidden 'Homepage-Route' host not matching Magpie refused for security reasons."
[docs] header = HeaderResponseSchema()
[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(colander.MappingSchema):
[docs] description = "Invalid 'provider_name' not found within available providers."
[docs] header = HeaderResponseSchema()
[docs] body = ProviderSignin_GET_NotFoundResponseBodySchema(code=HTTPNotFound.code, description=description)
[docs]class Signin_POST_RequestBodySchema(colander.MappingSchema):
[docs] user_name = colander.SchemaNode(colander.String(), description="User name to use for sign in.")
[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.", default=get_constant('MAGPIE_DEFAULT_PROVIDER'), missing=colander.drop)
[docs]class Signin_POST_RequestSchema(colander.MappingSchema):
[docs] header = HeaderRequestSchemaAPI()
[docs] body = Signin_POST_RequestBodySchema()
[docs]class Signin_POST_OkResponseSchema(colander.MappingSchema):
[docs] description = "Login successful."
[docs] header = HeaderResponseSchema()
[docs] body = BaseResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Signin_POST_BadRequestResponseSchema(colander.MappingSchema):
[docs] description = "Missing credentials."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPBadRequest.code, description=description)
[docs]class Signin_POST_UnauthorizedResponseSchema(colander.MappingSchema):
[docs] description = "Incorrect credentials."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPUnauthorized.code, description=description)
[docs]class Signin_POST_ForbiddenResponseSchema(colander.MappingSchema):
[docs] description = "Could not verify 'user_name'."
[docs] header = HeaderResponseSchema()
[docs] body = ErrorResponseBodySchema(code=HTTPForbidden.code, description=description)
[docs]class Signin_POST_ConflictResponseBodySchema(ErrorResponseBodySchema):
[docs] provider_name = colander.SchemaNode(colander.String())
[docs] internal_user_name = colander.SchemaNode(colander.String())
[docs] external_user_name = colander.SchemaNode(colander.String())
[docs] external_id = colander.SchemaNode(colander.String())
[docs]class Signin_POST_ConflictResponseSchema(colander.MappingSchema):
[docs] description = "Add external user identity refused by db because it already exists."
[docs] header = HeaderResponseSchema()
[docs] body = Signin_POST_ConflictResponseBodySchema(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(colander.MappingSchema):
[docs] description = "Unknown login error."
[docs] header = HeaderResponseSchema()
[docs] body = Signin_POST_InternalServerErrorBodySchema(code=HTTPInternalServerError.code, description=description)
[docs]class Signin_POST_External_InternalServerErrorResponseSchema(colander.MappingSchema):
[docs] description = "Error occurred while signing in with external provider."
[docs] header = HeaderResponseSchema()
[docs] body = Signin_POST_InternalServerErrorBodySchema(code=HTTPInternalServerError.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(colander.MappingSchema):
[docs] description = "Get version successful."
[docs] header = HeaderResponseSchema()
[docs] body = Version_GET_ResponseBodySchema(code=HTTPOk.code, description=description)
[docs]class Homepage_GET_OkResponseSchema(colander.MappingSchema):
[docs] description = "Get homepage successful."
[docs] header = HeaderResponseSchema()
[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_PUT_responses = { "200": Resource_PUT_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), "403": Resource_PUT_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[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(),
}
[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(),
}
[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(),
}
[docs]ServiceTypes_GET_responses = { "200": ServiceTypes_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[docs]ServiceType_GET_responses = { "200": Services_GET_OkResponseSchema(), "400": Services_GET_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[docs]Services_GET_responses = { "200": Services_GET_OkResponseSchema(), "400": Services_GET_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[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(),
}
[docs]Service_GET_responses = { "200": Service_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_MatchDictCheck_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[docs]Service_PUT_responses = { "200": Service_PUT_OkResponseSchema(), "400": Service_PUT_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_PUT_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "409": Service_PUT_ConflictResponseSchema(),
}
[docs]Service_DELETE_responses = { "200": Service_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_DELETE_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[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(),
}
[docs]ServiceResources_GET_responses = { "200": ServiceResources_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Service_MatchDictCheck_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[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(),
}
[docs]ServiceTypeResources_GET_responses = { "200": ServiceTypeResources_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": ServiceTypeResources_GET_ForbiddenResponseSchema(), "404": ServiceTypeResources_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]ServiceTypeResourceTypes_GET_responses = { "200": ServiceTypeResourceTypes_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": ServiceTypeResourceTypes_GET_ForbiddenResponseSchema(), "404": ServiceTypeResourceTypes_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[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(),
}
[docs]Users_GET_responses = { "200": Users_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Users_GET_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[docs]Users_POST_responses = { "201": Users_POST_CreatedResponseSchema(), "400": Users_CheckInfo_Name_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Users_POST_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "409": User_Check_ConflictResponseSchema(),
}
[docs]User_GET_responses = { "200": User_GET_OkResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]User_PUT_responses = { "200": Users_PUT_OkResponseSchema(), "400": Users_CheckInfo_Name_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": UserGroup_GET_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "409": User_Check_ConflictResponseSchema(),
}
[docs]User_DELETE_responses = { "200": User_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]UserResources_GET_responses = { "200": UserResources_GET_OkResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": UserResources_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]UserGroups_GET_responses = { "200": UserGroups_GET_OkResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]UserGroups_POST_responses = { "201": UserGroups_POST_CreatedResponseSchema(), "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": UserGroups_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]UserGroup_DELETE_responses = { "200": UserGroup_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]UserResourcePermissions_GET_responses = { "200": UserResourcePermissions_GET_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[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(),
}
[docs]UserResourcePermission_DELETE_responses = { "200": UserResourcePermissions_DELETE_OkResponseSchema(), "400": UserResourcePermissions_DELETE_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "404": UserResourcePermissions_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]UserServices_GET_responses = { "200": UserServices_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": User_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]UserServicePermissions_GET_responses = { "200": UserServicePermissions_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": UserServicePermissions_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]UserServiceResources_GET_responses = { "200": UserServiceResources_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[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(),
}
[docs]LoggedUser_PUT_responses = { "200": Users_PUT_OkResponseSchema(), "400": User_PUT_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": User_PUT_ForbiddenResponseSchema(), "406": NotAcceptableResponseSchema(), "409": User_PUT_ConflictResponseSchema(),
}
[docs]LoggedUser_DELETE_responses = { "200": User_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]LoggedUserResources_GET_responses = { "200": UserResources_GET_OkResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": UserResources_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]LoggedUserGroups_GET_responses = { "200": UserGroups_GET_OkResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[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(),
}
[docs]LoggedUserGroup_DELETE_responses = { "200": UserGroup_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": User_CheckAnonymous_ForbiddenResponseSchema(), "404": User_CheckAnonymous_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]LoggedUserResourcePermissions_GET_responses = { "200": UserResourcePermissions_GET_OkResponseSchema(), "400": Resource_MatchDictCheck_BadRequestResponseSchema(), "403": Resource_MatchDictCheck_ForbiddenResponseSchema(), "404": Resource_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]LoggedUserResourcePermissions_POST_responses = { "201": UserResourcePermissions_POST_CreatedResponseSchema(), "400": UserResourcePermissions_POST_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "406": NotAcceptableResponseSchema(), "409": UserResourcePermissions_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]LoggedUserResourcePermission_DELETE_responses = { "200": UserResourcePermissions_DELETE_OkResponseSchema(), "400": UserResourcePermissions_DELETE_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "404": UserResourcePermissions_DELETE_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]LoggedUserServices_GET_responses = { "200": UserServices_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": User_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]LoggedUserServicePermissions_GET_responses = { "200": UserServicePermissions_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": UserServicePermissions_GET_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]LoggedUserServiceResources_GET_responses = { "200": UserServiceResources_GET_OkResponseSchema(), "403": User_GET_ForbiddenResponseSchema(), "404": Service_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[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(),
}
[docs]Groups_POST_responses = { "201": Groups_POST_CreatedResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Groups_POST_ForbiddenCreateResponseSchema(), "406": NotAcceptableResponseSchema(), "409": Groups_POST_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]Group_GET_responses = { "200": Group_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_MatchDictCheck_ForbiddenResponseSchema(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]Group_PUT_responses = { "200": Group_PUT_OkResponseSchema(), "400": Group_PUT_Name_BadRequestResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_MatchDictCheck_ForbiddenResponseSchema(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "409": Group_PUT_ConflictResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]Group_DELETE_responses = { "200": Group_DELETE_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": Group_DELETE_ForbiddenResponseSchema(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[docs]GroupUsers_GET_responses = { "200": GroupUsers_GET_OkResponseSchema(), "401": UnauthorizedResponseSchema(), "403": GroupUsers_GET_ForbiddenResponseSchema(), "404": Group_MatchDictCheck_NotFoundResponseSchema(), "406": NotAcceptableResponseSchema(), "422": UnprocessableEntityResponseSchema(),
}
[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(),
}
[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(),
}
[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(),
}
[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(),
}
[docs]GroupResourcePermission_DELETE_responses = GroupServicePermission_DELETE_responses
[docs]Providers_GET_responses = { "200": Providers_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[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]Signout_GET_responses = { "200": Signout_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[docs]Session_GET_responses = { "200": Session_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(), "500": Session_GET_InternalServerErrorResponseSchema(),
}
[docs]Version_GET_responses = { "200": Version_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[docs]Homepage_GET_responses = { "200": Homepage_GET_OkResponseSchema(), "406": NotAcceptableResponseSchema(),
}
[docs]SwaggerAPI_GET_responses = { "200": SwaggerAPI_GET_OkResponseSchema(),
} # use Cornice Services and Schemas to return swagger specifications
[docs]def api_schema(request): """ Return JSON Swagger specifications of Magpie REST API. """ 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 = { "host": get_magpie_url(request.registry), "schemes": [request.scheme] } swagger_base_spec.update(SecurityDefinitionsAPI) generator.swagger = swagger_base_spec json_api_spec = generator.generate(title=TitleAPI, version=__meta__.__version__, info=InfoAPI) return json_api_spec