biothings.web.options¶
biothings.web.options.manager¶
Request Argument Standardization
- class biothings.web.options.manager.Converter(**kwargs)[source]¶
Bases:
objectA generic HTTP request argument processing unit. Only perform one level of validation at this moment. The strict switch controls the type conversion rules.
- class biothings.web.options.manager.Existentialist(defdict)[source]¶
Bases:
objectDescribes the requirement of the existance of an argument. {
“default”: <object>, “required”: <bool>,
}
- class biothings.web.options.manager.FormArgCvter(**kwargs)[source]¶
Bases:
ConverterDedicated argument converter for HTTP body arguments. Additionally support JSON seriealization format as values. Correspond to arguments received in tornado from
RequestHandler.get_body_argument
- class biothings.web.options.manager.JsonArgCvter(**kwargs)[source]¶
Bases:
ConverterDedicated argument converter for JSON HTTP bodys. Here it is used for dict JSON objects, with their first level keys considered as parameters and their values considered as arguments to process.
May correspond to this tornado implementation: https://www.tornadoweb.org/en/stable/web.html#input
- class biothings.web.options.manager.Locator(defdict)[source]¶
Bases:
objectDescribes the location of an argument in ReqArgs. {
“keyword”: <str>, “path”: <int or str>, “alias”: <str or [<str>, …]>
}
- class biothings.web.options.manager.Option(*args, **kwargs)[source]¶
Bases:
UserDictA parameter for end applications to consume. Find the value of it in the desired location.
For example: {
“keyword”: “q”, “location”: (“query”, “form”, “json”), “default”: “__all__”, “type”: “str”
}
- exception biothings.web.options.manager.OptionError(reason=None, **kwargs)[source]¶
Bases:
ValueError
- class biothings.web.options.manager.OptionSet(*args, **kwargs)[source]¶
Bases:
UserDictA collection of options that a specific endpoint consumes. Divided into groups and by the request methods.
For example: {
“*”:{“raw”:{…},”size”:{…},”dotfield”:{…}}, “GET”:{“q”:{…},”from”:{…},”sort”:{…}}, “POST”:{“q”:{…},”scopes”:{…}}
}
- class biothings.web.options.manager.OptionsManager(dict=None, /, **kwargs)[source]¶
Bases:
UserDictA collection of OptionSet(s) that makes up an application. Provide an interface to setup and serialize.
Example: {
“annotation”: {“*”: {…}, “GET”: {…}, “POST”: {… }}, “query”: {“*”: {…}, “GET”: {…}, “POST”: {… }}, “metadata”: {“GET”: {…}, “POST”: {… }}
}
- class biothings.web.options.manager.PathArgCvter(**kwargs)[source]¶
Bases:
ConverterDedicated argument converter for path arguments. Correspond to arguments received in tornado for
RequestHandler.path_args RequestHandler.path_kwargs
- class biothings.web.options.manager.QueryArgCvter(**kwargs)[source]¶
Bases:
ConverterDedicated argument converter for url query arguments. Correspond to arguments received in tornado from
RequestHandler.get_query_argument
biothings.web.options.openapi¶
- class biothings.web.options.openapi.OpenAPIContactContext(parent)[source]¶
Bases:
_ChildContext- ATTRIBUTE_FIELDS = {'email': 'email', 'name': 'name', 'url': 'url'}¶
- EXTENSION = True¶
- email(v)¶
Set email field
- name(v)¶
Set name field
- subclasses: MutableMapping[str, Type[_ChildContext]] = {'OpenAPIContactContext': <class 'biothings.web.options.openapi.OpenAPIContactContext'>, 'OpenAPIContext': <class 'biothings.web.options.openapi.OpenAPIContext'>, 'OpenAPIExternalDocsContext': <class 'biothings.web.options.openapi.OpenAPIExternalDocsContext'>, 'OpenAPIInfoContext': <class 'biothings.web.options.openapi.OpenAPIInfoContext'>, 'OpenAPILicenseContext': <class 'biothings.web.options.openapi.OpenAPILicenseContext'>, 'OpenAPIOperation': <class 'biothings.web.options.openapi.OpenAPIOperation'>, 'OpenAPIParameterContext': <class 'biothings.web.options.openapi.OpenAPIParameterContext'>, 'OpenAPIPathItemContext': <class 'biothings.web.options.openapi.OpenAPIPathItemContext'>, '_BaseContext': <class 'biothings.web.options.openapi._BaseContext'>, '_ChildContext': <class 'biothings.web.options.openapi._ChildContext'>, '_HasDescription': <class 'biothings.web.options.openapi._HasDescription'>, '_HasExternalDocs': <class 'biothings.web.options.openapi._HasExternalDocs'>, '_HasParameters': <class 'biothings.web.options.openapi._HasParameters'>, '_HasSummary': <class 'biothings.web.options.openapi._HasSummary'>, '_HasTags': <class 'biothings.web.options.openapi._HasTags'>}¶
- url(v)¶
Set url field
- class biothings.web.options.openapi.OpenAPIContext[source]¶
Bases:
_HasExternalDocs- CHILD_CONTEXTS = {'info': ('OpenAPIInfoContext', 'info')}¶
- EXTENSION = True¶
- info(**kwargs)¶
Set info Create OpenAPIInfoContext and set info
- subclasses: MutableMapping[str, Type[_ChildContext]] = {'OpenAPIContactContext': <class 'biothings.web.options.openapi.OpenAPIContactContext'>, 'OpenAPIContext': <class 'biothings.web.options.openapi.OpenAPIContext'>, 'OpenAPIExternalDocsContext': <class 'biothings.web.options.openapi.OpenAPIExternalDocsContext'>, 'OpenAPIInfoContext': <class 'biothings.web.options.openapi.OpenAPIInfoContext'>, 'OpenAPILicenseContext': <class 'biothings.web.options.openapi.OpenAPILicenseContext'>, 'OpenAPIOperation': <class 'biothings.web.options.openapi.OpenAPIOperation'>, 'OpenAPIParameterContext': <class 'biothings.web.options.openapi.OpenAPIParameterContext'>, 'OpenAPIPathItemContext': <class 'biothings.web.options.openapi.OpenAPIPathItemContext'>, '_BaseContext': <class 'biothings.web.options.openapi._BaseContext'>, '_ChildContext': <class 'biothings.web.options.openapi._ChildContext'>, '_HasDescription': <class 'biothings.web.options.openapi._HasDescription'>, '_HasExternalDocs': <class 'biothings.web.options.openapi._HasExternalDocs'>, '_HasParameters': <class 'biothings.web.options.openapi._HasParameters'>, '_HasSummary': <class 'biothings.web.options.openapi._HasSummary'>, '_HasTags': <class 'biothings.web.options.openapi._HasTags'>}¶
- biothings.web.options.openapi.OpenAPIDocumentBuilder¶
alias of
OpenAPIContext
- class biothings.web.options.openapi.OpenAPIExternalDocsContext(parent)[source]¶
Bases:
_ChildContext,_HasDescription- ATTRIBUTE_FIELDS = {'url': 'url'}¶
- EXTENSION = True¶
- subclasses: MutableMapping[str, Type[_ChildContext]] = {'OpenAPIContactContext': <class 'biothings.web.options.openapi.OpenAPIContactContext'>, 'OpenAPIContext': <class 'biothings.web.options.openapi.OpenAPIContext'>, 'OpenAPIExternalDocsContext': <class 'biothings.web.options.openapi.OpenAPIExternalDocsContext'>, 'OpenAPIInfoContext': <class 'biothings.web.options.openapi.OpenAPIInfoContext'>, 'OpenAPILicenseContext': <class 'biothings.web.options.openapi.OpenAPILicenseContext'>, 'OpenAPIOperation': <class 'biothings.web.options.openapi.OpenAPIOperation'>, 'OpenAPIParameterContext': <class 'biothings.web.options.openapi.OpenAPIParameterContext'>, 'OpenAPIPathItemContext': <class 'biothings.web.options.openapi.OpenAPIPathItemContext'>, '_BaseContext': <class 'biothings.web.options.openapi._BaseContext'>, '_ChildContext': <class 'biothings.web.options.openapi._ChildContext'>, '_HasDescription': <class 'biothings.web.options.openapi._HasDescription'>, '_HasExternalDocs': <class 'biothings.web.options.openapi._HasExternalDocs'>, '_HasParameters': <class 'biothings.web.options.openapi._HasParameters'>, '_HasSummary': <class 'biothings.web.options.openapi._HasSummary'>, '_HasTags': <class 'biothings.web.options.openapi._HasTags'>}¶
- url(v)¶
Set url field
- class biothings.web.options.openapi.OpenAPIInfoContext(parent)[source]¶
Bases:
_ChildContext,_HasDescription- ATTRIBUTE_FIELDS = {'terms_of_service': 'termsOfService', 'title': 'title', 'version': 'version'}¶
- CHILD_CONTEXTS = {'contact': ('OpenAPIContactContext', 'contact'), 'license': ('OpenAPILicenseContext', 'license')}¶
- EXTENSION = True¶
- contact(**kwargs)¶
Set contact Create OpenAPIContactContext and set contact
- license(**kwargs)¶
Set license Create OpenAPILicenseContext and set license
- subclasses: MutableMapping[str, Type[_ChildContext]] = {'OpenAPIContactContext': <class 'biothings.web.options.openapi.OpenAPIContactContext'>, 'OpenAPIContext': <class 'biothings.web.options.openapi.OpenAPIContext'>, 'OpenAPIExternalDocsContext': <class 'biothings.web.options.openapi.OpenAPIExternalDocsContext'>, 'OpenAPIInfoContext': <class 'biothings.web.options.openapi.OpenAPIInfoContext'>, 'OpenAPILicenseContext': <class 'biothings.web.options.openapi.OpenAPILicenseContext'>, 'OpenAPIOperation': <class 'biothings.web.options.openapi.OpenAPIOperation'>, 'OpenAPIParameterContext': <class 'biothings.web.options.openapi.OpenAPIParameterContext'>, 'OpenAPIPathItemContext': <class 'biothings.web.options.openapi.OpenAPIPathItemContext'>, '_BaseContext': <class 'biothings.web.options.openapi._BaseContext'>, '_ChildContext': <class 'biothings.web.options.openapi._ChildContext'>, '_HasDescription': <class 'biothings.web.options.openapi._HasDescription'>, '_HasExternalDocs': <class 'biothings.web.options.openapi._HasExternalDocs'>, '_HasParameters': <class 'biothings.web.options.openapi._HasParameters'>, '_HasSummary': <class 'biothings.web.options.openapi._HasSummary'>, '_HasTags': <class 'biothings.web.options.openapi._HasTags'>}¶
- terms_of_service(v)¶
Set termsOfService field
- title(v)¶
Set title field
- version(v)¶
Set version field
- class biothings.web.options.openapi.OpenAPILicenseContext(parent)[source]¶
Bases:
_ChildContext- ATTRIBUTE_FIELDS = {'name': 'name', 'url': 'url'}¶
- EXTENSION = True¶
- name(v)¶
Set name field
- subclasses: MutableMapping[str, Type[_ChildContext]] = {'OpenAPIContactContext': <class 'biothings.web.options.openapi.OpenAPIContactContext'>, 'OpenAPIContext': <class 'biothings.web.options.openapi.OpenAPIContext'>, 'OpenAPIExternalDocsContext': <class 'biothings.web.options.openapi.OpenAPIExternalDocsContext'>, 'OpenAPIInfoContext': <class 'biothings.web.options.openapi.OpenAPIInfoContext'>, 'OpenAPILicenseContext': <class 'biothings.web.options.openapi.OpenAPILicenseContext'>, 'OpenAPIOperation': <class 'biothings.web.options.openapi.OpenAPIOperation'>, 'OpenAPIParameterContext': <class 'biothings.web.options.openapi.OpenAPIParameterContext'>, 'OpenAPIPathItemContext': <class 'biothings.web.options.openapi.OpenAPIPathItemContext'>, '_BaseContext': <class 'biothings.web.options.openapi._BaseContext'>, '_ChildContext': <class 'biothings.web.options.openapi._ChildContext'>, '_HasDescription': <class 'biothings.web.options.openapi._HasDescription'>, '_HasExternalDocs': <class 'biothings.web.options.openapi._HasExternalDocs'>, '_HasParameters': <class 'biothings.web.options.openapi._HasParameters'>, '_HasSummary': <class 'biothings.web.options.openapi._HasSummary'>, '_HasTags': <class 'biothings.web.options.openapi._HasTags'>}¶
- url(v)¶
Set url field
- class biothings.web.options.openapi.OpenAPIOperation(parent)[source]¶
Bases:
_ChildContext,_HasSummary,_HasExternalDocs,_HasTags,_HasDescription,_HasParameters- ATTRIBUTE_FIELDS = {'operation_id': 'operationId'}¶
- EXTENSION = True¶
- operation_id(v)¶
Set operationId field
- subclasses: MutableMapping[str, Type[_ChildContext]] = {'OpenAPIContactContext': <class 'biothings.web.options.openapi.OpenAPIContactContext'>, 'OpenAPIContext': <class 'biothings.web.options.openapi.OpenAPIContext'>, 'OpenAPIExternalDocsContext': <class 'biothings.web.options.openapi.OpenAPIExternalDocsContext'>, 'OpenAPIInfoContext': <class 'biothings.web.options.openapi.OpenAPIInfoContext'>, 'OpenAPILicenseContext': <class 'biothings.web.options.openapi.OpenAPILicenseContext'>, 'OpenAPIOperation': <class 'biothings.web.options.openapi.OpenAPIOperation'>, 'OpenAPIParameterContext': <class 'biothings.web.options.openapi.OpenAPIParameterContext'>, 'OpenAPIPathItemContext': <class 'biothings.web.options.openapi.OpenAPIPathItemContext'>, '_BaseContext': <class 'biothings.web.options.openapi._BaseContext'>, '_ChildContext': <class 'biothings.web.options.openapi._ChildContext'>, '_HasDescription': <class 'biothings.web.options.openapi._HasDescription'>, '_HasExternalDocs': <class 'biothings.web.options.openapi._HasExternalDocs'>, '_HasParameters': <class 'biothings.web.options.openapi._HasParameters'>, '_HasSummary': <class 'biothings.web.options.openapi._HasSummary'>, '_HasTags': <class 'biothings.web.options.openapi._HasTags'>}¶
- class biothings.web.options.openapi.OpenAPIParameterContext(parent, name: str, in_: str, required: bool)[source]¶
Bases:
_ChildContext,_HasDescription- ATTRIBUTE_FIELDS = {'allow_empty': 'allowEmptyValue', 'allow_reserved': 'allowReserved', 'deprecated': 'deprecated', 'explode': 'explode', 'schema': 'schema', 'style': 'style'}¶
- EXTENSION = True¶
- allow_empty(v)¶
Set allowEmptyValue field
- allow_reserved(v)¶
Set allowReserved field
- deprecated(v)¶
Set deprecated field
- explode(v)¶
Set explode field
- schema(v)¶
Set schema field
- style(v)¶
Set style field
- subclasses: MutableMapping[str, Type[_ChildContext]] = {'OpenAPIContactContext': <class 'biothings.web.options.openapi.OpenAPIContactContext'>, 'OpenAPIContext': <class 'biothings.web.options.openapi.OpenAPIContext'>, 'OpenAPIExternalDocsContext': <class 'biothings.web.options.openapi.OpenAPIExternalDocsContext'>, 'OpenAPIInfoContext': <class 'biothings.web.options.openapi.OpenAPIInfoContext'>, 'OpenAPILicenseContext': <class 'biothings.web.options.openapi.OpenAPILicenseContext'>, 'OpenAPIOperation': <class 'biothings.web.options.openapi.OpenAPIOperation'>, 'OpenAPIParameterContext': <class 'biothings.web.options.openapi.OpenAPIParameterContext'>, 'OpenAPIPathItemContext': <class 'biothings.web.options.openapi.OpenAPIPathItemContext'>, '_BaseContext': <class 'biothings.web.options.openapi._BaseContext'>, '_ChildContext': <class 'biothings.web.options.openapi._ChildContext'>, '_HasDescription': <class 'biothings.web.options.openapi._HasDescription'>, '_HasExternalDocs': <class 'biothings.web.options.openapi._HasExternalDocs'>, '_HasParameters': <class 'biothings.web.options.openapi._HasParameters'>, '_HasSummary': <class 'biothings.web.options.openapi._HasSummary'>, '_HasTags': <class 'biothings.web.options.openapi._HasTags'>}¶
- class biothings.web.options.openapi.OpenAPIPathItemContext(parent)[source]¶
Bases:
_ChildContext,_HasSummary,_HasDescription,_HasParameters- CHILD_CONTEXTS = {'delete': ('OpenAPIOperation', 'delete'), 'get': ('OpenAPIOperation', 'get'), 'head': ('OpenAPIOperation', 'head'), 'options': ('OpenAPIOperation', 'options'), 'patch': ('OpenAPIOperation', 'patch'), 'post': ('OpenAPIOperation', 'post'), 'put': ('OpenAPIOperation', 'put'), 'trace': ('OpenAPIOperation', 'trace')}¶
- EXTENSION = True¶
- delete(**kwargs)¶
Set delete Create OpenAPIOperation and set delete
- get(**kwargs)¶
Set get Create OpenAPIOperation and set get
- head(**kwargs)¶
Set head Create OpenAPIOperation and set head
- http_method = 'trace'¶
- options(**kwargs)¶
Set options Create OpenAPIOperation and set options
- patch(**kwargs)¶
Set patch Create OpenAPIOperation and set patch
- post(**kwargs)¶
Set post Create OpenAPIOperation and set post
- put(**kwargs)¶
Set put Create OpenAPIOperation and set put
- subclasses: MutableMapping[str, Type[_ChildContext]] = {'OpenAPIContactContext': <class 'biothings.web.options.openapi.OpenAPIContactContext'>, 'OpenAPIContext': <class 'biothings.web.options.openapi.OpenAPIContext'>, 'OpenAPIExternalDocsContext': <class 'biothings.web.options.openapi.OpenAPIExternalDocsContext'>, 'OpenAPIInfoContext': <class 'biothings.web.options.openapi.OpenAPIInfoContext'>, 'OpenAPILicenseContext': <class 'biothings.web.options.openapi.OpenAPILicenseContext'>, 'OpenAPIOperation': <class 'biothings.web.options.openapi.OpenAPIOperation'>, 'OpenAPIParameterContext': <class 'biothings.web.options.openapi.OpenAPIParameterContext'>, 'OpenAPIPathItemContext': <class 'biothings.web.options.openapi.OpenAPIPathItemContext'>, '_BaseContext': <class 'biothings.web.options.openapi._BaseContext'>, '_ChildContext': <class 'biothings.web.options.openapi._ChildContext'>, '_HasDescription': <class 'biothings.web.options.openapi._HasDescription'>, '_HasExternalDocs': <class 'biothings.web.options.openapi._HasExternalDocs'>, '_HasParameters': <class 'biothings.web.options.openapi._HasParameters'>, '_HasSummary': <class 'biothings.web.options.openapi._HasSummary'>, '_HasTags': <class 'biothings.web.options.openapi._HasTags'>}¶
- trace(**kwargs)¶
Set trace Create OpenAPIOperation and set trace