Class: ReactorSDK::Endpoints::Environments

Inherits:
BaseEndpoint show all
Defined in:
lib/reactor_sdk/endpoints/environments.rb

Instance Method Summary collapse

Methods inherited from BaseEndpoint

#initialize

Constructor Details

This class inherits a constructor from ReactorSDK::Endpoints::BaseEndpoint

Instance Method Details

#builds(environment_id) ⇒ Array<ReactorSDK::Resources::Build>

Lists builds produced for an environment.

Parameters:

  • environment_id (String)

    Adobe environment ID

Returns:



157
158
159
# File 'lib/reactor_sdk/endpoints/environments.rb', line 157

def builds(environment_id)
  list_resources("/environments/#{environment_id}/builds", Resources::Build)
end

#create(property_id:, name:, host_id:, stage: 'development') ⇒ ReactorSDK::Resources::Environment

Creates a new environment within a property.

Requires a host_id — fetch the property’s hosts first:

hosts = client.hosts.list_for_property(property_id)
host_id = hosts.first.id

Used by LaunchGuard to provision personal developer sandboxes when a new user joins an organisation.

Parameters:

  • property_id (String)

    Adobe property ID

  • name (String)

    Display name (e.g. “jsmith-dev”)

  • stage (String) (defaults to: 'development')

    One of: “development”, “staging”, “production”

  • host_id (String)

    Adobe host ID — required by the Reactor API

Returns:

Raises:



74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/reactor_sdk/endpoints/environments.rb', line 74

def create(property_id:, name:, host_id:, stage: 'development')
  if host_id.nil? || host_id.strip.empty?
    raise ConfigurationError,
          'host_id is required to create an environment. ' \
          'Fetch the property hosts first: client.hosts.list_for_property(property_id)'
  end

  create_resource(
    "/properties/#{property_id}/environments",
    'environments',
    Resources::Environment,
    attributes: { name: name, stage: stage },
    relationships: {
      host: {
        data: { id: host_id, type: 'hosts' }
      }
    }
  )
end

#delete(environment_id) ⇒ nil

Deletes an environment permanently. Only non-built-in environments (personal sandboxes) should be deleted.

Parameters:

  • environment_id (String)

    Adobe environment ID

Returns:

  • (nil)

Raises:



169
170
171
# File 'lib/reactor_sdk/endpoints/environments.rb', line 169

def delete(environment_id)
  delete_resource("/environments/#{environment_id}")
end

#find(environment_id) ⇒ ReactorSDK::Resources::Environment

Retrieves a single environment by its Adobe ID.

Parameters:

  • environment_id (String)

    Adobe environment ID (format: “EN” + hex string)

Returns:

Raises:



52
53
54
# File 'lib/reactor_sdk/endpoints/environments.rb', line 52

def find(environment_id)
  fetch_resource("/environments/#{environment_id}", Resources::Environment)
end

#host(environment_id) ⇒ ReactorSDK::Resources::Host

Retrieves the host assigned to an environment.

Parameters:

  • environment_id (String)

    Adobe environment ID

Returns:



117
118
119
# File 'lib/reactor_sdk/endpoints/environments.rb', line 117

def host(environment_id)
  fetch_resource("/environments/#{environment_id}/host", Resources::Host)
end

#host_relationship(environment_id) ⇒ Hash?

Retrieves the raw host relationship linkage for an environment.

Parameters:

  • environment_id (String)

    Adobe environment ID

Returns:

  • (Hash, nil)


127
128
129
# File 'lib/reactor_sdk/endpoints/environments.rb', line 127

def host_relationship(environment_id)
  fetch_relationship("/environments/#{environment_id}/relationships/host")
end

#library(environment_id) ⇒ ReactorSDK::Resources::Library

Retrieves the library currently assigned to an environment.

Parameters:

  • environment_id (String)

    Adobe environment ID

Returns:



137
138
139
# File 'lib/reactor_sdk/endpoints/environments.rb', line 137

def library(environment_id)
  fetch_resource("/environments/#{environment_id}/library", Resources::Library)
end

#list_for_property(property_id) ⇒ Array<ReactorSDK::Resources::Environment>

Lists all environments for a given property. Follows pagination automatically — returns all environments.

Parameters:

  • property_id (String)

    Adobe property ID

Returns:

Raises:



41
42
43
# File 'lib/reactor_sdk/endpoints/environments.rb', line 41

def list_for_property(property_id)
  list_resources("/properties/#{property_id}/environments", Resources::Environment)
end

#property(environment_id) ⇒ ReactorSDK::Resources::Property

Retrieves the property that owns an environment.

Parameters:

  • environment_id (String)

    Adobe environment ID

Returns:



147
148
149
# File 'lib/reactor_sdk/endpoints/environments.rb', line 147

def property(environment_id)
  fetch_resource("/environments/#{environment_id}/property", Resources::Property)
end

#update(environment_id, attributes) ⇒ ReactorSDK::Resources::Environment

Updates an existing environment.

Parameters:

  • environment_id (String)

    Adobe environment ID

  • attributes (Hash)

    Fields to update

Returns:



101
102
103
104
105
106
107
108
109
# File 'lib/reactor_sdk/endpoints/environments.rb', line 101

def update(environment_id, attributes)
  update_resource(
    "/environments/#{environment_id}",
    environment_id,
    'environments',
    Resources::Environment,
    attributes: attributes
  )
end