class Contentful::Management::Environment
Resource
class for Environment
. @see _ www.contentful.com/developers/documentation/content-management-api/#resources-environments
Public Class Methods
@private
# File lib/contentful/management/environment.rb, line 20 def self.build_endpoint(endpoint_options) space_id = endpoint_options.fetch(:space_id) environment_id = endpoint_options.fetch(:resource_id, endpoint_options.fetch(:environment_id, nil)) endpoint = "spaces/#{space_id}/environments" endpoint = "#{endpoint}/#{environment_id}" if environment_id endpoint end
Creates an environment.
@param [Contentful::Management::Client] client @param [String] space_id @param [Hash] attributes @see _ README for full attribute list for each resource.
@return [Contentful::Management::Environment]
# File lib/contentful/management/environment.rb, line 37 def self.create(client, space_id, attributes = {}) super(client, space_id, nil, attributes) end
@private
# File lib/contentful/management/environment.rb, line 53 def self.create_attributes(_client, attributes) return {} if attributes.nil? || attributes.empty? { 'name' => attributes[:name] || attributes['name'] } end
@private
# File lib/contentful/management/environment.rb, line 62 def self.create_headers(_client, attributes, _instance = nil) return {} unless attributes[:source_environment_id] || attributes['source_environment_id'] { 'X-Contentful-Source-Environment' => attributes[:source_environment_id] || attributes['source_environment_id'] } end
Finds an environment by ID.
@param [Contentful::Management::Client] client @param [String] space_id @param [String] environment_id
@return [Contentful::Management::Environment]
# File lib/contentful/management/environment.rb, line 48 def self.find(client, space_id, environment_id) super(client, space_id, nil, environment_id) end
Public Instance Methods
Allows manipulation of assets in context of the current environment Allows listing all assets for the current environment, creating new and finding one by ID. @see _ README for details.
@return [Contentful::Management::EnvironmentAssetMethodsFactory]
# File lib/contentful/management/environment.rb, line 84 def assets EnvironmentAssetMethodsFactory.new(self) end
Allows manipulation of content types in context of the current environment Allows listing all content types for the current environment, creating new and finding one by ID. @see _ README for details.
@return [Contentful::Management::EnvironmentContentTypeMethodsFactory]
# File lib/contentful/management/environment.rb, line 93 def content_types EnvironmentContentTypeMethodsFactory.new(self) end
Retrieves Default Locale
for current Environment
and leaves it cached
@return [String]
# File lib/contentful/management/environment.rb, line 132 def default_locale self.found_locale ||= find_locale end
Allows manipulation of editor interfaces in context of the current environment Allows listing of editor interfaces for the current environment. @see _ README for details.
@return [Contentful::Management::EnvironmentEditorInterfaceMethodsFactory]
# File lib/contentful/management/environment.rb, line 120 def editor_interfaces EnvironmentEditorInterfaceMethodsFactory.new(self) end
Allows manipulation of entries in context of the current environment Allows listing all entries for the current environment, creating new and finding one by ID. @see _ README for details.
@return [Contentful::Management::EnvironmentEntryMethodsFactory]
# File lib/contentful/management/environment.rb, line 75 def entries EnvironmentEntryMethodsFactory.new(self) end
Gets the environment ID
# File lib/contentful/management/environment.rb, line 125 def environment_id id end
Allows manipulation of locales in context of the current environment Allows listing all locales for the current environment, creating new and finding one by ID. @see _ README for details.
@return [Contentful::Management::EnvironmentLocaleMethodsFactory]
# File lib/contentful/management/environment.rb, line 102 def locales EnvironmentLocaleMethodsFactory.new(self) end
@private
# File lib/contentful/management/environment.rb, line 148 def refresh_find self.class.find(client, space.id, id) end
Allows manipulation of UI extensions in context of the current environment Allows listing all UI extensions for the current environment, creating new and finding one by ID. @see _ README for details.
@return [Contentful::Management::EnvironmentUIExtensionMethodsFactory]
# File lib/contentful/management/environment.rb, line 111 def ui_extensions EnvironmentUIExtensionMethodsFactory.new(self) end
Protected Instance Methods
# File lib/contentful/management/environment.rb, line 154 def query_attributes(attributes) { name: name }.merge(attributes) end