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

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

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, environment_sid, sid) ⇒ VariableContext

Initialize the VariableContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

    The SID of the Service to update the Variable resource under.

  • environment_sid (String)

    The SID of the Environment with the Variable resource to update.

  • sid (String)

    The SID of the Variable resource to update.



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

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

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

    
end

Instance Method Details

#deleteBoolean

Delete the VariableInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

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 VariableInstanceMetadata

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



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

def 

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

#fetchVariableInstance

Fetch the VariableInstance

Returns:



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

def fetch

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

#fetch_with_metadataVariableInstance

Fetch the VariableInstanceMetadata

Returns:



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

def 

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

#inspectObject

Provide a detailed, user friendly representation



406
407
408
409
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb', line 406

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

#to_sObject

Provide a user friendly representation



399
400
401
402
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb', line 399

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

#update(key: :unset, value: :unset) ⇒ VariableInstance

Update the VariableInstance

Parameters:

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

    A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.

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

    A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.

Returns:



333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb', line 333

def update(
  key: :unset, 
  value: :unset
)

    data = Twilio::Values.of({
        'Key' => key,
        'Value' => value,
    })

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

#update_with_metadata(key: :unset, value: :unset) ⇒ VariableInstance

Update the VariableInstanceMetadata

Parameters:

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

    A string by which the Variable resource can be referenced. It can be a maximum of 128 characters.

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

    A string that contains the actual value of the Variable. It can be a maximum of 450 bytes in size.

Returns:



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
392
393
394
# File 'lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb', line 364

def (
  key: :unset, 
  value: :unset
)

    data = Twilio::Values.of({
        'Key' => key,
        'Value' => value,
    })

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