diff --git a/README.md b/README.md index a6cfdf5..438564a 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,10 @@ The Mediahaven Python library provides a way to communicate with MediaHaven via the v2 REST API. +## Documentation + +For more information about the internals of this library: see the automatically generated [documentation](/docs/README.md). + ## Usage ```python diff --git a/docs/README.md b/docs/README.md new file mode 100644 index 0000000..5a83492 --- /dev/null +++ b/docs/README.md @@ -0,0 +1,14 @@ +# Mediahaven-python Index + +> Auto-generated documentation index. + +A full list of `Mediahaven-python` project modules. + +- [MediaHaven](mediahaven/index.md#mediahaven) + - [Mediahaven](mediahaven/mediahaven.md#mediahaven) + - [Oauth2](mediahaven/oauth2.md#oauth2) + - [Resources](mediahaven/resources/index.md#resources) + - [BaseResource](mediahaven/resources/base_resource.md#baseresource) + - [FieldDefinitions](mediahaven/resources/field_definitions.md#fielddefinitions) + - [Organisations](mediahaven/resources/organisations.md#organisations) + - [Records](mediahaven/resources/records.md#records) diff --git a/docs/mediahaven/index.md b/docs/mediahaven/index.md new file mode 100644 index 0000000..c0d28bd --- /dev/null +++ b/docs/mediahaven/index.md @@ -0,0 +1,34 @@ +# MediaHaven + +[Mediahaven-python Index](../README.md#mediahaven-python-index) / +MediaHaven + +> Auto-generated documentation for [mediahaven](../../mediahaven/__init__.py) module. + +- [MediaHaven](#mediahaven) + - [MediaHaven](#mediahaven-1) + - [Modules](#modules) + +## MediaHaven + +[Show source in __init__.py:12](../../mediahaven/__init__.py#L12) + +#### Signature + +```python +class MediaHaven(MediaHavenClient): + def __init__(self, *args, **kwargs): + ... +``` + +#### See also + +- [MediaHavenClient](./mediahaven.md#mediahavenclient) + + + +## Modules + +- [Mediahaven](./mediahaven.md) +- [Oauth2](./oauth2.md) +- [Resources](resources/index.md) \ No newline at end of file diff --git a/docs/mediahaven/mediahaven.md b/docs/mediahaven/mediahaven.md new file mode 100644 index 0000000..a3f3485 --- /dev/null +++ b/docs/mediahaven/mediahaven.md @@ -0,0 +1,57 @@ +# Mediahaven + +[Mediahaven-python Index](../README.md#mediahaven-python-index) / +[MediaHaven](./index.md#mediahaven) / +Mediahaven + +> Auto-generated documentation for [mediahaven.mediahaven](../../mediahaven/mediahaven.py) module. + +- [Mediahaven](#mediahaven) + - [AcceptFormat](#acceptformat) + - [MediaHavenClient](#mediahavenclient) + - [MediaHavenException](#mediahavenexception) + +## AcceptFormat + +[Show source in mediahaven.py:31](../../mediahaven/mediahaven.py#L31) + +#### Signature + +```python +class AcceptFormat(Enum): + ... +``` + + + +## MediaHavenClient + +[Show source in mediahaven.py:42](../../mediahaven/mediahaven.py#L42) + +The MediaHaven client class to communicate with MediaHaven. + +#### Signature + +```python +class MediaHavenClient: + def __init__(self, mh_base_url: str, grant: OAuth2Grant): + ... +``` + +#### See also + +- [OAuth2Grant](./oauth2.md#oauth2grant) + + + +## MediaHavenException + +[Show source in mediahaven.py:25](../../mediahaven/mediahaven.py#L25) + +#### Signature + +```python +class MediaHavenException(Exception): + def __init__(self, message: str, status_code: int = None): + ... +``` \ No newline at end of file diff --git a/docs/mediahaven/oauth2.md b/docs/mediahaven/oauth2.md new file mode 100644 index 0000000..b334b7d --- /dev/null +++ b/docs/mediahaven/oauth2.md @@ -0,0 +1,157 @@ +# Oauth2 + +[Mediahaven-python Index](../README.md#mediahaven-python-index) / +[MediaHaven](./index.md#mediahaven) / +Oauth2 + +> Auto-generated documentation for [mediahaven.oauth2](../../mediahaven/oauth2.py) module. + +- [Oauth2](#oauth2) + - [NoTokenError](#notokenerror) + - [OAuth2Grant](#oauth2grant) + - [OAuth2Grant().refresh_token](#oauth2grant()refresh_token) + - [OAuth2Grant().request_token](#oauth2grant()request_token) + - [ROPCGrant](#ropcgrant) + - [ROPCGrant().request_token](#ropcgrant()request_token) + - [RefreshTokenError](#refreshtokenerror) + - [RequestTokenError](#requesttokenerror) + +## NoTokenError + +[Show source in oauth2.py:38](../../mediahaven/oauth2.py#L38) + +Raised when a token has not been requested yet. + +#### Signature + +```python +class NoTokenError(Exception): + def __init__(self): + ... +``` + + + +## OAuth2Grant + +[Show source in oauth2.py:45](../../mediahaven/oauth2.py#L45) + +Abstract class representing an OAuth2 grant used in MediaHaven. + +#### Signature + +```python +class OAuth2Grant(ABC): + def __init__(self, mh_base_url: str, client_id: str, client_secret: str): + ... +``` + +### OAuth2Grant().refresh_token + +[Show source in oauth2.py:67](../../mediahaven/oauth2.py#L67) + +Refresh the OAuth2 token with the saved refresh token. + +Issues a new access token but also a new refresh token. + +#### Signature + +```python +def refresh_token(self): + ... +``` + +### OAuth2Grant().request_token + +[Show source in oauth2.py:63](../../mediahaven/oauth2.py#L63) + +#### Signature + +```python +@abstractmethod +def request_token(self): + ... +``` + + + +## ROPCGrant + +[Show source in oauth2.py:96](../../mediahaven/oauth2.py#L96) + +Represents a "Resource Owner Password Credential" grant. + +#### Signature + +```python +class ROPCGrant(OAuth2Grant): + def __init__(self, mh_base_url: str, client_id: str, client_secret: str): + ... +``` + +#### See also + +- [OAuth2Grant](#oauth2grant) + +### ROPCGrant().request_token + +[Show source in oauth2.py:104](../../mediahaven/oauth2.py#L104) + +Request an OAuth2 token. + +The resource owner grants the client the authorization to execute the +requests on its behalf. Given the credentials of the resource owner, an auth +token is issued by the authorization server. This token will be saved in memory +and used by the session in order to execute authorized requests. + +#### Arguments + +- `username` - The username of the resource owner. +- `password` - The password of the resource owner. + +#### Raises + +- `RequestTokenException` - When an error occurred when requesting the token. + +#### Signature + +```python +def request_token(self, username: str, password: str): + ... +``` + + + +## RefreshTokenError + +[Show source in oauth2.py:28](../../mediahaven/oauth2.py#L28) + +Raised when an error occurred during token request. + +Abstracts the underlying OAuthlib2 errors. + +#### Signature + +```python +class RefreshTokenError(Exception): + def __init__(self): + ... +``` + + + +## RequestTokenError + +[Show source in oauth2.py:18](../../mediahaven/oauth2.py#L18) + +Raised when an error occurred during token request. + +Abstracts the underlying OAuthlib2 errors. + +#### Signature + +```python +class RequestTokenError(Exception): + def __init__(self): + ... +``` \ No newline at end of file diff --git a/docs/mediahaven/resources/base_resource.md b/docs/mediahaven/resources/base_resource.md new file mode 100644 index 0000000..9361a98 --- /dev/null +++ b/docs/mediahaven/resources/base_resource.md @@ -0,0 +1,453 @@ +# BaseResource + +[Mediahaven-python Index](../../README.md#mediahaven-python-index) / +[MediaHaven](../index.md#mediahaven) / +[Resources](./index.md#resources) / +BaseResource + +> Auto-generated documentation for [mediahaven.resources.base_resource](../../../mediahaven/resources/base_resource.py) module. + +- [BaseResource](#baseresource) + - [BaseResource](#baseresource-1) + - [BaseResource().mh_client](#baseresource()mh_client) + - [BaseResource().name](#baseresource()name) + - [MediaHavenPageObject](#mediahavenpageobject) + - [MediaHavenPageObject().as_generator](#mediahavenpageobject()as_generator) + - [MediaHavenPageObject().has_more](#mediahavenpageobject()has_more) + - [MediaHavenPageObject().next_page](#mediahavenpageobject()next_page) + - [MediaHavenPageObject().nr_of_results](#mediahavenpageobject()nr_of_results) + - [MediaHavenPageObject().page_result](#mediahavenpageobject()page_result) + - [MediaHavenPageObject().raw_response](#mediahavenpageobject()raw_response) + - [MediaHavenPageObject().start_index](#mediahavenpageobject()start_index) + - [MediaHavenPageObject().total_nr_of_results](#mediahavenpageobject()total_nr_of_results) + - [MediaHavenPageObjectCreator](#mediahavenpageobjectcreator) + - [MediaHavenPageObjectCreator.create_object](#mediahavenpageobjectcreatorcreate_object) + - [MediaHavenPageObjectJSON](#mediahavenpageobjectjson) + - [MediaHavenPageObjectJSON().as_generator](#mediahavenpageobjectjson()as_generator) + - [MediaHavenPageObjectJSON().next_page](#mediahavenpageobjectjson()next_page) + - [MediaHavenSingleObject](#mediahavensingleobject) + - [MediaHavenSingleObject().raw_response](#mediahavensingleobject()raw_response) + - [MediaHavenSingleObject().single_result](#mediahavensingleobject()single_result) + - [MediaHavenSingleObjectCreator](#mediahavensingleobjectcreator) + - [MediaHavenSingleObjectCreator.create_object](#mediahavensingleobjectcreatorcreate_object) + - [MediaHavenSingleObjectJSON](#mediahavensingleobjectjson) + - [NoMorePagesException](#nomorepagesexception) + +## BaseResource + +[Show source in base_resource.py:13](../../../mediahaven/resources/base_resource.py#L13) + +Base API endpoint of a MediaHaven resource. + +#### Attributes + +- `_mh_client` - The MediaHaven client used to execute requests. +- `_name` - The name of the resource. + +#### Signature + +```python +class BaseResource: + def __init__(self, mh_client: MediaHavenClient): + ... +``` + +#### See also + +- [MediaHavenClient](../mediahaven.md#mediahavenclient) + +### BaseResource().mh_client + +[Show source in base_resource.py:34](../../../mediahaven/resources/base_resource.py#L34) + +#### Signature + +```python +@property +def mh_client(self): + ... +``` + +### BaseResource().name + +[Show source in base_resource.py:30](../../../mediahaven/resources/base_resource.py#L30) + +#### Signature + +```python +@property +def name(self): + ... +``` + + + +## MediaHavenPageObject + +[Show source in base_resource.py:125](../../../mediahaven/resources/base_resource.py#L125) + +Represents a paged result. + +As this is a paged result, other pages could be available. The resource which +executed the request together with query parameters are passed as arguments in +other to potentially execute subsequent page requests. + +#### Attributes + +- `_start_index` - The start index of the executed search request. +- `_nr_of_results` - The number of results of the search result. +- `_total_nr_of_results` - The total number of results of search request. +- `_has_more` - Indicating if there are more pages left. +- `_resource` - The resource that executed the request. +- `_query_params` - The query parameters used in the request. +- `_raw_response` - The raw body of the response. +- `_page_result` - The payload of the response transformed depending on the type. + +#### Signature + +```python +class MediaHavenPageObject(ABC): + def __init__(self, response: Response, resource: BaseResource, **query_params): + ... +``` + +#### See also + +- [BaseResource](#baseresource) + +### MediaHavenPageObject().as_generator + +[Show source in base_resource.py:172](../../../mediahaven/resources/base_resource.py#L172) + +Returns a generator for all the result items spread over all the pages. + +#### Returns + +A generator. + +#### Signature + +```python +@abstractmethod +def as_generator(self) -> Generator[Union[SimpleNamespace, str], None, None]: + ... +``` + +### MediaHavenPageObject().has_more + +[Show source in base_resource.py:185](../../../mediahaven/resources/base_resource.py#L185) + +#### Signature + +```python +@property +def has_more(self): + ... +``` + +### MediaHavenPageObject().next_page + +[Show source in base_resource.py:160](../../../mediahaven/resources/base_resource.py#L160) + +Fetches the next page. + +#### Returns + +The next page. + +#### Raises + +NoMorePagesException if there are no pages left. + +#### Signature + +```python +@abstractmethod +def next_page(self) -> MediaHavenPageObject: + ... +``` + +### MediaHavenPageObject().nr_of_results + +[Show source in base_resource.py:189](../../../mediahaven/resources/base_resource.py#L189) + +#### Signature + +```python +@property +def nr_of_results(self): + ... +``` + +### MediaHavenPageObject().page_result + +[Show source in base_resource.py:181](../../../mediahaven/resources/base_resource.py#L181) + +#### Signature + +```python +@property +def page_result(self): + ... +``` + +### MediaHavenPageObject().raw_response + +[Show source in base_resource.py:201](../../../mediahaven/resources/base_resource.py#L201) + +#### Signature + +```python +@property +def raw_response(self): + ... +``` + +### MediaHavenPageObject().start_index + +[Show source in base_resource.py:197](../../../mediahaven/resources/base_resource.py#L197) + +#### Signature + +```python +@property +def start_index(self): + ... +``` + +### MediaHavenPageObject().total_nr_of_results + +[Show source in base_resource.py:193](../../../mediahaven/resources/base_resource.py#L193) + +#### Signature + +```python +@property +def total_nr_of_results(self): + ... +``` + + + +## MediaHavenPageObjectCreator + +[Show source in base_resource.py:243](../../../mediahaven/resources/base_resource.py#L243) + +Factory class for creating an object which is a subclass of MediaHavenPageObject. + +#### Signature + +```python +class MediaHavenPageObjectCreator: + ... +``` + +### MediaHavenPageObjectCreator.create_object + +[Show source in base_resource.py:246](../../../mediahaven/resources/base_resource.py#L246) + +Create a MediaHavenPageObject. + +As this is a paged result, other pages could be available. The resource which +executed the request together with query parameters are passed as arguments in +other to potentially execute subsequent page requests. + +#### Arguments + +- `response` - The HTTP response. +- `accept_format` - To determine the format of the result (XML/JSON). +- `resource` - The resource that executed the initial request. +- `**query_params` - The optional query parameters. + +#### Returns + +The MediaHavenPageObject. + +#### Raises + +- `NotImplementedError` - When passing an XML format. + +#### Signature + +```python +@staticmethod +def create_object( + response: Response, + accept_format: AcceptFormat, + resource: BaseResource, + **query_params +) -> MediaHavenPageObject: + ... +``` + +#### See also + +- [AcceptFormat](../mediahaven.md#acceptformat) +- [BaseResource](#baseresource) +- [MediaHavenPageObject](#mediahavenpageobject) + + + +## MediaHavenPageObjectJSON + +[Show source in base_resource.py:206](../../../mediahaven/resources/base_resource.py#L206) + +#### Signature + +```python +class MediaHavenPageObjectJSON(MediaHavenPageObject): + def __init__(self, response: Response, resource: BaseResource, **query_params): + ... +``` + +#### See also + +- [BaseResource](#baseresource) +- [MediaHavenPageObject](#mediahavenpageobject) + +### MediaHavenPageObjectJSON().as_generator + +[Show source in base_resource.py:231](../../../mediahaven/resources/base_resource.py#L231) + +#### Signature + +```python +def as_generator(self) -> Generator[SimpleNamespace, None, None]: + ... +``` + +### MediaHavenPageObjectJSON().next_page + +[Show source in base_resource.py:223](../../../mediahaven/resources/base_resource.py#L223) + +#### Signature + +```python +def next_page(self) -> MediaHavenPageObjectJSON: + ... +``` + + + +## MediaHavenSingleObject + +[Show source in base_resource.py:61](../../../mediahaven/resources/base_resource.py#L61) + +Represents a single result. + +#### Attributes + +- `_raw_response` - The raw body of the response. +- `_single_result` - The payload of the response transformed depending on the type. + +#### Signature + +```python +class MediaHavenSingleObject(ABC): + def __init__(self, response: Response): + ... +``` + +### MediaHavenSingleObject().raw_response + +[Show source in base_resource.py:82](../../../mediahaven/resources/base_resource.py#L82) + +#### Signature + +```python +@property +def raw_response(self): + ... +``` + +### MediaHavenSingleObject().single_result + +[Show source in base_resource.py:78](../../../mediahaven/resources/base_resource.py#L78) + +#### Signature + +```python +@property +def single_result(self): + ... +``` + + + +## MediaHavenSingleObjectCreator + +[Show source in base_resource.py:98](../../../mediahaven/resources/base_resource.py#L98) + +Factory class for creating an object which is a subclass of MediaHavenSingleObject. + +#### Signature + +```python +class MediaHavenSingleObjectCreator: + ... +``` + +### MediaHavenSingleObjectCreator.create_object + +[Show source in base_resource.py:101](../../../mediahaven/resources/base_resource.py#L101) + +Create a MediaHavenSingleObject. + +#### Arguments + +- `response` - The HTTP response. + +#### Returns + +The MediaHavenSingleObject. + +#### Raises + +- `NotImplementedError` - When passing an XML format. + +#### Signature + +```python +@staticmethod +def create_object( + response: Response, accept_format: AcceptFormat +) -> MediaHavenSingleObject: + ... +``` + +#### See also + +- [AcceptFormat](../mediahaven.md#acceptformat) +- [MediaHavenSingleObject](#mediahavensingleobject) + + + +## MediaHavenSingleObjectJSON + +[Show source in base_resource.py:87](../../../mediahaven/resources/base_resource.py#L87) + +#### Signature + +```python +class MediaHavenSingleObjectJSON(MediaHavenSingleObject): + def __init__(self, response: Response): + ... +``` + +#### See also + +- [MediaHavenSingleObject](#mediahavensingleobject) + + + +## NoMorePagesException + +[Show source in base_resource.py:120](../../../mediahaven/resources/base_resource.py#L120) + +#### Signature + +```python +class NoMorePagesException(Exception): + def __init__(self): + ... +``` \ No newline at end of file diff --git a/docs/mediahaven/resources/field_definitions.md b/docs/mediahaven/resources/field_definitions.md new file mode 100644 index 0000000..3477a6a --- /dev/null +++ b/docs/mediahaven/resources/field_definitions.md @@ -0,0 +1,95 @@ +# FieldDefinitions + +[Mediahaven-python Index](../../README.md#mediahaven-python-index) / +[MediaHaven](../index.md#mediahaven) / +[Resources](./index.md#resources) / +FieldDefinitions + +> Auto-generated documentation for [mediahaven.resources.field_definitions](../../../mediahaven/resources/field_definitions.py) module. + +- [FieldDefinitions](#fielddefinitions) + - [FieldDefinitions](#fielddefinitions-1) + - [FieldDefinitions().get](#fielddefinitions()get) + - [FieldDefinitions().search](#fielddefinitions()search) + +## FieldDefinitions + +[Show source in field_definitions.py:15](../../../mediahaven/resources/field_definitions.py#L15) + +Public API endpoint of MediaHaven field definitions. + +#### Signature + +```python +class FieldDefinitions(BaseResource): + def __init__(self, *args, **kwargs): + ... +``` + +#### See also + +- [BaseResource](./base_resource.md#baseresource) + +### FieldDefinitions().get + +[Show source in field_definitions.py:22](../../../mediahaven/resources/field_definitions.py#L22) + +Get a single field definition. + +#### Arguments + +- `field` - The id or FlatKey of a metadata field definition. +- `accept_format` - The "Accept" request header. + +#### Returns + +A single metadata field definition. + +#### Signature + +```python +def get( + self, field: str = None, accept_format=DEFAULT_ACCEPT_FORMAT +) -> MediaHavenSingleObject: + ... +``` + +#### See also + +- [DEFAULT_ACCEPT_FORMAT](../mediahaven.md#default_accept_format) +- [MediaHavenSingleObject](./base_resource.md#mediahavensingleobject) + +### FieldDefinitions().search + +[Show source in field_definitions.py:41](../../../mediahaven/resources/field_definitions.py#L41) + +Search all field definitions. + +#### Arguments + +- `accept_format` - The "Accept" request header. +- `**query_params` - The optional query paramaters: + - `query_params["startIndex"]` - Used for pagination of search results, + search results will be returned starting from this index. + - `query_params["nrOfResults"]` - the number of results that will be returned. + - `query_params["nested"]` - If true include children and parents in the response, + default is false. + - `query_params["sort"]` - Determine how to sort the field definitions. (FieldDefinitionId or LongTranslation). + +#### Returns + +A paged result with the metadata field definitions. + +#### Signature + +```python +def search( + self, accept_format: str = DEFAULT_ACCEPT_FORMAT, **query_params +) -> MediaHavenPageObject: + ... +``` + +#### See also + +- [DEFAULT_ACCEPT_FORMAT](../mediahaven.md#default_accept_format) +- [MediaHavenPageObject](./base_resource.md#mediahavenpageobject) \ No newline at end of file diff --git a/docs/mediahaven/resources/index.md b/docs/mediahaven/resources/index.md new file mode 100644 index 0000000..6ef25ec --- /dev/null +++ b/docs/mediahaven/resources/index.md @@ -0,0 +1,17 @@ +# Resources + +[Mediahaven-python Index](../../README.md#mediahaven-python-index) / +[MediaHaven](../index.md#mediahaven) / +Resources + +> Auto-generated documentation for [mediahaven.resources](../../../mediahaven/resources/__init__.py) module. + +- [Resources](#resources) + - [Modules](#modules) + +## Modules + +- [BaseResource](./base_resource.md) +- [FieldDefinitions](./field_definitions.md) +- [Organisations](./organisations.md) +- [Records](./records.md) \ No newline at end of file diff --git a/docs/mediahaven/resources/organisations.md b/docs/mediahaven/resources/organisations.md new file mode 100644 index 0000000..89b8c3c --- /dev/null +++ b/docs/mediahaven/resources/organisations.md @@ -0,0 +1,93 @@ +# Organisations + +[Mediahaven-python Index](../../README.md#mediahaven-python-index) / +[MediaHaven](../index.md#mediahaven) / +[Resources](./index.md#resources) / +Organisations + +> Auto-generated documentation for [mediahaven.resources.organisations](../../../mediahaven/resources/organisations.py) module. + +- [Organisations](#organisations) + - [Organisations](#organisations-1) + - [Organisations().get](#organisations()get) + - [Organisations().search](#organisations()search) + +## Organisations + +[Show source in organisations.py:15](../../../mediahaven/resources/organisations.py#L15) + +Public API endpoint of MediaHaven tenants. + +#### Signature + +```python +class Organisations(BaseResource): + def __init__(self, *args, **kwargs): + ... +``` + +#### See also + +- [BaseResource](./base_resource.md#baseresource) + +### Organisations().get + +[Show source in organisations.py:22](../../../mediahaven/resources/organisations.py#L22) + +Get a single organisation. + +#### Arguments + +- `organisation_id` - The id of an organisation. +- `accept_format` - The "Accept" request header. + +#### Returns + +A single organisation. + +#### Signature + +```python +def get( + self, organisation_id: str, accept_format=DEFAULT_ACCEPT_FORMAT +) -> MediaHavenSingleObject: + ... +``` + +#### See also + +- [DEFAULT_ACCEPT_FORMAT](../mediahaven.md#default_accept_format) +- [MediaHavenSingleObject](./base_resource.md#mediahavensingleobject) + +### Organisations().search + +[Show source in organisations.py:40](../../../mediahaven/resources/organisations.py#L40) + +Search all organisations. + +#### Arguments + +- `query` - The search query. +- `accept_format` - The "Accept" request header. +- `**query_params` - The optional query parameters: + - `query_params["startIndex"]` - Used for pagination of search results, + search results will be returned starting from this index. + - `query_params["nrOfResults"]` - The number of results that will be returned. + +#### Returns + +A paged result with the organisations. + +#### Signature + +```python +def search( + self, accept_format: str = DEFAULT_ACCEPT_FORMAT, **query_params +) -> MediaHavenPageObject: + ... +``` + +#### See also + +- [DEFAULT_ACCEPT_FORMAT](../mediahaven.md#default_accept_format) +- [MediaHavenPageObject](./base_resource.md#mediahavenpageobject) \ No newline at end of file diff --git a/docs/mediahaven/resources/records.md b/docs/mediahaven/resources/records.md new file mode 100644 index 0000000..e22c9b5 --- /dev/null +++ b/docs/mediahaven/resources/records.md @@ -0,0 +1,181 @@ +# Records + +[Mediahaven-python Index](../../README.md#mediahaven-python-index) / +[MediaHaven](../index.md#mediahaven) / +[Resources](./index.md#resources) / +Records + +> Auto-generated documentation for [mediahaven.resources.records](../../../mediahaven/resources/records.py) module. + +- [Records](#records) + - [Records](#records-1) + - [Records().count](#records()count) + - [Records().delete](#records()delete) + - [Records().get](#records()get) + - [Records().publish](#records()publish) + - [Records().search](#records()search) + - [Records().update](#records()update) + +## Records + +[Show source in records.py:15](../../../mediahaven/resources/records.py#L15) + +Public API endpoint of a MediaHaven record. + +#### Signature + +```python +class Records(BaseResource): + def __init__(self, *args, **kwargs): + ... +``` + +#### See also + +- [BaseResource](./base_resource.md#baseresource) + +### Records().count + +[Show source in records.py:22](../../../mediahaven/resources/records.py#L22) + +Counts the amount the records given a query string. + +#### Arguments + +- `query` - Free text search string. + +#### Returns + +The amount of records. + +#### Signature + +```python +def count(self, query: str) -> int: + ... +``` + +### Records().delete + +[Show source in records.py:81](../../../mediahaven/resources/records.py#L81) + +Delete a record. + +#### Arguments + +- `record_id` - The ID of the record to remove. + It can be either a MediaObjectId, FragmentId or RecordId. +- `reason` - The reason to delete the record. +- `event_type` - A custom subtype for the delete event. + +#### Signature + +```python +def delete(self, record_id: str, reason: str = None, event_type: str = None): + ... +``` + +### Records().get + +[Show source in records.py:36](../../../mediahaven/resources/records.py#L36) + +Get a single record. + +#### Arguments + +- `record_id` - It can either be a MediaObjectId, FragmentId or RecordId. +- `accept_format` - The "Accept" request header. + +#### Returns + +A single record. + +#### Signature + +```python +def get( + self, record_id: str, accept_format=DEFAULT_ACCEPT_FORMAT +) -> MediaHavenSingleObject: + ... +``` + +#### See also + +- [DEFAULT_ACCEPT_FORMAT](../mediahaven.md#default_accept_format) +- [MediaHavenSingleObject](./base_resource.md#mediahavensingleobject) + +### Records().publish + +[Show source in records.py:121](../../../mediahaven/resources/records.py#L121) + +Publishes a record. + +#### Arguments + +- `record_id` - The ID of the record to publish. + It can be either a MediaObjectId, FragmentId or RecordId. +- `reason` - The reason to publish the record. + +#### Signature + +```python +def publish(self, record_id: str, reason: str = None): + ... +``` + +### Records().search + +[Show source in records.py:54](../../../mediahaven/resources/records.py#L54) + +Search for multiple records. + +#### Arguments + +- `accept_format` - The "Accept" request header. +- `**query_params` - The optional query paramaters: + - `query_params["q"]` - Free text search string. + - `query_params["startIndex"]` - Used for pagination of search results, + search results will be returned starting from this index. + - `query_params["nrOfResults"]` - The number of results that will be returned. + - `query_params["publicOnly"]` - If true exclude from the output dynamic + metadata fields which were marked as non public in the Profiles + linked with the record. + +#### Returns + +A paged result with the records. + +#### Signature + +```python +def search( + self, accept_format=DEFAULT_ACCEPT_FORMAT, **query_params +) -> MediaHavenPageObject: + ... +``` + +#### See also + +- [DEFAULT_ACCEPT_FORMAT](../mediahaven.md#default_accept_format) +- [MediaHavenPageObject](./base_resource.md#mediahavenpageobject) + +### Records().update + +[Show source in records.py:103](../../../mediahaven/resources/records.py#L103) + +Update a record. + +#### Arguments + +- `record_id` - The ID of the record to remove. + It can be either a MediaObjectId, FragmentId or RecordId. +- `json` - The JSON payload. +- `xml` - The XML payload. +- `**form_data` - The payload as multipart/form-data. + +#### Signature + +```python +def update(self, record_id: str, json: dict = None, xml: str = None, **form_data): + ... +``` \ No newline at end of file diff --git a/generate_doc.sh b/generate_doc.sh new file mode 100644 index 0000000..d532569 --- /dev/null +++ b/generate_doc.sh @@ -0,0 +1,6 @@ +#!/bin/bash + +handsdown +mv docs/README.md . +sed -i 's/mediahaven\//docs\/mediahaven\//g' README.md +find docs/ -type f -exec sed -i 's/\.\.\/README\.md/..\/..\/README.md/g' {} \; \ No newline at end of file