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

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/serverless/v1/service.rb,
lib/twilio-ruby/rest/serverless/v1/service/asset.rb,
lib/twilio-ruby/rest/serverless/v1/service/build.rb,
lib/twilio-ruby/rest/serverless/v1/service/function.rb,
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/build/build_status.rb,
lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb,
lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb,
lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb,
lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb,
lib/twilio-ruby/rest/serverless/v1/service/function/function_version/function_version_content.rb

Defined Under Namespace

Classes: AssetContext, AssetInstance, AssetInstanceMetadata, AssetList, AssetListResponse, AssetPage, AssetPageMetadata, BuildContext, BuildInstance, BuildInstanceMetadata, BuildList, BuildListResponse, BuildPage, BuildPageMetadata, EnvironmentContext, EnvironmentInstance, EnvironmentInstanceMetadata, EnvironmentList, EnvironmentListResponse, EnvironmentPage, EnvironmentPageMetadata, FunctionContext, FunctionInstance, FunctionInstanceMetadata, FunctionList, FunctionListResponse, FunctionPage, FunctionPageMetadata

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ ServiceContext

Initialize the ServiceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    The sid or unique_name of the Service resource to update.



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

def initialize(version, sid)
    super(version)
    

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

    # Dependents
    @environments = nil
    @functions = nil
    @builds = nil
    @assets = nil
end

Instance Method Details

#assets(sid = :unset) ⇒ AssetList, AssetContext

Access the assets

Returns:

Raises:

  • (ArgumentError)


454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 454

def assets(sid=:unset)

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

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

    unless @assets
        @assets = AssetList.new(
            @version, service_sid: @solution[:sid], )
    end

 @assets
end

#builds(sid = :unset) ⇒ BuildList, BuildContext

Access the builds

Returns:

Raises:

  • (ArgumentError)


435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 435

def builds(sid=:unset)

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

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

    unless @builds
        @builds = BuildList.new(
            @version, service_sid: @solution[:sid], )
    end

 @builds
end

#deleteBoolean

Delete the ServiceInstance

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.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 ServiceInstanceMetadata

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.rb', line 263

def 

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

#environments(sid = :unset) ⇒ EnvironmentList, EnvironmentContext

Access the environments

Returns:

Raises:

  • (ArgumentError)


397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 397

def environments(sid=:unset)

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

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

    unless @environments
        @environments = EnvironmentList.new(
            @version, service_sid: @solution[:sid], )
    end

 @environments
end

#fetchServiceInstance

Fetch the ServiceInstance

Returns:



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

def fetch

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

#fetch_with_metadataServiceInstance

Fetch the ServiceInstanceMetadata

Returns:



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

def 

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

#functions(sid = :unset) ⇒ FunctionList, FunctionContext

Access the functions

Returns:

Raises:

  • (ArgumentError)


416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 416

def functions(sid=:unset)

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

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

    unless @functions
        @functions = FunctionList.new(
            @version, service_sid: @solution[:sid], )
    end

 @functions
end

#inspectObject

Provide a detailed, user friendly representation



479
480
481
482
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 479

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

#to_sObject

Provide a user friendly representation



472
473
474
475
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 472

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

#update(include_credentials: :unset, friendly_name: :unset, ui_editable: :unset) ⇒ ServiceInstance

Update the ServiceInstance

Parameters:

  • include_credentials (Boolean) (defaults to: :unset)

    Whether to inject Account credentials into a function invocation context.

  • friendly_name (String) (defaults to: :unset)

    A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.

  • ui_editable (Boolean) (defaults to: :unset)

    Whether the Service resource’s properties and subresources can be edited via the UI. The default value is false.

Returns:



329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 329

def update(
    include_credentials: :unset, 
    friendly_name: :unset, 
    ui_editable: :unset
)

    data = Twilio::Values.of({
        'IncludeCredentials' => include_credentials,
        'FriendlyName' => friendly_name,
        'UiEditable' => ui_editable,
    })

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

#update_with_metadata(include_credentials: :unset, friendly_name: :unset, ui_editable: :unset) ⇒ ServiceInstance

Update the ServiceInstanceMetadata

Parameters:

  • include_credentials (Boolean) (defaults to: :unset)

    Whether to inject Account credentials into a function invocation context.

  • friendly_name (String) (defaults to: :unset)

    A descriptive string that you create to describe the Service resource. It can be a maximum of 255 characters.

  • ui_editable (Boolean) (defaults to: :unset)

    Whether the Service resource’s properties and subresources can be edited via the UI. The default value is false.

Returns:



361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 361

def (
  include_credentials: :unset, 
  friendly_name: :unset, 
  ui_editable: :unset
)

    data = Twilio::Values.of({
        'IncludeCredentials' => include_credentials,
        'FriendlyName' => friendly_name,
        'UiEditable' => ui_editable,
    })

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    response = @version.('POST', @uri, data: data, headers: headers)
    service_instance = ServiceInstance.new(
        @version,
        response.body,
        sid: @solution[:sid],
    )
    .new(
        @version,
        service_instance,
        response.headers,
        response.status_code
    )
end