Class: Contentful::Management::Client
- Inherits:
-
Object
- Object
- Contentful::Management::Client
- Defined in:
- lib/contentful/management/client.rb
Overview
Client for interacting with the Contentful Management API
Constant Summary collapse
- DEFAULT_CONFIGURATION =
Default configuration for Contentful::Management::Client
{ api_url: 'api.contentful.com', uploads_url: 'upload.contentful.com', api_version: '1', secure: true, default_locale: 'en-US', gzip_encoded: false, logger: false, log_level: Logger::INFO, raise_errors: false, dynamic_entries: {}, disable_content_type_caching: false, proxy_host: nil, proxy_port: nil, proxy_username: nil, proxy_password: nil, max_rate_limit_retries: 1, max_rate_limit_wait: 60, application_name: nil, application_version: nil, integration_name: nil, integration_version: nil }.freeze
- RATE_LIMIT_RESET_HEADER_KEY =
Rate Limit Reset Header Key
'x-contentful-ratelimit-reset'
Instance Attribute Summary collapse
-
#access_token ⇒ Object
readonly
Returns the value of attribute access_token.
-
#configuration ⇒ Object
readonly
Returns the value of attribute configuration.
-
#content_type_id ⇒ Object
Returns the value of attribute content_type_id.
-
#dynamic_entry_cache ⇒ Object
Returns the value of attribute dynamic_entry_cache.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#organization_id ⇒ Object
Returns the value of attribute organization_id.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
-
#api_keys(space_id) ⇒ Contentful::Management::ClientApiKeyMethodsFactory
Allows manipulation of api keys in context of the current client Allows listing all api keys for client, creating new and finding one by ID.
-
#assets(space_id, environment_id) ⇒ Contentful::Management::ClientAssetMethodsFactory
Allows manipulation of assets in context of the current client Allows listing all assets for client, creating new and finding one by ID.
-
#content_type_snapshots(space_id, environment_id) ⇒ Contentful::Management::ClientSnapshotMethodsFactory
Allows manipulation of content type snapshots in context of the current client Allows listing all content type snapshots for client and finding one by ID.
-
#content_types(space_id, environment_id) ⇒ Contentful::Management::ClientContentTypeMethodsFactory
Allows manipulation of content types in context of the current client Allows listing all content types for client, creating new and finding one by ID.
-
#editor_interfaces(space_id, environment_id, content_type_id) ⇒ Contentful::Management::ClientEditorInterfaceMethodsFactory
Allows manipulation of editor interfaces in context of the current client Allows listing all editor interfaces for client and finding one by content type.
-
#entries(space_id, environment_id) ⇒ Contentful::Management::ClientEntryMethodsFactory
Allows manipulation of entries in context of the current client Allows listing all entries for client, creating new and finding one by ID.
-
#entry_snapshots(space_id, environment_id) ⇒ Contentful::Management::ClientSnapshotMethodsFactory
Allows manipulation of entry snapshots in context of the current client Allows listing all entry snapshots for client and finding one by ID.
-
#environments(space_id) ⇒ Contentful::Management::ClientEnvironmentMethodsFactory
Allows manipulation of environments in context of the current client Allows listing all environments for client, creating new and finding one by ID.
-
#http_send(type, url, params, headers, proxy) ⇒ HTTP::Response
HTTP Helper Abtracts the Proxy/No-Proxy logic.
-
#initialize(access_token = nil, configuration = {}) ⇒ Client
constructor
A new instance of Client.
-
#locales(space_id, environment_id) ⇒ Contentful::Management::ClientLocaleMethodsFactory
Allows manipulation of locales in context of the current client Allows listing all locales for client, creating new and finding one by ID.
-
#organization_periodic_usages(organization_id) ⇒ Contentful::Management::ClientOrganizationPeriodicUsageMethodsFactory
deprecated
Deprecated.
The
GET /organizations/:organization_id/organization_periodic_usagesendpoint is deprecated in favor of the new Usage API. It will be removed on 2027-02-28, after which requests will return 410 Gone. -
#organizations ⇒ Contentful::Management::ClientOrganizationMethodsFactory
Allows viewing of organizations in context of the current client Allows listing all organizations for client.
-
#personal_access_tokens ⇒ Contentful::Management::ClientPersonalAccessTokenMethodsFactory
Allows manipulation of personal access tokens in context of the current client Allows listing all personal access tokens for client, creating new and finding one by ID.
-
#preview_api_keys(space_id) ⇒ Contentful::Management::ClientPreviewApiKeyMethodsFactory
Allows manipulation of api keys in context of the current client Allows listing all preview api keys for client and finding one by ID.
-
#proxy_send(type, url, params, headers, proxy) ⇒ HTTP::Response
Proxy Helper.
-
#roles(space_id) ⇒ Contentful::Management::ClientRoleMethodsFactory
Allows manipulation of roles in context of the current client Allows listing all roles for client, creating new and finding one by ID.
-
#snapshots(space_id, environment_id, resource_type = 'entries') ⇒ Contentful::Management::ClientSnapshotMethodsFactory
Allows manipulation of snapshots in context of the current client Allows listing all snapshots for client and finding one by ID.
-
#space_memberships(space_id) ⇒ Contentful::Management::ClientSpaceMembershipMethodsFactory
Allows manipulation of space memberships in context of the current client Allows listing all space memberships for client, creating new and finding one by ID.
-
#space_periodic_usages(organization_id) ⇒ Contentful::Management::ClientSpacePeriodicUsageMethodsFactory
deprecated
Deprecated.
The
GET /organizations/:organization_id/space_periodic_usagesendpoint is deprecated in favor of the new Usage API. It will be removed on 2027-02-28, after which requests will return 410 Gone. -
#spaces ⇒ Contentful::Management::ClientSpaceMethodsFactory
Allows manipulation of spaces in context of the current client Allows listing all spaces for client, creating new and finding one by ID.
-
#tags(space_id, environment_id) ⇒ Contentful::Management::ClientTagMethodsFactory
Allows manipulation of tags in context of the current client Allows listing all tags for client, creating new and finding one by ID.
-
#taxonomy_concept_schemes(organization_id) ⇒ Contentful::Management::ClientTaxonomyConceptSchemeMethodsFactory
Allows manipulation of taxonomy concept schemes in context of the current client Allows listing all taxonomy concept schemes for client, creating new and finding one by ID.
-
#taxonomy_concepts(organization_id) ⇒ Contentful::Management::ClientTaxonomyConceptMethodsFactory
Allows manipulation of taxonomy concepts in context of the current client Allows listing all taxonomy concepts for client, creating new and finding one by ID.
-
#ui_extensions(space_id, environment_id) ⇒ Contentful::Management::ClientUIExtensionMethodsFactory
Allows manipulation of UI extensions in context of the current client Allows listing all UI extensions for client, creating new and finding one by ID.
-
#uploads(space_id) ⇒ Contentful::Management::ClientUploadMethodsFactory
Allows manipulation of uploads in context of the current client Allows creating new and finding uploads by ID.
-
#users ⇒ Contentful::Management::ClientUserMethodsFactory
Allows viewing of users in context of the current client Allows listing all users for client.
-
#webhook_calls(space_id, webhook_id) ⇒ Contentful::Management::ClientWebhookCallMethodsFactory
Allows manipulation of webhook calls in context of the current client Allows listing all webhook call details for client and finding one by ID.
-
#webhook_health(space_id) ⇒ Contentful::Management::ClientWebhookHealthMethodsFactory
Allows manipulation of webhook health in context of the current client Allows listing all webhook health details for client and finding one by ID.
-
#webhooks(space_id) ⇒ Contentful::Management::ClientWebhookMethodsFactory
Allows manipulation of webhooks in context of the current client Allows listing all webhooks for client, creating new and finding one by ID.
Constructor Details
#initialize(access_token = nil, configuration = {}) ⇒ Client
Returns a new instance of Client.
96 97 98 99 100 101 102 103 |
# File 'lib/contentful/management/client.rb', line 96 def initialize(access_token = nil, configuration = {}) @configuration = default_configuration.merge(configuration) setup_logger @access_token = access_token @dynamic_entry_cache = {} Thread.current[:client] = self update_all_dynamic_entry_cache! end |
Instance Attribute Details
#access_token ⇒ Object (readonly)
Returns the value of attribute access_token.
46 47 48 |
# File 'lib/contentful/management/client.rb', line 46 def access_token @access_token end |
#configuration ⇒ Object (readonly)
Returns the value of attribute configuration.
46 47 48 |
# File 'lib/contentful/management/client.rb', line 46 def configuration @configuration end |
#content_type_id ⇒ Object
Returns the value of attribute content_type_id.
47 48 49 |
# File 'lib/contentful/management/client.rb', line 47 def content_type_id @content_type_id end |
#dynamic_entry_cache ⇒ Object
Returns the value of attribute dynamic_entry_cache.
47 48 49 |
# File 'lib/contentful/management/client.rb', line 47 def dynamic_entry_cache @dynamic_entry_cache end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
46 47 48 |
# File 'lib/contentful/management/client.rb', line 46 def logger @logger end |
#organization_id ⇒ Object
Returns the value of attribute organization_id.
47 48 49 |
# File 'lib/contentful/management/client.rb', line 47 def organization_id @organization_id end |
#version ⇒ Object
Returns the value of attribute version.
47 48 49 |
# File 'lib/contentful/management/client.rb', line 47 def version @version end |
Instance Method Details
#api_keys(space_id) ⇒ Contentful::Management::ClientApiKeyMethodsFactory
Allows manipulation of api keys in context of the current client Allows listing all api keys for client, creating new and finding one by ID.
201 202 203 |
# File 'lib/contentful/management/client.rb', line 201 def api_keys(space_id) ClientApiKeyMethodsFactory.new(self, space_id) end |
#assets(space_id, environment_id) ⇒ Contentful::Management::ClientAssetMethodsFactory
Allows manipulation of assets in context of the current client Allows listing all assets for client, creating new and finding one by ID.
228 229 230 |
# File 'lib/contentful/management/client.rb', line 228 def assets(space_id, environment_id) ClientAssetMethodsFactory.new(self, space_id, environment_id) end |
#content_type_snapshots(space_id, environment_id) ⇒ Contentful::Management::ClientSnapshotMethodsFactory
Allows manipulation of content type snapshots in context of the current client Allows listing all content type snapshots for client and finding one by ID.
354 355 356 |
# File 'lib/contentful/management/client.rb', line 354 def content_type_snapshots(space_id, environment_id) ClientSnapshotMethodsFactory.new(self, space_id, environment_id, 'content_types') end |
#content_types(space_id, environment_id) ⇒ Contentful::Management::ClientContentTypeMethodsFactory
Allows manipulation of content types in context of the current client Allows listing all content types for client, creating new and finding one by ID.
246 247 248 |
# File 'lib/contentful/management/client.rb', line 246 def content_types(space_id, environment_id) ClientContentTypeMethodsFactory.new(self, space_id, environment_id) end |
#editor_interfaces(space_id, environment_id, content_type_id) ⇒ Contentful::Management::ClientEditorInterfaceMethodsFactory
Allows manipulation of editor interfaces in context of the current client Allows listing all editor interfaces for client and finding one by content type.
291 292 293 |
# File 'lib/contentful/management/client.rb', line 291 def editor_interfaces(space_id, environment_id, content_type_id) ClientEditorInterfaceMethodsFactory.new(self, space_id, environment_id, content_type_id) end |
#entries(space_id, environment_id) ⇒ Contentful::Management::ClientEntryMethodsFactory
Allows manipulation of entries in context of the current client Allows listing all entries for client, creating new and finding one by ID.
255 256 257 |
# File 'lib/contentful/management/client.rb', line 255 def entries(space_id, environment_id) ClientEntryMethodsFactory.new(self, space_id, environment_id) end |
#entry_snapshots(space_id, environment_id) ⇒ Contentful::Management::ClientSnapshotMethodsFactory
Allows manipulation of entry snapshots in context of the current client Allows listing all entry snapshots for client and finding one by ID.
345 346 347 |
# File 'lib/contentful/management/client.rb', line 345 def entry_snapshots(space_id, environment_id) ClientSnapshotMethodsFactory.new(self, space_id, environment_id, 'entries') end |
#environments(space_id) ⇒ Contentful::Management::ClientEnvironmentMethodsFactory
Allows manipulation of environments in context of the current client Allows listing all environments for client, creating new and finding one by ID.
119 120 121 |
# File 'lib/contentful/management/client.rb', line 119 def environments(space_id) ClientEnvironmentMethodsFactory.new(self, space_id) end |
#http_send(type, url, params, headers, proxy) ⇒ HTTP::Response
HTTP Helper Abtracts the Proxy/No-Proxy logic
544 545 546 547 548 |
# File 'lib/contentful/management/client.rb', line 544 def http_send(type, url, params, headers, proxy) return proxy_send(type, url, params, headers, proxy) unless proxy[:host].nil? HTTP[headers].public_send(type, url, params) end |
#locales(space_id, environment_id) ⇒ Contentful::Management::ClientLocaleMethodsFactory
Allows manipulation of locales in context of the current client Allows listing all locales for client, creating new and finding one by ID.
264 265 266 |
# File 'lib/contentful/management/client.rb', line 264 def locales(space_id, environment_id) ClientLocaleMethodsFactory.new(self, space_id, environment_id) end |
#organization_periodic_usages(organization_id) ⇒ Contentful::Management::ClientOrganizationPeriodicUsageMethodsFactory
The GET /organizations/:organization_id/organization_periodic_usages
endpoint is deprecated in favor of the new Usage API. It will be removed on
2027-02-28, after which requests will return 410 Gone.
Allows listing all usage periods for organization grouped by organization.
148 149 150 151 152 153 |
# File 'lib/contentful/management/client.rb', line 148 def organization_periodic_usages(organization_id) warn '[DEPRECATION] `Client#organization_periodic_usages` calls the legacy ' \ 'organization_periodic_usages endpoint, which is deprecated and will be ' \ 'removed on 2027-02-28. Migrate to the new Usage API.' ClientOrganizationPeriodicUsageMethodsFactory.new(self, organization_id) end |
#organizations ⇒ Contentful::Management::ClientOrganizationMethodsFactory
Allows viewing of organizations in context of the current client Allows listing all organizations for client.
137 138 139 |
# File 'lib/contentful/management/client.rb', line 137 def organizations ClientOrganizationMethodsFactory.new(self) end |
#personal_access_tokens ⇒ Contentful::Management::ClientPersonalAccessTokenMethodsFactory
Allows manipulation of personal access tokens in context of the current client Allows listing all personal access tokens for client, creating new and finding one by ID.
219 220 221 |
# File 'lib/contentful/management/client.rb', line 219 def personal_access_tokens ClientPersonalAccessTokenMethodsFactory.new(self) end |
#preview_api_keys(space_id) ⇒ Contentful::Management::ClientPreviewApiKeyMethodsFactory
Allows manipulation of api keys in context of the current client Allows listing all preview api keys for client and finding one by ID.
210 211 212 |
# File 'lib/contentful/management/client.rb', line 210 def preview_api_keys(space_id) ClientPreviewApiKeyMethodsFactory.new(self, space_id) end |
#proxy_send(type, url, params, headers, proxy) ⇒ HTTP::Response
Proxy Helper
525 526 527 528 529 530 531 532 |
# File 'lib/contentful/management/client.rb', line 525 def proxy_send(type, url, params, headers, proxy) HTTP[headers].via( proxy[:host], proxy[:port], proxy[:username], proxy[:password] ).public_send(type, url, params) end |
#roles(space_id) ⇒ Contentful::Management::ClientRoleMethodsFactory
Allows manipulation of roles in context of the current client Allows listing all roles for client, creating new and finding one by ID.
273 274 275 |
# File 'lib/contentful/management/client.rb', line 273 def roles(space_id) ClientRoleMethodsFactory.new(self, space_id) end |
#snapshots(space_id, environment_id, resource_type = 'entries') ⇒ Contentful::Management::ClientSnapshotMethodsFactory
Allows manipulation of snapshots in context of the current client Allows listing all snapshots for client and finding one by ID.
336 337 338 |
# File 'lib/contentful/management/client.rb', line 336 def snapshots(space_id, environment_id, resource_type = 'entries') ClientSnapshotMethodsFactory.new(self, space_id, environment_id, resource_type) end |
#space_memberships(space_id) ⇒ Contentful::Management::ClientSpaceMembershipMethodsFactory
Allows manipulation of space memberships in context of the current client Allows listing all space memberships for client, creating new and finding one by ID.
128 129 130 |
# File 'lib/contentful/management/client.rb', line 128 def space_memberships(space_id) ClientSpaceMembershipMethodsFactory.new(self, space_id) end |
#space_periodic_usages(organization_id) ⇒ Contentful::Management::ClientSpacePeriodicUsageMethodsFactory
The GET /organizations/:organization_id/space_periodic_usages
endpoint is deprecated in favor of the new Usage API. It will be removed on
2027-02-28, after which requests will return 410 Gone.
Allows listing all usage periods for organization grouped by space.
162 163 164 165 166 167 |
# File 'lib/contentful/management/client.rb', line 162 def space_periodic_usages(organization_id) warn '[DEPRECATION] `Client#space_periodic_usages` calls the legacy ' \ 'space_periodic_usages endpoint, which is deprecated and will be ' \ 'removed on 2027-02-28. Migrate to the new Usage API.' ClientSpacePeriodicUsageMethodsFactory.new(self, organization_id) end |
#spaces ⇒ Contentful::Management::ClientSpaceMethodsFactory
Allows manipulation of spaces in context of the current client Allows listing all spaces for client, creating new and finding one by ID.
110 111 112 |
# File 'lib/contentful/management/client.rb', line 110 def spaces ClientSpaceMethodsFactory.new(self) end |
#tags(space_id, environment_id) ⇒ Contentful::Management::ClientTagMethodsFactory
Allows manipulation of tags in context of the current client Allows listing all tags for client, creating new and finding one by ID.
237 238 239 |
# File 'lib/contentful/management/client.rb', line 237 def (space_id, environment_id) ClientTagMethodsFactory.new(self, space_id, environment_id) end |
#taxonomy_concept_schemes(organization_id) ⇒ Contentful::Management::ClientTaxonomyConceptSchemeMethodsFactory
Allows manipulation of taxonomy concept schemes in context of the current client Allows listing all taxonomy concept schemes for client, creating new and finding one by ID.
183 184 185 |
# File 'lib/contentful/management/client.rb', line 183 def taxonomy_concept_schemes(organization_id) ClientTaxonomyConceptSchemeMethodsFactory.new(self, organization_id) end |
#taxonomy_concepts(organization_id) ⇒ Contentful::Management::ClientTaxonomyConceptMethodsFactory
Allows manipulation of taxonomy concepts in context of the current client Allows listing all taxonomy concepts for client, creating new and finding one by ID.
174 175 176 |
# File 'lib/contentful/management/client.rb', line 174 def taxonomy_concepts(organization_id) ClientTaxonomyConceptMethodsFactory.new(self, organization_id) end |
#ui_extensions(space_id, environment_id) ⇒ Contentful::Management::ClientUIExtensionMethodsFactory
Allows manipulation of UI extensions in context of the current client Allows listing all UI extensions for client, creating new and finding one by ID.
282 283 284 |
# File 'lib/contentful/management/client.rb', line 282 def ui_extensions(space_id, environment_id) ClientUIExtensionMethodsFactory.new(self, space_id, environment_id) end |
#uploads(space_id) ⇒ Contentful::Management::ClientUploadMethodsFactory
Allows manipulation of uploads in context of the current client Allows creating new and finding uploads by ID.
327 328 329 |
# File 'lib/contentful/management/client.rb', line 327 def uploads(space_id) ClientUploadMethodsFactory.new(self, space_id) end |
#users ⇒ Contentful::Management::ClientUserMethodsFactory
Allows viewing of users in context of the current client Allows listing all users for client.
192 193 194 |
# File 'lib/contentful/management/client.rb', line 192 def users ClientUserMethodsFactory.new(self) end |
#webhook_calls(space_id, webhook_id) ⇒ Contentful::Management::ClientWebhookCallMethodsFactory
Allows manipulation of webhook calls in context of the current client Allows listing all webhook call details for client and finding one by ID.
309 310 311 |
# File 'lib/contentful/management/client.rb', line 309 def webhook_calls(space_id, webhook_id) ClientWebhookCallMethodsFactory.new(self, space_id, webhook_id) end |
#webhook_health(space_id) ⇒ Contentful::Management::ClientWebhookHealthMethodsFactory
Allows manipulation of webhook health in context of the current client Allows listing all webhook health details for client and finding one by ID.
318 319 320 |
# File 'lib/contentful/management/client.rb', line 318 def webhook_health(space_id) ClientWebhookHealthMethodsFactory.new(self, space_id) end |
#webhooks(space_id) ⇒ Contentful::Management::ClientWebhookMethodsFactory
Allows manipulation of webhooks in context of the current client Allows listing all webhooks for client, creating new and finding one by ID.
300 301 302 |
# File 'lib/contentful/management/client.rb', line 300 def webhooks(space_id) ClientWebhookMethodsFactory.new(self, space_id) end |