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

Defined Under Namespace

Classes: DeploymentContext, DeploymentInstance, DeploymentInstanceMetadata, DeploymentList, DeploymentListResponse, DeploymentPage, DeploymentPageMetadata, LogContext, LogInstance, LogInstanceMetadata, LogList, LogListResponse, LogPage, LogPageMetadata, VariableContext, VariableInstance, VariableInstanceMetadata, VariableList, VariableListResponse, VariablePage, VariablePageMetadata

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.



234
235
236
237
238
239
240
241
242
243
244
245
246
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 234

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



250
251
252
253
254
255
256
257
258
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 250

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    

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

#delete_with_metadataBoolean

Delete the EnvironmentInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 263

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
      response = @version.('DELETE', @uri, headers: headers)
      environment_instance = EnvironmentInstance.new(
          @version,
          response.body,
          account_sid: @solution[:account_sid],
          sid: @solution[:sid],
      )
      EnvironmentInstanceMetadata.new(@version, environment_instance, response.headers, response.status_code)
end

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

Access the deployments

Returns:

Raises:

  • (ArgumentError)


367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 367

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:



282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 282

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    EnvironmentInstance.new(
        @version,
        payload,
        service_sid: @solution[:service_sid],
        sid: @solution[:sid],
    )
end

#fetch_with_metadataEnvironmentInstance

Fetch the EnvironmentInstanceMetadata

Returns:



302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 302

def 

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('GET', @uri, headers: headers)
    environment_instance = EnvironmentInstance.new(
        @version,
        response.body,
        service_sid: @solution[:service_sid],
        sid: @solution[:sid],
    )
    EnvironmentInstanceMetadata.new(
        @version,
        environment_instance,
        response.headers,
        response.status_code
    )
end

#inspectObject

Provide a detailed, user friendly representation



392
393
394
395
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 392

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)


329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 329

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



385
386
387
388
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 385

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)


348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment.rb', line 348

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