Class: Twilio::REST::Serverless::V1::ServiceContext::EnvironmentContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/serverless/v1/service/environment.rb,
lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb,
lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb,
lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb

Overview

PLEASE NOTE that this class contains beta products that are subject to change. Use them with caution.

Defined Under Namespace

Classes: DeploymentContext, DeploymentInstance, DeploymentList, DeploymentPage, LogContext, LogInstance, LogList, LogPage, VariableContext, VariableInstance, VariableList, VariablePage

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ EnvironmentContext

Initialize the EnvironmentContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the Service to fetch the Environment resource from.

  • sid (String)

    The SID of the Environment resource to fetch.



162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 162

def initialize(version, service_sid, sid)
    super(version)

    # Path Solution
    @solution = { service_sid: service_sid, sid: sid,  }
    @uri = "/Services/#{@solution[:service_sid]}/Environments/#{@solution[:sid]}"

    # Dependents
    @logs = nil
    @variables = nil
    @deployments = nil
end

Instance Method Details

#deleteBoolean

Delete the EnvironmentInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



177
178
179
180
181
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 177

def delete

    
    @version.delete('DELETE', @uri)
end

#deployments(sid = :unset) ⇒ DeploymentList, DeploymentContext

Access the deployments

Returns:

Raises:

  • (ArgumentError)


240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 240

def deployments(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return DeploymentContext.new(@version, @solution[:service_sid], @solution[:sid],sid )
    end

    unless @deployments
        @deployments = DeploymentList.new(
            @version, service_sid: @solution[:service_sid], environment_sid: @solution[:sid], )
    end

 @deployments
end

#fetchEnvironmentInstance

Fetch the EnvironmentInstance

Returns:



186
187
188
189
190
191
192
193
194
195
196
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 186

def fetch

    
    payload = @version.fetch('GET', @uri)
    EnvironmentInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



265
266
267
268
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 265

def inspect
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Serverless.V1.EnvironmentContext #{context}>"
end

#logs(sid = :unset) ⇒ LogList, LogContext

Access the logs

Returns:

Raises:

  • (ArgumentError)


202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 202

def logs(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return LogContext.new(@version, @solution[:service_sid], @solution[:sid],sid )
    end

    unless @logs
        @logs = LogList.new(
            @version, service_sid: @solution[:service_sid], environment_sid: @solution[:sid], )
    end

 @logs
end

#to_sObject

Provide a user friendly representation



258
259
260
261
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 258

def to_s
    context = @solution.map{|k, v| "#{k}: #{v}"}.join(',')
    "#<Twilio.Serverless.V1.EnvironmentContext #{context}>"
end

#variables(sid = :unset) ⇒ VariableList, VariableContext

Access the variables

Returns:

Raises:

  • (ArgumentError)


221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 221

def variables(sid=:unset)

    raise ArgumentError, 'sid cannot be nil' if sid.nil?

    if sid != :unset
        return VariableContext.new(@version, @solution[:service_sid], @solution[:sid],sid )
    end

    unless @variables
        @variables = VariableList.new(
            @version, service_sid: @solution[:service_sid], environment_sid: @solution[:sid], )
    end

 @variables
end