Class: Contentful::Management::Client

Inherits:
Object
  • Object
show all
Extended by:
HTTPClient
Defined in:
lib/contentful/management/client.rb

Overview

Client for interacting with the Contentful Management API

See Also:

  • https://www.contentful.com/developers/docs/references/content-management-api/

Constant Summary collapse

DEFAULT_CONFIGURATION =

Default configuration for Contentful::Management::Client

{
  api_url: 'api.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: [],
  proxy_host: nil,
  proxy_port: nil,
  proxy_username: nil,
  proxy_password: nil,
  max_rate_limit_retries: 1,
  max_rate_limit_wait: 60
}
RATE_LIMIT_RESET_HEADER_KEY =

Rate Limit Reset Header Key

'x-contentful-ratelimit-reset'

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from HTTPClient

delete_http, get_http, http_send, post_http, proxy_send, put_http

Constructor Details

#initialize(access_token = nil, configuration = {}) ⇒ Client

Returns a new instance of Client.

Parameters:

  • access_token (String) (defaults to: nil)
  • configuration (Hash) (defaults to: {})

Options Hash (configuration):

  • :api_url (String)
  • :api_version (String)
  • :default_locale (String)
  • :gzip_encoded (Boolean)
  • :logger (false, ::Logger)
  • :log_level (::Logger::DEBUG, ::Logger::INFO, ::Logger::WARN, ::Logger::ERROR)
  • :raise_errors (Boolean)
  • :dynamic_entries (::Array<String>)
  • :proxy_host (String)
  • :proxy_port (Fixnum)
  • :proxy_username (String)
  • :proxy_username (String)


68
69
70
71
72
73
74
75
# File 'lib/contentful/management/client.rb', line 68

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_tokenObject (readonly)

Returns the value of attribute access_token.



30
31
32
# File 'lib/contentful/management/client.rb', line 30

def access_token
  @access_token
end

#configurationObject (readonly)

Returns the value of attribute configuration.



30
31
32
# File 'lib/contentful/management/client.rb', line 30

def configuration
  @configuration
end

#content_type_idObject

Returns the value of attribute content_type_id.



31
32
33
# File 'lib/contentful/management/client.rb', line 31

def content_type_id
  @content_type_id
end

#dynamic_entry_cacheObject

Returns the value of attribute dynamic_entry_cache.



31
32
33
# File 'lib/contentful/management/client.rb', line 31

def dynamic_entry_cache
  @dynamic_entry_cache
end

#loggerObject (readonly)

Returns the value of attribute logger.



30
31
32
# File 'lib/contentful/management/client.rb', line 30

def logger
  @logger
end

#organization_idObject

Returns the value of attribute organization_id.



31
32
33
# File 'lib/contentful/management/client.rb', line 31

def organization_id
  @organization_id
end

#versionObject

Returns the value of attribute version.



31
32
33
# File 'lib/contentful/management/client.rb', line 31

def version
  @version
end

#zero_lengthObject

Returns the value of attribute zero_length.



31
32
33
# File 'lib/contentful/management/client.rb', line 31

def zero_length
  @zero_length
end

Instance Method Details

#api_keysContentful::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.

Returns:

  • (Contentful::Management::ClientApiKeyMethodsFactory)

See Also:

  • README for details.


91
92
93
# File 'lib/contentful/management/client.rb', line 91

def api_keys
  ClientApiKeyMethodsFactory.new(self)
end

#assetsContentful::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.

Returns:

  • (Contentful::Management::ClientAssetMethodsFactory)

See Also:

  • README for details.


100
101
102
# File 'lib/contentful/management/client.rb', line 100

def assets
  ClientAssetMethodsFactory.new(self)
end

#content_typesContentful::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.

Returns:

  • (Contentful::Management::ClientContentTypeMethodsFactory)

See Also:

  • README for details.


109
110
111
# File 'lib/contentful/management/client.rb', line 109

def content_types
  ClientContentTypeMethodsFactory.new(self)
end

#editor_interfacesContentful::Management::ClientEditorInterfaceMethodsFactory

Allows manipulation of editor interfaces in context of the current client Allows listing all editor interfaces for client, creating new and finding one by id.

Returns:

  • (Contentful::Management::ClientEditorInterfaceMethodsFactory)

See Also:

  • README for details.


145
146
147
# File 'lib/contentful/management/client.rb', line 145

def editor_interfaces
  ClientEditorInterfaceMethodsFactory.new(self)
end

#entriesContentful::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.

Returns:

  • (Contentful::Management::ClientEntryMethodsFactory)

See Also:

  • README for details.


118
119
120
# File 'lib/contentful/management/client.rb', line 118

def entries
  ClientEntryMethodsFactory.new(self)
end

#localesContentful::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.

Returns:

  • (Contentful::Management::ClientLocaleMethodsFactory)

See Also:

  • README for details.


127
128
129
# File 'lib/contentful/management/client.rb', line 127

def locales
  ClientLocaleMethodsFactory.new(self)
end

#rolesContentful::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.

Returns:

  • (Contentful::Management::ClientRoleMethodsFactory)

See Also:

  • README for details.


136
137
138
# File 'lib/contentful/management/client.rb', line 136

def roles
  ClientRoleMethodsFactory.new(self)
end

#spacesContentful::Management::ClientSpaceMethodsFactory

Allows manipulation of spaces in context of the current client Allows listing all spaces for client and finding one by id.

Returns:

  • (Contentful::Management::ClientSpaceMethodsFactory)

See Also:

  • README for details.


82
83
84
# File 'lib/contentful/management/client.rb', line 82

def spaces
  ClientSpaceMethodsFactory.new(self)
end

#webhooksContentful::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.

Returns:

  • (Contentful::Management::ClientWebhookMethodsFactory)

See Also:

  • README for details.


154
155
156
# File 'lib/contentful/management/client.rb', line 154

def webhooks
  ClientWebhookMethodsFactory.new(self)
end