### Install Contentful Management SDK Source: https://github.com/contentful/contentful-management.py/blob/master/_docs/index.md Install the SDK using pip. This is the initial step before using any of the SDK's functionalities. ```bash sudo pip install contentful_management ``` -------------------------------- ### Local Python Environment Setup Source: https://github.com/contentful/contentful-management.py/blob/master/CONTRIBUTING.md Steps to clone the repository and install dependencies for a local Python development environment. The test group is required for running tests. ```bash # Clone git clone git@github.com:contentful/contentful-management.py.git cd contentful-management.py # Install dependencies (test group required to run tests) pdm install --group test # source: .devcontainer/devcontainer.json → postCreateCommand # Verify pdm run coverage # source: pyproject.toml → tool.pdm.scripts.coverage ``` -------------------------------- ### Start Dev Container (Terminal) Source: https://github.com/contentful/contentful-management.py/blob/master/CONTRIBUTING.md Use these commands to start the development container and enter it from the terminal. ```bash # Install dev container CLI npm install -g @devcontainers/cli # Start container and enter it devcontainer up --workspace-folder . devcontainer exec --workspace-folder . bash ``` -------------------------------- ### Conventional Commits Examples Source: https://github.com/contentful/contentful-management.py/blob/master/CONTRIBUTING.md Examples demonstrating the Conventional Commits format for commit messages, including valid types and an example with a ticket ID. ```bash feat: add taxonomy concept endpoints fix: preserve fields default value on update chore: route CI alerts to sdk-bots channel docs: add agent section to README build(deps): update requests dependencies [DX-886] ``` -------------------------------- ### Environment Management Source: https://github.com/contentful/contentful-management.py/blob/master/README.rst Examples for retrieving, finding, deleting, and creating environments within a Contentful space. ```APIDOC ## Environment Management ### Retrieving all environments on a space ```python # Using client environments = client.environments('my_space_id').all() # Using a fetched space object environments = space.environments().all() ``` ### Retrieving an environment by ID ```python # Using client environment = client.environments('my_space_id').find('environment_id') # Using a fetched space object environment = space.environments().find('environment_id') ``` ### Deleting an environment ```python # Using client client.environments('my_space_id').delete('environment_id') # Using a fetched space object space.environments().delete('environment_id') # Using a fetched environment object environment.delete() ``` ### Creating an environment ```python # Using client new_environment = client.environments('my_space_id').create( 'new_environment_id', { 'name': 'New Environment' } ) # Using a fetched space object new_environment = space.environments().create( 'new_environment_id', { 'name': 'New Environment' } ) ``` ### Creating an environment with a different source ```python # Using client new_environment = client.environments('my_space_id').create( 'new_environment_id', { 'name': 'New Environment', 'source_environment_id': 'other_environment' } ) ``` ``` -------------------------------- ### EnvironmentResourceProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/environment_resource_proxy.html Gets all resources related to the current space. ```APIDOC ## EnvironmentResourceProxy.all ### Description Gets all resources related to the current space. ### Method GET (implied) ### Endpoint Not explicitly defined, but operates on the current environment. ### Parameters #### Query Parameters - **query** (object) - Optional - Query parameters for filtering resources. ### Response #### Success Response (200) - **resources** (list) - A list of resources. ### Response Example ```json { "items": [ { ... resource object ... }, { ... resource object ... } ] } ``` ``` -------------------------------- ### EntryResourceProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/entry_resource_proxy.html Gets all resources related to the current entry. ```APIDOC ## EntryResourceProxy.all ### Description Gets all resources related to the current entry. ### Method GET ### Endpoint /spaces/{space_id}/environments/{environment_id}/entries/{entry_id}/{resource_type} ### Parameters #### Query Parameters - **query** (object) - Optional - Query parameters for filtering and pagination. ``` -------------------------------- ### Get Preview API Keys Proxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Instantiate the PreviewApiKeysProxy to manage preview API keys for a given space. ```python preview_api_keys_proxy = client.preview_api_keys('cfexampleapi') ``` -------------------------------- ### Get Preview API Keys Proxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Instantiate the PreviewApiKeysProxy to manage Preview API key settings for a space. ```python preview_api_keys_proxy = client.preview_api_keys('space_id') ``` -------------------------------- ### Get Environments Proxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/client.html Instantiate an EnvironmentsProxy to manage environments within a space. ```python environments_proxy = client.environments('cfexampleapi') ``` -------------------------------- ### Get Organizations Proxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Instantiate the OrganizationsProxy to manage organization-level settings. ```python organizations_proxy = client.organizations() ``` -------------------------------- ### Get Snapshots Proxy for Entries Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Instantiate the SnapshotsProxy to manage entry snapshots within a space and environment. ```python entry_snapshots_proxy = client.snapshots('cfexampleapi', 'master', 'nyancat') ``` -------------------------------- ### Asset Management Source: https://github.com/contentful/contentful-management.py/blob/master/README.rst Examples for retrieving, finding, deleting, creating, processing, updating, archiving, unarchiving, publishing, and unpublishing assets. ```APIDOC ## Asset Management ### Retrieving all assets on a space ```python # Using client assets = client.assets('my_space_id', 'environment_id').all() # Using a fetched environment object assets = environment.assets().all() ``` ### Retrieving an asset by ID ```python # Using client asset = client.assets('my_space_id', 'environment_id').find('asset_id') # Using a fetched environment object asset = environment.assets().find('asset_id') ``` ### Deleting an asset ```python # Using client client.assets('my_space_id', 'environment_id').delete('asset_id') # Using a fetched environment object environment.assets().delete('asset_id') # Using a fetched asset object asset.delete() ``` ### Creating an asset ```python file_attributes = { 'fields': { 'file': { 'en-US': { 'fileName': 'file.png', 'contentType': 'image/png', 'upload': 'https://url.to/file.png' } } } } # Using client new_asset = client.assets('my_space_id', 'environment_id').create( 'new_asset_id', file_attributes ) # Using a fetched environment object new_asset = environment.assets().create( 'new_asset_id', file_attributes ) ``` ### Processing an asset ```python asset.process() ``` ### Updating an asset ```python # Update with new file attributes asset.update(other_file_attributes) # Directly editing properties and saving asset.file['file_name'] = 'other_file.png' asset.save() ``` ### Archiving and Unarchiving an asset ```python asset.archive() asset.unarchive() ``` ### Publishing or Unpublishing an asset ```python asset.publish() asset.unpublish() ``` ### Checking asset status ```python # Check if published is_published = asset.is_published # Check if updated is_updated = asset.is_updated ``` ``` -------------------------------- ### Get Linkable System Properties Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/resource.html Returns a list of system property keys that should be treated as links. ```python def _linkables(self): return ['space', 'contentType', 'createdBy', 'updatedBy', 'publishedBy', 'environment'] ``` -------------------------------- ### Client Initialization Source: https://github.com/contentful/contentful-management.py/blob/master/_docs/index.md Demonstrates how to create a client instance using a management API token. ```APIDOC ## Client Initialization ### Description Create a client instance to interact with the Contentful Management API. ### Method ```python import contentful_management client = contentful_management.Client('MANAGEMENT_API_TOKEN') ``` ### Parameters * **MANAGEMENT_API_TOKEN** (string) - Your Contentful Management API token. ``` -------------------------------- ### Get Webhook Health Source: https://github.com/contentful/contentful-management.py/blob/master/docs/genindex.html Gets the health status of webhooks. ```APIDOC ## GET /webhooks/health ### Description Gets the health status of webhooks. ### Method GET ### Endpoint /webhooks/health ### Parameters (No parameters are explicitly documented in the source.) ### Response #### Success Response (200) (Details of the success response are not provided in the source.) #### Response Example (No example provided in the source.) ``` -------------------------------- ### Get Dateable System Properties Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/resource.html Returns a list of system property keys that represent dates and should be parsed. ```python def _dateables(self): return ['createdAt', 'updatedAt', 'deletedAt', 'firstPublishedAt', 'publishedAt', 'expiresAt'] ``` -------------------------------- ### GET Request Wrapper Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/client.html Wrapper for GET requests, utilizing the generic _request method. ```python def _get(self, url, query=None, **kwargs): """ Wrapper for the HTTP GET request. """ return self._request('get', url, query, **kwargs) ``` -------------------------------- ### Creating an Entry Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_sources/index.rst.txt Demonstrates how to create a new entry within a specified space and environment. You can either provide the space and environment IDs or use a pre-fetched environment object. ```APIDOC ## Creating an Entry ### Description Creates a new entry with the provided attributes. ### Method ```python client.entries(space_id, environment_id).create(entry_id, entry_attributes) # or environment.entries().create(entry_id, entry_attributes) ``` ### Parameters - `entry_id` (string): The unique identifier for the new entry. - `entry_attributes` (dict): A dictionary containing the entry's content type and fields. - `content_type_id` (string): The ID of the content type for the entry. - `fields` (dict): A dictionary of fields for the entry, with locale-specific values. ### Request Example ```python entry_attributes = { 'content_type_id': 'target_content_type', 'fields': { 'title': { 'en-US': 'My Awesome Post' }, 'body': { 'en-US': 'Once upon a time...' } } } # Using client new_entry = client.entries('my_space_id', 'environment_id').create( 'new_entry_id', entry_attributes ) # Using environment object new_entry = environment.entries().create( 'new_entry_id', entry_attributes ) ``` ``` -------------------------------- ### Client Initialization Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/client.html Constructs the API client with various configuration options. ```APIDOC ## Client ### Description Constructs the API client. ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Method __init__ ### Endpoint N/A ### Parameters * **access_token** (string) - API access token. * **api_url** (string) - (optional) URL of the Contentful API, defaults to Management API. * **uploads_api_url** (string) - (optional) URL of the Contentful upload API, defaults to Upload API. * **api_version** (integer) - (optional) Target version of the Contentful API. * **default_locale** (string) - (optional) Default locale for your spaces, defaults to 'en-US'. * **https** (boolean) - (optional) Boolean determining whether to use https or http, defaults to True. * **raw_mode** (boolean) - (optional) Boolean determining whether to process the response or return it raw after each API call, defaults to True. * **gzip_encoded** (boolean) - (optional) Boolean determining whether to accept gzip encoded results, defaults to True. * **raise_errors** (boolean) - (optional) Boolean determining whether to raise an exception on requests that aren't successful, defaults to True. * **proxy_host** (string) - (optional) URL for Proxy, defaults to None. * **proxy_port** (integer) - (optional) Port for Proxy, defaults to None. * **proxy_username** (string) - (optional) Username for Proxy, defaults to None. * **proxy_password** (string) - (optional) Password for Proxy, defaults to None. * **max_rate_limit_retries** (integer) - (optional) Maximum amount of retries after RateLimitError, defaults to 1. * **max_rate_limit_wait** (integer) - (optional) Timeout (in seconds) for waiting for retry after RateLimitError, defaults to 60. * **application_name** (string) - (optional) User application name, defaults to None. * **application_version** (string) - (optional) User application version, defaults to None. * **integration_name** (string) - (optional) Integration name, defaults to None. * **integration_version** (string) - (optional) Integration version, defaults to None. ### Returns :class:`Client ` object. ### Usage ```python import contentful_management client = contentful_management.Client('YOUR_MANAGEMENT_TOKEN') ``` ``` -------------------------------- ### HTTP GET Request Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/client.html Performs an HTTP GET request, normalizing query parameters before sending. ```python def _http_get(self, url, query, **kwargs): """ Performs the HTTP GET request. """ self._normalize_query(query) kwargs.update({'params': query}) return self._http_request('get', url, kwargs) ``` -------------------------------- ### Create an Entry Source: https://github.com/contentful/contentful-management.py/blob/master/_docs/index.md Use this to create a new entry. You can either use the client directly or a fetched environment. Ensure you provide the content type ID and entry attributes. ```python entry_attributes = { 'content_type_id': 'target_content_type', 'fields': { 'title': { 'en-US': 'My Awesome Post' }, 'body': { 'en-US': 'Once upon a time...' } } } new_entry = client.entries('my_space_id', 'environment_id').create( 'new_entry_id', entry_attributes ) # or if you already have a fetched environment new_entry = environment.entries().create( 'new_entry_id', entry_attributes ) ``` -------------------------------- ### Creating an Entry Source: https://github.com/contentful/contentful-management.py/blob/master/_docs/index.md Demonstrates how to create a new entry with specified attributes. ```APIDOC ## Creating an Entry ### Description Creates a new entry within a specified space and environment. ### Method POST (implied by create operation) ### Endpoint `/spaces/{space_id}/environments/{environment_id}/entries` ### Parameters #### Path Parameters - **space_id** (string) - Required - The ID of the space. - **environment_id** (string) - Required - The ID of the environment. #### Request Body - **entry_attributes** (object) - Required - Attributes for the new entry, including `content_type_id` and `fields`. - **content_type_id** (string) - Required - The ID of the content type for the entry. - **fields** (object) - Required - A map of field IDs to their localized values. - **field_id** (object) - Required - Localized field values. - **locale** (string) - Required - The locale code (e.g., 'en-US'). - **value** (any) - The field's value. ### Request Example ```python entry_attributes = { 'content_type_id': 'target_content_type', 'fields': { 'title': { 'en-US': 'My Awesome Post' }, 'body': { 'en-US': 'Once upon a time...' } } } new_entry = client.entries('my_space_id', 'environment_id').create( 'new_entry_id', entry_attributes ) ``` ### Response #### Success Response (200 or 201) - **entry** (object) - The newly created entry object. ``` -------------------------------- ### TaxonomyConceptSchemesProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/taxonomy_concept_schemes_proxy.html Gets all taxonomy concept schemes. ```APIDOC ## GET /organizations/{organization_id}/taxonomy/concept-schemes ### Description Gets all taxonomy concept schemes. ### Method GET ### Endpoint /organizations/{organization_id}/taxonomy/concept-schemes ### Parameters #### Query Parameters - **query** (dict) - Optional query parameters for filtering the results. - **kwargs** (dict) - Optional parameters for the request. ### Response #### Success Response (200) - **response** (dict) - JSON object containing a list of taxonomy concept schemes. ``` -------------------------------- ### Create a Content Type Source: https://github.com/contentful/contentful-management.py/blob/master/docs/index.html Demonstrates the creation of a new content type, including its name, description, and fields with validations. This can be initiated via the client or a fetched environment. ```python content_type_attributes = { 'name': 'Blog Post', 'description': 'Blog Posts to be included in ...' 'fields': [ { 'disabled': False, 'id': 'title', 'localized': True, 'name': 'Title', 'omitted': False, 'required': True, 'type': 'Symbol', 'validations': [ { 'size': {'min': 3} } ] }, { 'disabled': False, 'id': 'body', 'localized': True, 'name': 'Body', 'omitted': False, 'required': True, 'type': 'Text', 'validations': [] } ] } new_content_type = client.content_types('my_space_id', 'environment_id').create( 'new_ct_id', content_type_attributes ) ``` ```python new_content_type = environment.content_types().create( 'new_ct_id', content_type_attributes ) ``` -------------------------------- ### SpacesProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/spaces_proxy.html Gets all spaces available to the client. ```APIDOC ## SpacesProxy.all ### Description Gets all spaces. ### Method GET ### Endpoint /spaces ### Parameters #### Query Parameters - **query** (dict) - Optional - Query parameters for filtering spaces. ### Response #### Success Response (200) - **items** (list) - A list of space objects. #### Response Example { "items": [ { "sys": { "type": "Space", "id": "SPACE_ID" }, "name": "My Space" } ] } ``` -------------------------------- ### ClientProxy Initialization Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/client_proxy.html Initializes the ClientProxy with a client instance, space ID, and an optional environment ID. ```python def __init__(self, client, space_id, environment_id=None): self.client = client self.space_id = space_id self.environment_id = environment_id ``` -------------------------------- ### WebhookResourceProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/webhook_resource_proxy.html Gets all resources related to the current webhook. ```APIDOC ## WebhookResourceProxy.all ### Description Gets all resources related to the current webhook. ### Method GET (inferred from proxy.all) ### Endpoint [Endpoint not explicitly defined, inferred from proxy usage] ### Parameters #### Query Parameters - **query** (dict) - Optional - Query parameters for filtering resources. ``` -------------------------------- ### Manage Environments Source: https://github.com/contentful/contentful-management.py/blob/master/docs/index.html Demonstrates creating, finding, deleting, and managing environments within a space. Use 'master' as environment_id if environments are not explicitly enabled. ```python environments = client.environments('my_space_id').all() ``` ```python environments = space.environments().all() ``` ```python environment = client.environments('my_space_id').find('environment_id') ``` ```python environment = space.environments().find('environment_id') ``` ```python client.environments('my_space_id').delete('environment_id') ``` ```python space.environments().delete('environment_id') ``` ```python environment.delete() ``` ```python new_environment = client.environments('my_space_id').create( 'new_environment_id', { 'name': 'New Environment' } ) ``` ```python new_environment = space.environments().create( 'new_environment_id', { 'name': 'New Environment' } ) ``` ```python new_environment = client.environments('my_space_id').create( 'new_environment_id', { 'name': 'New Environment', 'source_environment_id': 'other_environment' } ) ``` -------------------------------- ### create() - PreviewApiKeysProxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/genindex.html Creates a new preview API key for a space. ```APIDOC ## create() - PreviewApiKeysProxy ### Description Creates a new API key specifically for accessing preview environments. ### Method POST ### Endpoint /spaces/{space_id}/preview_api_keys ### Parameters #### Path Parameters - **space_id** (string) - Required - The ID of the space. #### Request Body - **name** (string) - Required - The name of the preview API key. - **description** (string) - Optional - A description for the API key. - **roles** (array) - Required - A list of role IDs to associate with the API key. ``` -------------------------------- ### Initialize Contentful Management Client Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/client.html Instantiate the Client with your API access token. Optional parameters allow customization of API URLs, version, locale, and error handling. ```python import contentful_management client = contentful_management.Client('YOUR_MANAGEMENT_TOKEN') ``` -------------------------------- ### SpacePeriodicUsagesProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Gets all organization periodic usage grouped by space. ```APIDOC ## SpacePeriodicUsagesProxy.all ### Description Gets all organization periodic usage grouped by space. ### Method GET ### Endpoint /spaces/{space_id}/periodic_usages ### Parameters #### Query Parameters - **query** (object) - Optional - Query parameters for filtering results. ``` -------------------------------- ### TaxonomyConceptSchemesProxy.total Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/taxonomy_concept_schemes_proxy.html Gets the total number of taxonomy concept schemes. ```APIDOC ## GET /organizations/{organization_id}/taxonomy/concept-schemes/total ### Description Gets the total number of taxonomy concept schemes. ### Method GET ### Endpoint /organizations/{organization_id}/taxonomy/concept-schemes/total ### Parameters #### Query Parameters - **kwargs** (dict) - Optional parameters for the request. ### Response #### Success Response (200) - **response** (dict) - JSON object containing the total count. ``` -------------------------------- ### Get Snapshots Proxy for Content Types Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Instantiate the SnapshotsProxy to manage content type snapshots within a space and environment. ```python content_type_snapshots_proxy = client.snapshots('cfexampleapi', 'master', 'cat', 'content_types') ``` -------------------------------- ### Create API Key using Contentful Management SDK Source: https://github.com/contentful/contentful-management.py/blob/master/docs/index.html Shows how to create a new API key. This can be done via the client or a fetched space object. You can also specify multiple environments for the key. ```python new_api_key = client.api_keys('my_space_id').create({'name': 'My API Key'}) ``` ```python new_api_key = space.api_keys().create({'name': 'My API Key'}) ``` ```python environments = [ { "sys": { "type": "Link", "linkType": "Environment", "id": "master" } }, { "sys": { "type": "Link", "linkType": "Environment", "id": "staging" } } ] new_api_key = client.api_keys('my_space_id').create({'name': 'My API Key with environments', 'environments': environments}) ``` ```python new_api_key = space.api_keys().create({'name': 'My API Key with environments', 'environments': environments}) ``` -------------------------------- ### EditorInterfacesProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/editor_interfaces_proxy.html Gets the default editor interface for a content type. ```APIDOC ## EditorInterfacesProxy.all ### Description Gets the default editor interface. ### Method GET ### Endpoint /spaces/{space_id}/environments/{environment_id}/content_types/{content_type_id}/editor_interface ``` -------------------------------- ### Manage Assets Source: https://github.com/contentful/contentful-management.py/blob/master/docs/index.html Provides examples for retrieving, finding, deleting, creating, processing, updating, archiving, and publishing assets. Supports direct file uploads and asset state checks. ```python assets = client.assets('my_space_id', 'environment_id').all() ``` ```python assets = environment.assets().all() ``` ```python asset = client.assets('my_space_id', 'environment_id').find('asset_id') ``` ```python asset = environment.assets().find('asset_id') ``` ```python client.assets('my_space_id', 'environment_id').delete('asset_id') ``` ```python environment.assets().delete('asset_id') ``` ```python asset.delete() ``` ```python file_attributes = { 'fields': { 'file': { 'en-US': { 'fileName': 'file.png', 'contentType': 'image/png', 'upload': 'https://url.to/file.png' } } } } ``` ```python new_asset = client.assets('my_space_id', 'environment_id').create( 'new_asset_id', file_attributes ) ``` ```python new_asset = environment.assets().create( 'new_asset_id', file_attributes ) ``` ```python asset.process() ``` ```python asset.update(other_file_attributes) ``` ```python asset.file['file_name'] = 'other_file.png' asset.save() ``` ```python asset.archive() ``` ```python asset.unarchive() ``` ```python asset.publish() ``` ```python asset.unpublish() ``` ```python asset.is_published ``` ```python asset.is_updated ``` -------------------------------- ### ContentTypeEditorInterfacesProxy.all() Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/content_type_editor_interfaces_proxy.html Gets the default editor interface for a content type. ```APIDOC ## GET /content_types/{content_type_id}/editor_interface ### Description Gets the default editor interface for a content type. ### Method GET ### Endpoint /content_types/{content_type_id}/editor_interface ### Parameters #### Path Parameters - **content_type_id** (string) - Required - The ID of the content type. ### Response #### Success Response (200) - **editor_interface** (object) - The editor interface configuration. ``` -------------------------------- ### Creating a Content Type Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_sources/index.rst.txt Demonstrates how to create a new content type with specified attributes, including its name, description, and fields. ```APIDOC ## Creating a Content Type ### Description Creates a new content type with the provided attributes. ### Method ```python client.content_types(space_id, environment_id).create(content_type_id, content_type_attributes) # or environment.content_types().create(content_type_id, content_type_attributes) ``` ### Parameters - `content_type_id` (string): The unique identifier for the new content type. - `content_type_attributes` (dict): A dictionary containing the content type's properties. - `name` (string): The name of the content type. - `description` (string): A description for the content type. - `fields` (list): A list of field definitions for the content type. ### Request Example ```python content_type_attributes = { 'name': 'Blog Post', 'description': 'Blog Posts to be included in ...', 'fields': [ { 'disabled': False, 'id': 'title', 'localized': True, 'name': 'Title', 'omitted': False, 'required': True, 'type': 'Symbol', 'validations': [ { 'size': {'min': 3} } ] }, { 'disabled': False, 'id': 'body', 'localized': True, 'name': 'Body', 'omitted': False, 'required': True, 'type': 'Text', 'validations': [] } ] } # Using client new_content_type = client.content_types('my_space_id', 'environment_id').create( 'new_ct_id', content_type_attributes ) # Using environment object new_content_type = environment.content_types().create( 'new_ct_id', content_type_attributes ) ``` ``` -------------------------------- ### Get Space JSON Representation Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Returns the JSON representation of the space. ```APIDOC ## Space.to_json() ### Description Returns the JSON representation of the space. ### Usage ```python space_json = space.to_json() ``` ``` -------------------------------- ### Get Space Preview API Keys Proxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Use this to access preview API key management methods for a space. Requires a space object. ```python space_preview_api_keys_proxy = space.preview_api_keys() ``` -------------------------------- ### Fetch All Entries Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_sources/index.rst.txt Use the client to fetch all entries from a space. This operation requires a configured client instance. ```python client.entries().all() ``` -------------------------------- ### Get Current User Source: https://github.com/contentful/contentful-management.py/blob/master/docs/index.html Retrieves the information for the currently authenticated user. ```APIDOC ## Users ### Description Retrieving your User information. ### Method GET (Implicit) ### Endpoint `/users/me` ### Request Example ```python user = client.users().me() ``` ``` -------------------------------- ### Environment.create_headers Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/environment.html Headers for environment creation. ```APIDOC ## Environment.create_headers ### Description Headers for environment creation. ### Method classmethod ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **attributes** (dict) - Required - Attributes for environment creation, potentially including 'source_environment_id'. ``` -------------------------------- ### ContentTypeEditorInterfacesProxy.find() Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/content_type_editor_interfaces_proxy.html Gets the default editor interface for a content type. This is an alias for `all()`. ```APIDOC ## GET /content_types/{content_type_id}/editor_interface ### Description Gets the default editor interface for a content type. This is an alias for `all()`. ### Method GET ### Endpoint /content_types/{content_type_id}/editor_interface ### Parameters #### Path Parameters - **content_type_id** (string) - Required - The ID of the content type. ### Response #### Success Response (200) - **editor_interface** (object) - The editor interface configuration. ``` -------------------------------- ### PreviewApiKeysProxy.create Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/preview_api_keys_proxy.html This method is not supported for creating preview API keys. ```APIDOC ## PreviewApiKeysProxy.create ### Description Not supported for creating preview API keys. ### Method Not Supported ### Endpoint Not Supported ``` -------------------------------- ### OrganizationsProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Gets all organizations accessible by the client. This method retrieves a list of all organizations. ```APIDOC ## OrganizationsProxy.all ### Description Gets all organizations. ### Method GET ### Endpoint /organizations ``` -------------------------------- ### Get Spaces Proxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Instantiate the SpacesProxy to access space management methods. ```python spaces_proxy = client.spaces() ``` -------------------------------- ### Get Ancestors of Taxonomy Concept Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/taxonomy_concepts_proxy.html Retrieves all ancestors of a given taxonomy concept. ```APIDOC ## ancestors concept_id, query=None ### Description Gets ancestors of a taxonomy concept. ### Method GET ### Endpoint /organizations/{organization_id}/taxonomy/concepts/{concept_id}/ancestors ### Parameters #### Path Parameters - **concept_id** (string) - Required - The ID of the taxonomy concept whose ancestors to retrieve. #### Query Parameters - **query** (object) - Optional - Query parameters for filtering the request. - **kwargs** (object) - Optional - Additional keyword arguments for the request. ``` -------------------------------- ### Create Resource Attributes with Metadata Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/resource.html Prepares attributes for resource creation, handling metadata separately. ```python @classmethod def create_attributes(klass, attributes, previous_object=None): """ Attributes for resource creation. """ result = super(MetadataResource, klass).create_attributes(attributes, previous_object) if '_metadata' in attributes: result['metadata'] = attributes.pop('_metadata') return result ``` -------------------------------- ### Run Full Verification Loop Source: https://github.com/contentful/contentful-management.py/blob/master/AGENTS.md Execute the complete verification process, including installation of test dependencies and running coverage checks. This command ensures the project's build and quality standards are met. ```bash pdm install --group test && pdm run coverage ``` -------------------------------- ### Get Descendants of Taxonomy Concept Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/taxonomy_concepts_proxy.html Retrieves all descendants of a given taxonomy concept. ```APIDOC ## descendants concept_id, query=None ### Description Gets descendants of a taxonomy concept. ### Method GET ### Endpoint /organizations/{organization_id}/taxonomy/concepts/{concept_id}/descendants ### Parameters #### Path Parameters - **concept_id** (string) - Required - The ID of the taxonomy concept whose descendants to retrieve. #### Query Parameters - **query** (object) - Optional - Query parameters for filtering the request. - **kwargs** (object) - Optional - Additional keyword arguments for the request. ``` -------------------------------- ### Create Personal Access Token Source: https://github.com/contentful/contentful-management.py/blob/master/_docs/index.md Demonstrates how to create a new Personal Access Token with specified scopes. ```APIDOC ## Create Personal Access Token ### Description Creates a new Personal Access Token with a given name and set of scopes. ### Method `client.personal_access_tokens().create()` ### Parameters - `name` (string) - The name for the new Personal Access Token. - `scopes` (list of strings) - A list of scopes to grant to the token. ### Request Example ```python new_personal_access_token = client.personal_access_tokens().create({ 'name': 'My API Key', 'scopes': ['content_management_manage'] }) ``` ``` -------------------------------- ### EditorInterfacesProxy.default Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/editor_interfaces_proxy.html Gets the default editor interface for a content type. This is an alias for the `all` method. ```APIDOC ## EditorInterfacesProxy.default ### Description Gets the default editor interface. ### Method GET ### Endpoint /spaces/{space_id}/environments/{environment_id}/content_types/{content_type_id}/editor_interface ``` -------------------------------- ### Initialize Contentful Management Client Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Instantiate the Contentful Management client with your API access token. Other parameters can be optionally configured. ```python import contentful_management client = contentful_management.Client('YOUR_MANAGEMENT_TOKEN') ``` -------------------------------- ### EditorInterfacesProxy.find Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/editor_interfaces_proxy.html Gets the default editor interface for a content type. This is an alias for the `all` method. ```APIDOC ## EditorInterfacesProxy.find ### Description Gets the default editor interface. ### Method GET ### Endpoint /spaces/{space_id}/environments/{environment_id}/content_types/{content_type_id}/editor_interface ``` -------------------------------- ### Client Initialization Source: https://github.com/contentful/contentful-management.py/blob/master/docs/contentful_management.html Initializes the Contentful Management client with your API access token and optional parameters. ```APIDOC ## Client Initialization ### Description Constructs the API client for interacting with the Contentful Management API. ### Parameters * **access_token** (string) - Required - API access token. * **api_url** (string) - Optional - URL of the Contentful API, defaults to 'api.contentful.com'. * **uploads_api_url** (string) - Optional - URL of the Contentful upload API, defaults to 'upload.contentful.com'. * **api_version** (integer) - Optional - Target version of the Contentful API, defaults to 1. * **default_locale** (string) - Optional - Default locale for your spaces, defaults to 'en-US'. * **https** (boolean) - Optional - Determines whether to use https or http, defaults to True. * **raw_mode** (boolean) - Optional - Determines whether to process the response or return it raw after each API call, defaults to True. * **gzip_encoded** (boolean) - Optional - Determines whether to accept gzip encoded results, defaults to True. * **raise_errors** (boolean) - Optional - Determines whether to raise an exception on requests that aren’t successful, defaults to True. * **proxy_host** (string) - Optional - URL for Proxy, defaults to None. * **proxy_port** (integer) - Optional - Port for Proxy, defaults to None. * **proxy_username** (string) - Optional - Username for Proxy, defaults to None. * **proxy_password** (string) - Optional - Password for Proxy, defaults to None. * **max_rate_limit_retries** (integer) - Optional - Maximum amount of retries after RateLimitError, defaults to 1. * **max_rate_limit_wait** (integer) - Optional - Timeout (in seconds) for waiting for retry after RateLimitError, defaults to 60. * **application_name** (string) - Optional - User application name, defaults to None. * **application_version** (string) - Optional - User application version, defaults to None. * **integration_name** (string) - Optional - Integration name, defaults to None. * **integration_version** (string) - Optional - Integration version, defaults to None. ### Returns * contentful.Client - A Client object. ### Usage ```python import contentful_management client = contentful_management.Client('YOUR_MANAGEMENT_TOKEN') ``` ``` -------------------------------- ### Retrieve Preview API Keys Source: https://github.com/contentful/contentful-management.py/blob/master/_docs/index.md Shows how to retrieve all Preview API keys for a given space. ```APIDOC ## Retrieve Preview API Keys ### Description Retrieves all Preview API keys associated with a Contentful space. ### Method `client.preview_api_keys().all()` or `space.preview_api_keys().all()` ### Parameters - `space_id` (string) - The ID of the space to retrieve keys from. ### Request Example ```python # Using client preview_api_keys = client.preview_api_keys('my_space_id').all() # Using a fetched space object preview_api_keys = space.preview_api_keys().all() ``` ``` -------------------------------- ### Get Uploads Proxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/client.html Instantiate an UploadsProxy to manage asset uploads for a space. ```python uploads_proxy = client.uploads('cfexampleapi') ``` -------------------------------- ### Get Entry Snapshots Proxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/client.html Instantiate a SnapshotsProxy specifically for entry snapshots. ```python entry_snapshots_proxy = client.entry_snapshots('cfexampleapi', 'master', 'nyancat') ``` -------------------------------- ### AssetsProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/assets_proxy.html Gets all assets of a space. Supports query parameters for filtering and selection. ```APIDOC ## AssetsProxy.all ### Description Gets all assets of a space. Supports query parameters for filtering and selection. ### Method GET ### Endpoint /spaces/{space_id}/assets ### Parameters #### Query Parameters - **query** (dict) - Optional - Dictionary of query parameters, including 'select' for field selection. - ****kwargs** - Optional - Additional keyword arguments for the request. ### Response #### Success Response (200) - **items** (list) - A list of asset objects. - **total** (int) - The total number of assets. ### Response Example { "items": [ { "sys": { "type": "Asset", "id": "asset_id_1" }, "fields": { "title": {"en-US": "Example Image 1"}, "file": { "en-US": { "url": "//images.ctfassets.net/...".", "details": {"size": 1000, "image": {"width": 100, "height": 100}}, "fileName": "example1.jpg", "contentType": "image/jpeg" } } } } ], "total": 1 } ``` -------------------------------- ### Creating a Content Type Source: https://github.com/contentful/contentful-management.py/blob/master/_docs/index.md Demonstrates how to create a new content type with specified attributes. ```APIDOC ## Creating a Content Type ### Description Creates a new content type with a given ID and attributes, including its fields. ### Method POST (implied by create operation) ### Endpoint `/spaces/{space_id}/environments/{environment_id}/content_types` ### Parameters #### Path Parameters - **space_id** (string) - Required - The ID of the space. - **environment_id** (string) - Required - The ID of the environment. #### Request Body - **content_type_attributes** (object) - Required - Attributes for the new content type. - **name** (string) - Required - The name of the content type. - **description** (string) - Optional - A description for the content type. - **fields** (array) - Required - An array of field definitions. - **field** (object) - Definition of a single field. - **id** (string) - Required - The unique ID of the field. - **name** (string) - Required - The display name of the field. - **type** (string) - Required - The data type of the field (e.g., 'Symbol', 'Text', 'Link'). - **localized** (boolean) - Required - Whether the field is localized. - **required** (boolean) - Required - Whether the field is mandatory. - **validations** (array) - Optional - Array of validation rules for the field. ### Request Example ```python content_type_attributes = { 'name': 'Blog Post', 'description': 'Blog Posts to be included in ...' 'fields': [ { 'disabled': False, 'id': 'title', 'localized': True, 'name': 'Title', 'omitted': False, 'required': True, 'type': 'Symbol', 'validations': [ { 'size': {'min': 3} } ] }, { 'disabled': False, 'id': 'body', 'localized': True, 'name': 'Body', 'omitted': False, 'required': True, 'type': 'Text', 'validations': [] } ] } new_content_type = client.content_types('my_space_id', 'environment_id').create( 'new_ct_id', content_type_attributes ) ``` ### Response #### Success Response (200 or 201) - **content_type** (object) - The newly created content type object. ``` -------------------------------- ### Get Taxonomy Concept Ancestors Source: https://github.com/contentful/contentful-management.py/blob/master/README.rst Retrieves all ancestor concepts of a given taxonomy concept. ```python ancestors = client.taxonomy_concepts('organization_id').ancestors('concept_id') ``` -------------------------------- ### Create a New Entry Source: https://github.com/contentful/contentful-management.py/blob/master/README.rst Create a new entry using the client or a fetched environment. Requires the space ID, environment ID, new entry ID, and entry attributes. ```python new_entry = client.entries('my_space_id', 'environment_id').create( 'new_entry_id', entry_attributes ) # or if you already have a fetched environment new_entry = environment.entries().create( 'new_entry_id', entry_attributes ) ``` -------------------------------- ### Get Taxonomy Concept Descendants Source: https://github.com/contentful/contentful-management.py/blob/master/README.rst Retrieves all descendant concepts of a given taxonomy concept. ```python descendants = client.taxonomy_concepts('organization_id').descendants('concept_id') ``` -------------------------------- ### Create New UI Extension Source: https://github.com/contentful/contentful-management.py/blob/master/docs/index.html Creates a new UI extension with specified parameters. This can be done using the client or from a fetched environment object. ```python new_ui_extension = client.ui_extensions('my_space_id', 'environment_id').create('test-extension', { "extension": { "name": "Test Extension", "srcdoc": "foobar", "fieldTypes": [{"type": "Symbol"}], "sidebar": False } }) ``` ```python new_ui_extension = environment.ui_extensions().create('test-extension', { "extension": { "name": "Test Extension", "srcdoc": "foobar", "fieldTypes": [{"type": "Symbol"}], "sidebar": False } }) ``` -------------------------------- ### create() - SnapshotsProxy Source: https://github.com/contentful/contentful-management.py/blob/master/docs/genindex.html Creates a snapshot for a given resource (e.g., entry, asset). ```APIDOC ## create() - SnapshotsProxy ### Description Creates a snapshot of a resource, capturing its state at a specific point in time. ### Method POST ### Endpoint /spaces/{space_id}/environments/{environment_id}/{resource_type}/{resource_id}/snapshots ### Parameters #### Path Parameters - **space_id** (string) - Required - The ID of the space. - **environment_id** (string) - Required - The ID of the environment. - **resource_type** (string) - Required - The type of resource (e.g., 'entries', 'assets'). - **resource_id** (string) - Required - The ID of the resource. #### Request Body - **snapshot_id** (string) - Required - The ID for the new snapshot. ``` -------------------------------- ### Get Environment ID Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/resource.html Retrieves the environment ID for the resource. Returns None if not applicable. ```python @property def _environment_id(self): """ Returns the Environment ID. """ try: return super(Resource, self)._environment_id except AttributeError: # In Resources which do not inherit EnvironmentAwareResource an AttributeError will happen return None ``` -------------------------------- ### Get Total Number of Taxonomy Concepts Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/taxonomy_concepts_proxy.html Retrieves the total count of all taxonomy concepts. ```APIDOC ## total ### Description Gets the total number of taxonomy concepts. ### Method GET ### Endpoint /organizations/{organization_id}/taxonomy/concepts/total ### Parameters #### Query Parameters - **kwargs** (object) - Optional - Additional keyword arguments for the request. ### Response #### Success Response (200) - **total** (integer) - The total number of taxonomy concepts. ``` -------------------------------- ### Create a new API key with environments Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_sources/index.rst.txt Use this method to create a new API key and associate it with specific environments. Requires a fetched space object. ```python new_api_key = space.api_keys().create({'name': 'My API Key with environments', 'environments': environments}) ``` -------------------------------- ### EntriesProxy.all Source: https://github.com/contentful/contentful-management.py/blob/master/docs/_modules/contentful_management/entries_proxy.html Gets all entries of a space. If a content_type_id is set on the proxy, it will filter by that content type. ```APIDOC ## EntriesProxy.all ### Description Gets all entries of a space. If a content_type_id is set on the proxy, it will filter by that content type. ### Method GET ### Endpoint /spaces/{space_id}/environments/{environment_id}/entries ### Parameters #### Query Parameters - **content_type** (string) - Optional - Filters entries by content type. - **select** (string) - Optional - Selects specific fields to return in the response. ### Response #### Success Response (200) - **items** (array) - A list of entry objects. - **total** (integer) - The total number of entries. - **skip** (integer) - The number of entries skipped. - **limit** (integer) - The maximum number of entries to return. ### Request Example ```python client.entries_proxy().all({'order': '-sys.createdAt'}) ``` ### Response Example ```json { "items": [ { "sys": { "type": "Entry", "id": "123", "contentType": { "sys": { "type": "Link", "linkType": "ContentType", "id": "post" } } }, "fields": { "title": { "en-US": "My First Post" } } } ], "total": 1, "skip": 0, "limit": 100 } ``` ```