API¶
Error Handler¶
Media Handler¶
Middleware¶
-
class
api.middleware.
Basic_Auth_Backend_Middleware
(dev_username, dev_password)[source]¶ -
authenticate
(req, resp, resource)[source]¶ Extract basic auth token from request authorization header, deocode the token, verifies the username/password and return either a
user
object if successful else raise an falcon.HTTPUnauthoried exception
-
get_auth_header
(user_payload)¶ Returns the value for authorization header Args:
- user_payload(dict, required): A dict containing required information
to create authentication token
-
get_auth_token
(user_payload)¶ Extracts username, password from the user_payload and encode the credentials username:password in base64 form
-
parse_auth_token_from_request
(auth_header)¶ Parses and returns Auth token from the request header. Raises falcon.HTTPUnauthoried exception with proper error message
-
Docstring¶
Document¶
-
class
document.base.
Base_Document
(meta=None, **kwargs)[source]¶ -
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
Agent¶
-
class
document.agent.catalog.
Agent_Catalog_Document
(meta=None, **kwargs)[source]¶ Represents an agent in the catalog.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
-
class
document.agent.instance.
Agent_Instance_Document
(meta=None, **kwargs)[source]¶ Represents an agent instance installed in an execution environment.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
eBPF Program¶
-
class
document.ebpf_program.catalog.
eBPF_Program_Catalog_Document
(meta=None, **kwargs)[source]¶ Represents an eBPF program in the catalog.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
-
class
document.ebpf_program.instance.
eBPF_Program_Instance_Document
(meta=None, **kwargs)[source]¶ Represents an eBPF program installed in an execution environment.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
Connection¶
-
class
document.connection.
Connection_Document
(meta=None, **kwargs)[source]¶ Represents an connection between execution environments and network links.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
Data¶
-
class
document.data.
Data_Document
(meta=None, **kwargs)[source]¶ Represents the stored data.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
Execution Environment¶
-
class
document.exec_env.
Exec_Env_Document
(meta=None, **kwargs)[source]¶ Represents an execution environment.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
-
class
document.exec_env.
Exec_Env_Type_Document
(meta=None, **kwargs)[source]¶ Type of execution environment. Example: virtual machine or container.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
Network Link¶
-
class
document.network_link.
Network_Link_Document
(meta=None, **kwargs)[source]¶ Represents a network link.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
-
class
document.network_link.
Network_Link_Type_Document
(meta=None, **kwargs)[source]¶ Represents a network link type.
-
delete
(using=None, index=None, **kwargs)¶ Delete the instance in elasticsearch.
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.delete
unchanged.
-
classmethod
get
(id, using=None, index=None, **kwargs)¶ Retrieve a single document from elasticsearch using its
id
.- Parameters
id –
id
of the document to be retrievedindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
Any additional keyword arguments will be passed to
Elasticsearch.get
unchanged.
-
classmethod
init
(index=None, using=None)¶ Create the index and populate the mappings in elasticsearch.
-
classmethod
mget
(docs, using=None, index=None, raise_on_error=True, missing='none', **kwargs)¶ Retrieve multiple document by their
id
s. Returns a list of instances in the same order as requested.- Parameters
docs – list of
id
s of the documents to be retrieved or a list of document specifications as per https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-multi-get.htmlindex – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
missing – what to do when one of the documents requested is not found. Valid options are
'none'
(useNone
),'raise'
(raiseNotFoundError
) or'skip'
(ignore the missing document).
Any additional keyword arguments will be passed to
Elasticsearch.mget
unchanged.
-
save
(using=None, index=None, validate=True, skip_empty=True, **kwargs)¶ Save the document into elasticsearch. If the document doesn’t exist it is created, it is overwritten otherwise. Returns
True
if this operations resulted in new document being created.- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
validate – set to
False
to skip validating the documentskip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
Any additional keyword arguments will be passed to
Elasticsearch.index
unchanged.:return operation result created/updated
-
classmethod
search
(using=None, index=None)¶ Create an
Search
instance that will search over thisDocument
.
-
to_dict
(include_meta=False, skip_empty=True)¶ Serialize the instance into a dictionary so that it can be saved in elasticsearch.
- Parameters
include_meta – if set to
True
will include all the metadata (_index
,_id
etc). Otherwise just the document’s data is serialized. This is useful when passing multiple instances intoelasticsearch.helpers.bulk
.skip_empty – if set to
False
will cause empty values (None
,[]
,{}
) to be left on the document. Those values will be stripped out otherwise as they make no difference in elasticsearch.
-
update
(using=None, index=None, detect_noop=True, doc_as_upsert=False, refresh=False, retry_on_conflict=None, script=None, script_id=None, scripted_upsert=False, upsert=None, **fields)¶ Partial update of the document, specify fields you wish to update and both the instance and the document in elasticsearch will be updated:
doc = MyDocument(title='Document Title!') doc.save() doc.update(title='New Document Title!')
- Parameters
index – elasticsearch index to use, if the
Document
is associated with an index this can be omitted.using – connection alias to use, defaults to
'default'
detect_noop – Set to
False
to disable noop detection.refresh – Control when the changes made by this request are visible to search. Set to
True
for immediate effect.retry_on_conflict – In between the get and indexing phases of the update, it is possible that another process might have already updated the same document. By default, the update will fail with a version conflict exception. The retry_on_conflict parameter controls how many times to retry the update before finally throwing an exception.
doc_as_upsert – Instead of sending a partial doc plus an upsert doc, setting doc_as_upsert to true will use the contents of doc as the upsert value
:return operation result noop/updated
-
Response¶
Reader¶
-
class
reader.config.
Config_Reader
[source]¶ -
class
Env_Interpolation
[source]¶ Interpolation which expands environment variables in values.
-
_interpolate_some
(parser, option, accum, rest, section, map, depth)¶
-
before_get
(parser, section, option, value, defaults)[source]¶ Executes before getting the value.
- Parameters
self – class instance
parser – configparser instance
section – section value
option – option value
value – current value
defaults – default values
- Returns
value with expanded variables
-
before_read
(parser, section, option, value)¶
-
before_set
(parser, section, option, value)¶
-
before_write
(parser, section, option, value)¶
-
-
class
Resource¶
Agent¶
-
class
resource.agent.catalog.
Agent_Catalog_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the agent catalog with the given id and filtered by the query in the request body.
—
- summary: <
Agent catalog Delete (Single).
description: Delete the agent catalog with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [agent-catalog] responses:
- 205:
- description: <
Agent catalog with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Agent catalog with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the agent catalog with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the agent catalog with the given id and filtered by the query in the request body. — summary: <
Agent catalog Read (Single).
description: Get the agent catalog with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [agent-catalog] responses:
- 200:
- description: <
Agent catalog with the given id and filtered by the query in the request body.
- schema:
type: array items: Agent_Catalog_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Agent catalog based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get agent catalogs with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new agent catalog with the given id. — summary: <
Agent catalog Create (Single).
description: Create a new agent catalog with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Agent_Catalog_Schema
tags: [agent-catalog] responses:
- 201:
- description: <
Agent catalog with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the agent catalog with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the agent catalog with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the agent catalog with the given id. — summary: <
Agent catalog Update (Single).
description: Update the agent catalog with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Agent_Catalog_Schema
tags: [agent-catalog] responses:
- 200:
- description: <
Agent catalog with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update agent catalogs with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the agent catalog with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the agent catalog with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶
-
-
class
resource.agent.catalog.
Agent_Catalog_Selected_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the agent catalog with the given id and filtered by the query in the request body.
—
- summary: <
Agent catalog Delete (Single).
description: Delete the agent catalog with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [agent-catalog] responses:
- 205:
- description: <
Agent catalog with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Agent catalog with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the agent catalog with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the agent catalog with the given id and filtered by the query in the request body. — summary: <
Agent catalog Read (Single).
description: Get the agent catalog with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [agent-catalog] responses:
- 200:
- description: <
Agent catalog with the given id and filtered by the query in the request body.
- schema:
type: array items: Agent_Catalog_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Agent catalog based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get agent catalogs with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new agent catalog with the given id. — summary: <
Agent catalog Create (Single).
description: Create a new agent catalog with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Agent_Catalog_Schema
tags: [agent-catalog] responses:
- 201:
- description: <
Agent catalog with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the agent catalog with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the agent catalog with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the agent catalog with the given id. — summary: <
Agent catalog Update (Single).
description: Update the agent catalog with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Agent_Catalog_Schema
tags: [agent-catalog] responses:
- 200:
- description: <
Agent catalog with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update agent catalogs with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the agent catalog with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the agent catalog with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶
-
-
class
resource.agent.instance.
Agent_Instance_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the agent instance with the given id and filtered by the query in the request body.
—
- summary: <
Agent instance Delete (Single).
description: Delete the agent instance with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [agent-instance] responses:
- 205:
- description: <
Agent instance with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Agent instance with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the agent instance with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the agent instance with the given id and filtered by the query in the request body. — summary: <
Agent instance Read (Single).
description: Get the agent instance with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [agent-instance] responses:
- 200:
- description: <
Agent instance with the given id and filtered by the query in the request body.
- schema:
type: array items: Agent_Instance_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Agent instance based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get agent instances with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new agent instance with the given id. — summary: <
Agent instance Create (Single).
description: Create a new agent instance with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Agent_Instance_Schema
tags: [agent-instance] responses:
- 201:
- description: <
Agent instance with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the agent instance with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the agent instance with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the agent instance with the given id. — summary: <
Agent instance Update (Single).
description: Update the agent instance with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Agent_Instance_Schema
tags: [agent-instance] responses:
- 200:
- description: <
Agent instance with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update agent instances with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the agent instance with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the agent instance with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶
-
-
class
resource.agent.instance.
Agent_Instance_Selected_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the agent instance with the given id and filtered by the query in the request body.
—
- summary: <
Agent instance Delete (Single).
description: Delete the agent instance with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [agent-instance] responses:
- 205:
- description: <
Agent instance with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Agent instance with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the agent instance with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the agent instance with the given id and filtered by the query in the request body. — summary: <
Agent instance Read (Single).
description: Get the agent instance with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [agent-instance] responses:
- 200:
- description: <
Agent instance with the given id and filtered by the query in the request body.
- schema:
type: array items: Agent_Instance_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Agent instance based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get agent instances with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new agent instance with the given id. — summary: <
Agent instance Create (Single).
description: Create a new agent instance with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Agent_Instance_Schema
tags: [agent-instance] responses:
- 201:
- description: <
Agent instance with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the agent instance with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the agent instance with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the agent instance with the given id. — summary: <
Agent instance Update (Single).
description: Update the agent instance with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Agent_Instance_Schema
tags: [agent-instance] responses:
- 200:
- description: <
Agent instance with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update agent instances with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the agent instance with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the agent instance with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶
-
eBPF Program¶
-
class
resource.ebpf_program.catalog.
eBPF_Program_Catalog_Resource
[source]¶ -
-
on_delete
(req, resp, id=None)¶ Delete the eBPF program catalog with the given id and filtered by the query in the request body.
—
- summary: <
Ebpf program catalog Delete (Single).
description: Delete the eBPF program catalog with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [ebpf-program-catalog] responses:
- 205:
- description: <
Ebpf program catalog with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Ebpf program catalog with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the eBPF program catalog with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the eBPF program catalog with the given id and filtered by the query in the request body. — summary: <
Ebpf program catalog Read (Single).
description: Get the eBPF program catalog with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [ebpf-program-catalog] responses:
- 200:
- description: <
Ebpf program catalog with the given id and filtered by the query in the request body.
- schema:
type: array items: eBPF_Program_Catalog_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Ebpf program catalog based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get eBPF program catalogs with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new eBPF program catalog with the given id. — summary: <
Ebpf program catalog Create (Single).
description: Create a new eBPF program catalog with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: eBPF_Program_Catalog_Schema
tags: [ebpf-program-catalog] responses:
- 201:
- description: <
Ebpf program catalog with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the eBPF program catalog with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the eBPF program catalog with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the eBPF program catalog with the given id. — summary: <
Ebpf program catalog Update (Single).
description: Update the eBPF program catalog with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: eBPF_Program_Catalog_Schema
tags: [ebpf-program-catalog] responses:
- 200:
- description: <
Ebpf program catalog with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update eBPF program catalogs with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the eBPF program catalog with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the eBPF program catalog with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.ebpf_program.catalog.eBPF_Program_Catalog_Schema
-
-
class
resource.ebpf_program.catalog.
eBPF_Program_Catalog_Selected_Resource
[source]¶ -
-
on_delete
(req, resp, id=None)¶ Delete the eBPF program catalog with the given id and filtered by the query in the request body.
—
- summary: <
Ebpf program catalog Delete (Single).
description: Delete the eBPF program catalog with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [ebpf-program-catalog] responses:
- 205:
- description: <
Ebpf program catalog with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Ebpf program catalog with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the eBPF program catalog with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the eBPF program catalog with the given id and filtered by the query in the request body. — summary: <
Ebpf program catalog Read (Single).
description: Get the eBPF program catalog with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [ebpf-program-catalog] responses:
- 200:
- description: <
Ebpf program catalog with the given id and filtered by the query in the request body.
- schema:
type: array items: eBPF_Program_Catalog_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Ebpf program catalog based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get eBPF program catalogs with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new eBPF program catalog with the given id. — summary: <
Ebpf program catalog Create (Single).
description: Create a new eBPF program catalog with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: eBPF_Program_Catalog_Schema
tags: [ebpf-program-catalog] responses:
- 201:
- description: <
Ebpf program catalog with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the eBPF program catalog with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the eBPF program catalog with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the eBPF program catalog with the given id. — summary: <
Ebpf program catalog Update (Single).
description: Update the eBPF program catalog with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: eBPF_Program_Catalog_Schema
tags: [ebpf-program-catalog] responses:
- 200:
- description: <
Ebpf program catalog with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update eBPF program catalogs with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the eBPF program catalog with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the eBPF program catalog with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.ebpf_program.catalog.eBPF_Program_Catalog_Schema
-
-
class
resource.ebpf_program.instance.
eBPF_Program_Instance_Resource
[source]¶ -
-
on_delete
(req, resp, id=None)¶ Delete the eBPF program with the given id and filtered by the query in the request body.
—
- summary: <
Ebpf program Delete (Single).
description: Delete the eBPF program with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [ebpf-program-instance] responses:
- 205:
- description: <
Ebpf program with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Ebpf program with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the eBPF program with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the eBPF program with the given id and filtered by the query in the request body. — summary: <
Ebpf program Read (Single).
description: Get the eBPF program with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [ebpf-program-instance] responses:
- 200:
- description: <
Ebpf program with the given id and filtered by the query in the request body.
- schema:
type: array items: eBPF_Program_Instance_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Ebpf program based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get eBPF programs with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new eBPF program with the given id. — summary: <
Ebpf program Create (Single).
description: Create a new eBPF program with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: eBPF_Program_Instance_Schema
tags: [ebpf-program-instance] responses:
- 201:
- description: <
Ebpf program with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the eBPF program with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the eBPF program with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the eBPF program with the given id. — summary: <
Ebpf program Update (Single).
description: Update the eBPF program with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: eBPF_Program_Instance_Schema
tags: [ebpf-program-instance] responses:
- 200:
- description: <
Ebpf program with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update eBPF programs with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the eBPF program with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the eBPF program with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.ebpf_program.instance.eBPF_Program_Instance_Schema
-
-
class
resource.ebpf_program.instance.
eBPF_Program_Instance_Selected_Resource
[source]¶ -
-
on_delete
(req, resp, id=None)¶ Delete the eBPF program with the given id and filtered by the query in the request body.
—
- summary: <
Ebpf program Delete (Single).
description: Delete the eBPF program with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [ebpf-program-instance] responses:
- 205:
- description: <
Ebpf program with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Ebpf program with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the eBPF program with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the eBPF program with the given id and filtered by the query in the request body. — summary: <
Ebpf program Read (Single).
description: Get the eBPF program with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [ebpf-program-instance] responses:
- 200:
- description: <
Ebpf program with the given id and filtered by the query in the request body.
- schema:
type: array items: eBPF_Program_Instance_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Ebpf program based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get eBPF programs with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new eBPF program with the given id. — summary: <
Ebpf program Create (Single).
description: Create a new eBPF program with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: eBPF_Program_Instance_Schema
tags: [ebpf-program-instance] responses:
- 201:
- description: <
Ebpf program with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the eBPF program with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the eBPF program with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the eBPF program with the given id. — summary: <
Ebpf program Update (Single).
description: Update the eBPF program with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: eBPF_Program_Instance_Schema
tags: [ebpf-program-instance] responses:
- 200:
- description: <
Ebpf program with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update eBPF programs with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the eBPF program with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the eBPF program with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.ebpf_program.instance.eBPF_Program_Instance_Schema
-
Execution Environment¶
-
class
resource.exec_env.
Exec_Env_Resource
[source]¶ -
doc
¶ alias of
document.exec_env.Exec_Env_Document
-
on_delete
(req, resp, id=None)¶ Delete the execution environment with the given id and filtered by the query in the request body.
—
- summary: <
Execution environment Delete (Single).
description: Delete the execution environment with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [exec-env] responses:
- 205:
- description: <
Execution environment with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Execution environment with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the execution environment with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the execution environment with the given id and filtered by the query in the request body. — summary: <
Execution environment Read (Single).
description: Get the execution environment with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [exec-env] responses:
- 200:
- description: <
Execution environment with the given id and filtered by the query in the request body.
- schema:
type: array items: Exec_Env_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Execution environment based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get execution environments with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new execution environment with the given id. — summary: <
Execution environment Create (Single).
description: Create a new execution environment with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Exec_Env_Schema
tags: [exec-env] responses:
- 201:
- description: <
Execution environment with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the execution environment with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the execution environment with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the execution environment with the given id. — summary: <
Execution environment Update (Single).
description: Update the execution environment with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Exec_Env_Schema
tags: [exec-env] responses:
- 200:
- description: <
Execution environment with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update execution environments with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the execution environment with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the execution environment with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.exec_env.Exec_Env_Schema
-
-
class
resource.exec_env.
Exec_Env_Selected_Resource
[source]¶ -
doc
¶ alias of
document.exec_env.Exec_Env_Document
-
on_delete
(req, resp, id=None)¶ Delete the execution environment with the given id and filtered by the query in the request body.
—
- summary: <
Execution environment Delete (Single).
description: Delete the execution environment with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [exec-env] responses:
- 205:
- description: <
Execution environment with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Execution environment with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the execution environment with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the execution environment with the given id and filtered by the query in the request body. — summary: <
Execution environment Read (Single).
description: Get the execution environment with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [exec-env] responses:
- 200:
- description: <
Execution environment with the given id and filtered by the query in the request body.
- schema:
type: array items: Exec_Env_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Execution environment based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get execution environments with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new execution environment with the given id. — summary: <
Execution environment Create (Single).
description: Create a new execution environment with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Exec_Env_Schema
tags: [exec-env] responses:
- 201:
- description: <
Execution environment with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the execution environment with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the execution environment with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the execution environment with the given id. — summary: <
Execution environment Update (Single).
description: Update the execution environment with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Exec_Env_Schema
tags: [exec-env] responses:
- 200:
- description: <
Execution environment with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update execution environments with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the execution environment with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the execution environment with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.exec_env.Exec_Env_Schema
-
-
class
resource.exec_env.
Exec_Env_Type_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the execution environment type with the given id and filtered by the query in the request body.
—
- summary: <
Execution environment type Delete (Single).
description: Delete the execution environment type with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [exec-env-type] responses:
- 205:
- description: <
Execution environment type with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Execution environment type with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the execution environment type with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the execution environment type with the given id and filtered by the query in the request body. — summary: <
Execution environment type Read (Single).
description: Get the execution environment type with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [exec-env-type] responses:
- 200:
- description: <
Execution environment type with the given id and filtered by the query in the request body.
- schema:
type: array items: Exec_Env_Type_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Execution environment type based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get execution environment types with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new execution environment type with the given id. — summary: <
Execution environment type Create (Single).
description: Create a new execution environment type with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Exec_Env_Type_Schema
tags: [exec-env-type] responses:
- 201:
- description: <
Execution environment type with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the execution environment type with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the execution environment type with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the execution environment type with the given id. — summary: <
Execution environment type Update (Single).
description: Update the execution environment type with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Exec_Env_Type_Schema
tags: [exec-env-type] responses:
- 200:
- description: <
Execution environment type with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update execution environment types with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the execution environment type with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the execution environment type with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.exec_env.Exec_Env_Type_Schema
-
-
class
resource.exec_env.
Exec_Env_Type_Selected_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the execution environment type with the given id and filtered by the query in the request body.
—
- summary: <
Execution environment type Delete (Single).
description: Delete the execution environment type with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [exec-env-type] responses:
- 205:
- description: <
Execution environment type with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Execution environment type with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the execution environment type with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the execution environment type with the given id and filtered by the query in the request body. — summary: <
Execution environment type Read (Single).
description: Get the execution environment type with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [exec-env-type] responses:
- 200:
- description: <
Execution environment type with the given id and filtered by the query in the request body.
- schema:
type: array items: Exec_Env_Type_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Execution environment type based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get execution environment types with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new execution environment type with the given id. — summary: <
Execution environment type Create (Single).
description: Create a new execution environment type with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Exec_Env_Type_Schema
tags: [exec-env-type] responses:
- 201:
- description: <
Execution environment type with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the execution environment type with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the execution environment type with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the execution environment type with the given id. — summary: <
Execution environment type Update (Single).
description: Update the execution environment type with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Exec_Env_Type_Schema
tags: [exec-env-type] responses:
- 200:
- description: <
Execution environment type with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update execution environment types with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the execution environment type with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the execution environment type with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.exec_env.Exec_Env_Type_Schema
-
Network Link¶
-
class
resource.network_link.
Network_Link_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the network link with the given id and filtered by the query in the request body.
—
- summary: <
Network link Delete (Single).
description: Delete the network link with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [network-link] responses:
- 205:
- description: <
Network link with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Network link with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the network link with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the network link with the given id and filtered by the query in the request body. — summary: <
Network link Read (Single).
description: Get the network link with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [network-link] responses:
- 200:
- description: <
Network link with the given id and filtered by the query in the request body.
- schema:
type: array items: Network_Link_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Network link based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get network links with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new network link with the given id. — summary: <
Network link Create (Single).
description: Create a new network link with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Network_Link_Schema
tags: [network-link] responses:
- 201:
- description: <
Network link with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the network link with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the network link with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the network link with the given id. — summary: <
Network link Update (Single).
description: Update the network link with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Network_Link_Schema
tags: [network-link] responses:
- 200:
- description: <
Network link with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update network links with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the network link with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the network link with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶
-
-
class
resource.network_link.
Network_Link_Selected_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the network link with the given id and filtered by the query in the request body.
—
- summary: <
Network link Delete (Single).
description: Delete the network link with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [network-link] responses:
- 205:
- description: <
Network link with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Network link with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the network link with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the network link with the given id and filtered by the query in the request body. — summary: <
Network link Read (Single).
description: Get the network link with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [network-link] responses:
- 200:
- description: <
Network link with the given id and filtered by the query in the request body.
- schema:
type: array items: Network_Link_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Network link based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get network links with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new network link with the given id. — summary: <
Network link Create (Single).
description: Create a new network link with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Network_Link_Schema
tags: [network-link] responses:
- 201:
- description: <
Network link with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the network link with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the network link with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the network link with the given id. — summary: <
Network link Update (Single).
description: Update the network link with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Network_Link_Schema
tags: [network-link] responses:
- 200:
- description: <
Network link with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update network links with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the network link with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the network link with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶
-
-
class
resource.network_link.
Network_Link_Type_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the network link type with the given id and filtered by the query in the request body.
—
- summary: <
Network link type Delete (Single).
description: Delete the network link type with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [network-link-type] responses:
- 205:
- description: <
Network link type with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Network link type with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the network link type with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the network link type with the given id and filtered by the query in the request body. — summary: <
Network link type Read (Single).
description: Get the network link type with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [network-link-type] responses:
- 200:
- description: <
Network link type with the given id and filtered by the query in the request body.
- schema:
type: array items: Network_Link_Type_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Network link type based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get network link types with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new network link type with the given id. — summary: <
Network link type Create (Single).
description: Create a new network link type with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Network_Link_Type_Schema
tags: [network-link-type] responses:
- 201:
- description: <
Network link type with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the network link type with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the network link type with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the network link type with the given id. — summary: <
Network link type Update (Single).
description: Update the network link type with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Network_Link_Type_Schema
tags: [network-link-type] responses:
- 200:
- description: <
Network link type with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update network link types with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the network link type with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the network link type with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶
-
-
class
resource.network_link.
Network_Link_Type_Selected_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the network link type with the given id and filtered by the query in the request body.
—
- summary: <
Network link type Delete (Single).
description: Delete the network link type with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [network-link-type] responses:
- 205:
- description: <
Network link type with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Network link type with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the network link type with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the network link type with the given id and filtered by the query in the request body. — summary: <
Network link type Read (Single).
description: Get the network link type with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [network-link-type] responses:
- 200:
- description: <
Network link type with the given id and filtered by the query in the request body.
- schema:
type: array items: Network_Link_Type_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Network link type based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get network link types with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new network link type with the given id. — summary: <
Network link type Create (Single).
description: Create a new network link type with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Network_Link_Type_Schema
tags: [network-link-type] responses:
- 201:
- description: <
Network link type with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the network link type with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the network link type with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the network link type with the given id. — summary: <
Network link type Update (Single).
description: Update the network link type with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Network_Link_Type_Schema
tags: [network-link-type] responses:
- 200:
- description: <
Network link type with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update network link types with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the network link type with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the network link type with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶
-
Connection¶
-
class
resource.connection.
Connection_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the connection with the given id and filtered by the query in the request body.
—
- summary: <
Connection Delete (Single).
description: Delete the connection with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [connection] responses:
- 205:
- description: <
Connection with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Connection with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the connection with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the connection with the given id and filtered by the query in the request body. — summary: <
Connection Read (Single).
description: Get the connection with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [connection] responses:
- 200:
- description: <
Connection with the given id and filtered by the query in the request body.
- schema:
type: array items: Connection_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Connection based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get connections with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new connection with the given id. — summary: <
Connection Create (Single).
description: Create a new connection with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Connection_Schema
tags: [connection] responses:
- 201:
- description: <
Connection with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the connection with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the connection with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the connection with the given id. — summary: <
Connection Update (Single).
description: Update the connection with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Connection_Schema
tags: [connection] responses:
- 200:
- description: <
Connection with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update connections with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the connection with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the connection with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.connection.Connection_Schema
-
-
class
resource.connection.
Connection_Selected_Resource
[source]¶ -
doc
¶
-
on_delete
(req, resp, id=None)¶ Delete the connection with the given id and filtered by the query in the request body.
—
- summary: <
Connection Delete (Single).
description: Delete the connection with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [connection] responses:
- 205:
- description: <
Connection with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Connection with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the connection with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the connection with the given id and filtered by the query in the request body. — summary: <
Connection Read (Single).
description: Get the connection with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [connection] responses:
- 200:
- description: <
Connection with the given id and filtered by the query in the request body.
- schema:
type: array items: Connection_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Connection based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get connections with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new connection with the given id. — summary: <
Connection Create (Single).
description: Create a new connection with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Connection_Schema
tags: [connection] responses:
- 201:
- description: <
Connection with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the connection with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the connection with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the connection with the given id. — summary: <
Connection Update (Single).
description: Update the connection with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Connection_Schema
tags: [connection] responses:
- 200:
- description: <
Connection with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update connections with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the connection with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the connection with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.connection.Connection_Schema
-
Data¶
-
class
resource.data.
Data_Resource
[source]¶ -
doc
¶ alias of
document.data.Data_Document
-
on_delete
(req, resp, id=None)¶ Delete the data with the given id and filtered by the query in the request body.
—
- summary: <
Data Delete (Single).
description: Delete the data with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [data] responses:
- 205:
- description: <
Data with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Data with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the data with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the data with the given id and filtered by the query in the request body. — summary: <
Data Read (Single).
description: Get the data with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [data] responses:
- 200:
- description: <
Data with the given id and filtered by the query in the request body.
- schema:
type: array items: Data_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Data based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get data with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new data with the given id. — summary: <
Data Create (Single).
description: Create a new data with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Data_Schema
tags: [data] responses:
- 201:
- description: <
Data with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the data with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the data with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the data with the given id. — summary: <
Data Update (Single).
description: Update the data with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Data_Schema
tags: [data] responses:
- 200:
- description: <
Data with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update data with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the data with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the data with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.data.Data_Schema
-
-
class
resource.data.
Data_Selected_Resource
[source]¶ -
doc
¶ alias of
document.data.Data_Document
-
on_delete
(req, resp, id=None)¶ Delete the data with the given id and filtered by the query in the request body.
—
- summary: <
Data Delete (Single).
description: Delete the data with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [data] responses:
- 205:
- description: <
Data with the given id correctly deleted.
- schema:
type: array items: Reset_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Data with the given id and based on the request query not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to delete the data with the given id and based on the request query. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_get
(req, resp, id=None)¶ Get the data with the given id and filtered by the query in the request body. — summary: <
Data Read (Single).
description: Get the data with the given id and filtered by the query in the request body. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema: Query_Request_Schema
tags: [data] responses:
- 200:
- description: <
Data with the given id and filtered by the query in the request body.
- schema:
type: array items: Data_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 404:
- description: <
Data based on the request _query_ not found.
schema: Not_Found_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to get data with the request _query_. schema: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_post
(req, resp, id=None)¶ Create a new data with the given id. — summary: <
Data Create (Single).
description: Create a new data with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Data_Schema
tags: [data] responses:
- 201:
- description: <
Data with the given id correctly created.
- schema:
type: array items: Created_Response_Schema
- 204:
description: No content to create the data with the given id and based on the request. schema: No_Content_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to create the data with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
on_put
(req, resp, id=None)¶ Update the data with the given id. — summary: <
Data Update (Single).
description: Update the data with the given id. parameters:
name: id required: true in: path type: String
name: payload required: true in: body schema:
type: array items: Data_Schema
tags: [data] responses:
- 200:
- description: <
Data with the given id correctly updated.
- schema:
type: array items: Ok_Response_Schema
- 204:
description: No content to update data with the given id and based on the request. schema: No_Content_Response_Schema
- 304:
description: Update of the data with the given id not necessary. schema:
type: array items: Not_Modified_Response_Schema
- 400:
description: Request not valid. schema: Bad_Request_Response_Schema
- 401:
description: Authentication failed. schema: Unauthorized_Response_Schema
- 406:
description: Request validation failed. schema: Not_Acceptable_Response_Schema
- 415:
description: Media type not supported. schema: Unsupported_Media_Type_Response_Schema
- 422:
description: Not possible to update the data with the given id and based on the request. schema:
type: array items: Unprocessable_Entity_Response_Schema
- 500:
description: Server not available to satisfy the request. schema: Internal_Server_Error_Response_Schema
-
schema
¶ alias of
schema.data.Data_Schema
-
Schema¶
-
class
schema.base.
Base_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)[source]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Agent¶
Catalog¶
-
class
schema.agent.catalog.
Agent_Catalog_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents an agent in the catalog.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
doc
¶
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.catalog.
Agent_Catalog_Action_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Agent action.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.catalog.
Agent_Catalog_Action_Config_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Agent action configuration.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.catalog.
Agent_Catalog_Parameter_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Agent parameter.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.catalog.
Agent_Catalog_Parameter_Config_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Agent parameter configuration.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.catalog.
Agent_Catalog_Resource_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Agent resource.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.catalog.
Agent_Catalog_Resource_Config_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Agent resource configuration.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Instance¶
-
class
schema.agent.instance.
Agent_Instance_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents an agent instance installed in an execution environment.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
doc
¶
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.instance.
Agent_Instance_Operation_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents the operations to perform with the agent instance installed in an execution environment.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.instance.
Agent_Instance_Action_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Action of the agent instance installed in an execution environment.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.instance.
Agent_Instance_Parameter_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Parameter of the agent instance installed in an execution environment.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.agent.instance.
Agent_Instance_Resource_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Resource of the agent instance installed in an execution environment.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
eBPF Program¶
Catalog¶
-
class
schema.ebpf_program.catalog.
eBPF_Program_Catalog_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents an eBPF program in the catalog.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.ebpf_program.catalog.
eBPF_Program_Catalog_Parameter_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ eBPF program configuration.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.ebpf_program.catalog.
eBPF_Program_Catalog_Config_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ eBPF program configuration.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.ebpf_program.catalog.
eBPF_Program_Catalog_Config_Metric_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ eBPF program metric.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.ebpf_program.catalog.
eBPF_Program_Catalog_Config_Metric_Open_Metrics_Metadata_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ eBPF program Open Metrics metadata.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.ebpf_program.catalog.
eBPF_Program_Catalog_Config_Metric_Open_Metrics_Metadata_Label_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ eBPF program Open Metrics metadata label.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Instance¶
-
class
schema.ebpf_program.instance.
eBPF_Program_Instance_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents an eBPF program instance installed in an execution environment.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.ebpf_program.instance.
eBPF_Program_Instance_Parameter_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Parameter of the eBPF program instance installed in an execution environment.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Execution Environment¶
-
class
schema.exec_env.
LCP_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Configuration of the LCP running in the execution environment.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.exec_env.
Exec_Env_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents an execution environment.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
doc
¶ alias of
document.exec_env.Exec_Env_Document
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.exec_env.
Exec_Env_Type_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents an execution environment type.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
doc
¶
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Network Link¶
-
class
schema.network_link.
Network_Link_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents a network link.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
doc
¶
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.network_link.
Network_Link_Type_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents a network link type.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
doc
¶
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Connection¶
-
class
schema.connection.
Connection_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents an connection between execution environments and network links.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
doc
¶
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Data¶
-
class
schema.data.
Data_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents the stored data.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
doc
¶ alias of
document.data.Data_Document
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Query Request¶
-
class
schema.query_request.
Query_Request_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Query request to filter the items.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.query_request.
Query_Request_Order_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Order the filtered items.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.query_request.
Query_Request_Limit_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Limit the items to return.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.query_request.
Query_Request_Filter_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ For numeric comparison in the clause.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.query_request.
Query_Request_Clause_Schema
(*args, method=None, check_unique_id=False, **kwargs)[source]¶ Represents a clause to filter a item based on various conditions.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data, response_type=<class 'lib.response.Ok_Response'>, id=None)¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Response¶
-
class
schema.response.
Exception_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Base_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ Response for the item creation.
-
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Bad_Request_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Conflict_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Content_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Created_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
No_Content_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Not_Acceptable_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Not_Found_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Not_Modified_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Ok_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Reset_Content_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
alias of
marshmallow.schema.SchemaOpts
Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
Apply then flatten nested schema options. This method is private API.
Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
Dictionary mapping field_names ->
Field
objects
Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
Hook to modify a field when it is bound to the Schema.
No-op by default.
Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
schema.response.
Unprocessable_Entity_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
-
class
schema.response.
Unsupported_Media_Type_Response_Schema
(*, only: Optional[Union[Sequence[str], Set[str]]] = None, exclude: Union[Sequence[str], Set[str]] = (), many: bool = False, context: Optional[Dict] = None, load_only: Union[Sequence[str], Set[str]] = (), dump_only: Union[Sequence[str], Set[str]] = (), partial: Union[bool, Sequence[str], Set[str]] = False, unknown: Optional[str] = None)[source]¶ -
class
Meta
¶ Options object for a Schema.
Example usage:
class Meta: fields = ("id", "email", "date_created") exclude = ("password", "secret_attribute")
Available options:
fields
: Tuple or list of fields to include in the serialized result.additional
: Tuple or list of fields to include in addition to theexplicitly declared fields.
additional
andfields
are mutually-exclusive options.
include
: Dictionary of additional fields to include in the schema. It isusually better to define fields as class variables, but you may need to use this option, e.g., if your fields are Python keywords. May be an OrderedDict.
exclude
: Tuple or list of fields to exclude in the serialized result.Nested fields can be represented with dot delimiters.
dateformat
: Default format for Date <fields.Date> fields.datetimeformat
: Default format for DateTime <fields.DateTime> fields.timeformat
: Default format for Time <fields.Time> fields.render_module
: Module to use for loads <Schema.loads> and dumps <Schema.dumps>.Defaults to json from the standard library.
ordered
: If True, order serialization output according to theorder in which fields were declared. Output of Schema.dump will be a collections.OrderedDict.
index_errors
: If True, errors dictionaries will include the indexof invalid items in a collection.
load_only
: Tuple or list of fields to exclude from serialized results.dump_only
: Tuple or list of fields to exclude from deserializationunknown
: Whether to exclude, include, or raise an error for unknownfields in the data. Use EXCLUDE, INCLUDE or RAISE.
register
: Whether to register the Schema with marshmallow’s internalclass registry. Must be True if you intend to refer to this Schema by class name in Nested fields. Only set this to False when memory usage is critical. Defaults to True.
-
OPTIONS_CLASS
¶ alias of
marshmallow.schema.SchemaOpts
-
_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Bind field to the schema, setting any necessary attributes on the field (e.g. parent and name).
Also set field load_only and dump_only values if field_name was specified in
class Meta
.
-
static
_call_and_store
(getter_func, data, *, field_name, error_store, index=None)¶ Call
getter_func
withdata
as its argument, and store any ValidationErrors.- Parameters
getter_func (callable) – Function for getting the serialized/deserialized value from
data
.data – The data passed to
getter_func
.field_name (str) – Field name.
index (int) – Index of the item being validated, if validating a collection, otherwise None.
-
_deserialize
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, error_store: marshmallow.error_store.ErrorStore, many: bool = False, partial=False, unknown='raise', index=None) → Union[_T, List[_T]]¶ Deserialize
data
.- Parameters
data (dict) – The data to deserialize.
error_store (ErrorStore) – Structure to store errors.
many (bool) – True if
data
should be deserialized as a collection.partial (bool|tuple) – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE.
index (int) – Index of the item being serialized (for storing errors) if serializing a collection, otherwise None.
- Returns
A dictionary of the deserialized data.
-
_do_load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, postprocess: bool = True)¶ Deserialize data, returning the deserialized result. This method is private API.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to validate required fields. If its value is an iterable, only fields listed in that iterable will be ignored will be allowed missing. If True, all fields will be allowed missing. If None, the value for self.partial is used.
unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
postprocess – Whether to run post_load methods..
- Returns
Deserialized data
-
_init_fields
() → None¶ Update self.fields, self.load_fields, and self.dump_fields based on schema options. This method is private API.
-
_normalize_nested_options
() → None¶ Apply then flatten nested schema options. This method is private API.
-
_serialize
(obj: Union[_T, Iterable[_T]], *, many: bool = False)¶ Serialize
obj
.- Parameters
obj – The object(s) to serialize.
many (bool) – True if
data
should be serialized as a collection.
- Returns
A dictionary of the serialized data
Changed in version 1.0.0: Renamed from
marshal
.
-
dump
(obj: Any, *, many: Optional[bool] = None)¶ Serialize an object to native Python data types according to this Schema’s fields.
- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A dict of serialized data
- Return type
dict
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.Changed in version 3.0.0rc9: Validation no longer occurs upon serialization.
-
dumps
(obj: Any, *args, many: Optional[bool] = None, **kwargs)¶ Same as
dump()
, except return a JSON-encoded string.- Parameters
obj – The object to serialize.
many – Whether to serialize obj as a collection. If None, the value for self.many is used.
- Returns
A
json
string- Return type
str
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the serialized data rather than a
(data, errors)
duple. AValidationError
is raised ifobj
is invalid.
-
fields
¶ Dictionary mapping field_names ->
Field
objects
-
classmethod
from_dict
(fields: Dict[str, Union[marshmallow.fields.Field, type]], *, name: str = 'GeneratedSchema') → type¶ Generate a Schema class given a dictionary of fields.
from marshmallow import Schema, fields PersonSchema = Schema.from_dict({"name": fields.Str()}) print(PersonSchema().load({"name": "David"})) # => {'name': 'David'}
Generated schemas are not added to the class registry and therefore cannot be referred to by name in Nested fields.
- Parameters
fields (dict) – Dictionary mapping field names to field instances.
name (str) – Optional name for the class, which will appear in the
repr
for the class.
New in version 3.0.0.
-
get_attribute
(obj: Any, attr: str, default: Any)¶ Defines how to pull values from an object to serialize.
New in version 2.0.0.
Changed in version 3.0.0a1: Changed position of
obj
andattr
.
-
handle_error
(error: marshmallow.exceptions.ValidationError, data: Any, *, many: bool, **kwargs)¶ Custom error handler function for the schema.
- Parameters
error – The ValidationError raised during (de)serialization.
data – The original input data.
many – Value of
many
on dump or load.partial – Value of
partial
on load.
New in version 2.0.0.
Changed in version 3.0.0rc9: Receives many and partial (on deserialization) as keyword arguments.
-
load
(data: Union[Mapping[str, Any], Iterable[Mapping[str, Any]]], *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None)¶ Deserialize a data structure to an object defined by this Schema’s fields.
- Parameters
data – The data to deserialize.
many – Whether to deserialize data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
loads
(json_data: str, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None, unknown: Optional[str] = None, **kwargs)¶ Same as
load()
, except it takes a JSON string as input.- Parameters
json_data – A JSON string of the data to deserialize.
many – Whether to deserialize obj as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.unknown – Whether to exclude, include, or raise an error for unknown fields in the data. Use EXCLUDE, INCLUDE or RAISE. If None, the value for self.unknown is used.
- Returns
Deserialized data
New in version 1.0.0.
Changed in version 3.0.0b7: This method returns the deserialized data rather than a
(data, errors)
duple. AValidationError
is raised if invalid data are passed.
-
on_bind_field
(field_name: str, field_obj: marshmallow.fields.Field) → None¶ Hook to modify a field when it is bound to the Schema.
No-op by default.
-
validate
(data: Mapping, *, many: Optional[bool] = None, partial: Optional[Union[bool, Sequence[str], Set[str]]] = None) → Dict[str, List[str]]¶ Validate data against the schema, returning a dictionary of validation errors.
- Parameters
data – The data to validate.
many – Whether to validate data as a collection. If None, the value for self.many is used.
partial – Whether to ignore missing fields and not require any fields declared. Propagates down to
Nested
fields as well. If its value is an iterable, only missing fields listed in that iterable will be ignored. Use dot delimiters to specify nested fields.
- Returns
A dictionary of validation errors.
New in version 1.1.0.
-
class
Utils¶
Datetime¶
-
utils.datetime.
FORMAT
= '%Y-%m-%dT%H:%M:%S'¶ str(object=’’) -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.__str__() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to ‘strict’.