Class: Contentful::Management::ApiKey

Inherits:
Object
  • Object
show all
Includes:
Resource, Resource::Refresher, Resource::SystemProperties
Defined in:
lib/contentful/management/api_key.rb

Overview

Resource class for ApiKey.

See Also:

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

Instance Attribute Summary

Attributes included from Resource::SystemProperties

#sys

Attributes included from Resource

#client, #properties, #raw_object, #request

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Resource::Refresher

#reload

Methods included from Resource

#array?, #default_locale, #destroy, #environment_id, #fields, #nested_locale_fields?, #resource?, #save, #sys, #update

Class Method Details

.create(client, space_id, attributes = {}) ⇒ Contentful::Management::ApiKey

Creates an API Key.

Parameters:

Returns:

See Also:

  • README for full attribute list for each resource.


38
39
40
# File 'lib/contentful/management/api_key.rb', line 38

def self.create(client, space_id, attributes = {})
  super(client, space_id, nil, attributes)
end

.find(client, space_id, api_key_id) ⇒ Contentful::Management::ApiKey

Finds an API Key by ID.

Parameters:

Returns:



49
50
51
# File 'lib/contentful/management/api_key.rb', line 49

def self.find(client, space_id, api_key_id)
  super(client, space_id, nil, api_key_id)
end

Instance Method Details

#environmentsObject

Returns the environment links associated to this Api Key



54
55
56
# File 'lib/contentful/management/api_key.rb', line 54

def environments
  properties[:environments].map { |environment| Link.new(environment, nil, client) }
end

#preview_api_keyContentful::Management::PreviewApiKey

Finds the Preview API Key associated to this API Key



61
62
63
# File 'lib/contentful/management/api_key.rb', line 61

def preview_api_key
  client.preview_api_keys(space.id).find(properties[:preview_api_key].id)
end