API Elements

Python Refact contains a registry for the API Elements Refract Profile which provide conviences around interacting with API Elements.

from refract.json import JSONDeserialiser
from refract.contrib.apielements import registry

deserialiser = JSONDeserialiser(registry=registry)
parseResult = deserialiser.deserialise('{"element": "parseResult"}')

if parseResult.errors:
    print('Parse Result contained errors')

ParseResult

class refract.contrib.apielements.ParseResult(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content=None)
annotations

Returns all of the annotations inside the parse result.

api

Returns an API category found within the parse result.

errors

Returns all of the error annotations in the parse result.

warnings

Returns all of the warning annotations in the parse result.

Annotation

class refract.contrib.apielements.Annotation(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content: str = None)

Category

class refract.contrib.apielements.Category(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content=None)
resourceGroups

Returns the resource group categories found within the category.

resources

Returns the resource elements found within the category.

transitions

Returns the transition elements found within the category.

Copy

class refract.contrib.apielements.Copy(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content: str = None)

Resource

class refract.contrib.apielements.Resource(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content=None)
transitions

Returns the transitions inside the resource.

Transition

class refract.contrib.apielements.Transition(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content=None)
transactions

Returns the HTTP transactions inside the transition.

HTTPTransaction

class refract.contrib.apielements.HTTPTransaction(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content=None)
request

Returns the first HTTPRequest in the transaction.

response

Returns the first HTTPResponse in the transaction.

HTTPRequest

class refract.contrib.apielements.HTTPRequest(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content=None)
assets

Returns the assets in the transaction.

body_asset

Returns the first body asset in the transaction.

body_schema_asset

Returns the first body schema asset in the transaction.

headers

Returns the header attributes for the HTTP message.

method

Returns the method attributes for the HTTP request.

HTTPResponse

class refract.contrib.apielements.HTTPResponse(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content=None)
assets

Returns the assets in the transaction.

body_asset

Returns the first body asset in the transaction.

body_schema_asset

Returns the first body schema asset in the transaction.

headers

Returns the header attributes for the HTTP message.

status_code

Returns the statuc code attribute for the HTTP response.

Asset

class refract.contrib.apielements.Asset(meta: refract.elements.base.Metadata = None, attributes: refract.elements.base.Attributes = None, content: str = None)
content_type

The content type of the asset