Package: json-home-client
json_home_clientClient class for calling http+json APIs in Python. Requires Python 3.6+.Supports json home pages per:https://tools.ietf.org/html/draft-nottingham-json-home-06InstallationStandard python package installation:pip install json-home-clientUsageImport the json_home_client package and instantiate a client.from json_home_client import Client

   api = Client('http://api.example.com')Call APIs:result = api.call('foo', var1=arg1, var2=arg2)
   print result.dataClient classclass json_home_client.Client(base_url: str, version: str = None, username: str = None, password: str = None, user_agent: str = None,
sni_hostname: str = None, client_cert_path: str = None, client_key_path: str = None, ca_cert_path: str = None)The Client constructor takes the base URL for the api, an optional request version identifier, username and password.
It also allows a custom sni_hostname (useful when the url uses an ip address), client certificate and key,
and a custom CA file path.Client.base_url: strThe base URL set in the constructor, read-only.Client.default_version: Optional[str]The default version information for accept headers.Client.default_accept: MimeTypeThe default accept types for API calls.Client.username: Optional[str]Username to send in HTTP authentication header.Client.password: Optional[str]Password to send in HTTP authentication header.Client.user_agent: strThe User-Agent string to send in requests.Client.resource_names: Sequence[str]A list of available API resource names.Client.resource(name: str) -> ResourceGet a named Resource.Client.add_resource(name: str, url: str) -> NoneAdd a URL resource.Client.set_version(name: str, version: str = None) -> NoneSet the request version identifier for a specific resource. If not set, the default version identifer will be used.Client.set_accept(name: str, content_type: Union[MimeType, Sequence[MimeType]]) -> NoneSet the requested Content-Type(s) for a specific resource. If not set, 'application/json' will be used.Client.get(name: str, [kwargs]) -> Optional[Response]Perform an HTTP GET on the named resource. Any named arguments supplied may be used in computing the actual URL to call. Returns a Response or None if the resource name is not known.Client.post(name: str, payload: bytes, content_type: MimeType = None, [kwargs]) -> Optional[Response]Perform an HTTP POST on the named resource. Any named arguments supplied may be used in computing the actual URL to call. Returns a Response or None if the resource name is not known.Client.post_form(name: str, payload: Mapping[str, Any] = None, [kwargs]) -> Optional[Response]Perform an HTTP POST on the named resource. The payload, if present, will be URL form encoded. Any named arguments supplied may be used in computing the actual URL to call. Returns a Response or None if the resource name is not known.Client.post_json(name: str, payload: Any = None, [kwargs]) -> Optional[Response]Perform an HTTP POST on the named resource. The payload, if present, will be converted to JSON. Any named arguments supplied may be used in computing the actual URL to call. Returns a Response or None if the resource name is not known.Client.put(name: str, payload = None, content_type: MimeType = None, [kwargs]) -> Optional[Response]Perform an HTTP PUT on the named resource. The payload, if present, will be sent to the server using the provided Content-Type. The payload must be pre-encoded and will not be processed by the Client. Any named arguments supplied may be used in computing the actual URL to call. Returns a Response or None if the resource name is not known.Client.patch(name: str, patch: Mapping[str, Any] = None, content_type: MimeType = MimeType.JSON_PATCH, [kwargs]) -> Optional[Response]Perform an HTTP PATCH on the named resource. The patch, if present, will be encoded in JSON and sent to the server as a 'application/json-patch'. Any named arguments supplied may be used in computing the actual URL to call. Returns a Response or None if the resource name is not known.Client.delete(name: str, [kwargs]) -> Optional[Response]Perform an HTTP DELETE on the named resource. Any named arguments supplied may be used in computing the actual URL to call. Returns a Response or None if the resource name is not known.Response classResponse.status_code: intThe HTTP status code of the response.Response.headers: Mapping[str, Any]A dict of HTTP response headers.Response.conten_type: MimeTypeThe Content-Type of the response.Response.encoding: strThe encoding of the response.Response.data: AnyThe body of the response. If the contentType is json, the data will be decoded into native objects.Resource classDescribes the properties of an available API resource.Resource.templateThe URITemplate used when calling the resource.Resource.variablesA dict of variables that may be passed to the resource. Keys are variable names, values are the URL identifier of the variable, if available (seehttps://tools.ietf.org/html/draft-nottingham-json-home-06#section-4.1).Resource.hintsAn Hints object describing any hints for the resource (seehttps://tools.ietf.org/html/draft-nottingham-json-home-06#section-5).Hints classHints.http_methods: Sequence[str]A list of HTTP methods the resource may be called with.Hints.formats: Mapping[str, Sequence[MimeType]]A dict of formats available for each HTTP method. Keys are HTTP methods, values are a list of Content-Types available.Hints.ranges: Optional[Sequence[str]]A list of range specifiers.Hints.preferences: Optional[Sequence[str]]A list of preferences supported by the resource.Hints.preconditions: Optional[Sequence[str]]A list of preconditions required by the resource.Hints.auth: Optional[Sequence[Mapping[str, str]]]A list of authorization schemes accepted by the resource.Hints.docs: Optional[str]A URL for documentation for the resource.Hints.status: Optional[str]The status of the resource.MimeType classMimeType(mime_type: str = None, type: str = None, structure: str = None, subtype: str = None)Constructor, accepts a mime_type, which will be parsed, or individual components.MimeType.type: strThe primary type, e.g. "application/json" -> "application"MimeType.structure: Optional[str]The structure, e.g. "application/json" -> "json", "application/vnd.app.v1+json" -> "json"MimeType.subtype: Optional[str]The subtype, e.g. "application/vnd.app.v1+json" -> "vnd.app.v1"NotesResource names may be absolute URLs or relative to the base URL of the API.