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

Overview

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

Defined Under Namespace

Classes: AssetContext, AssetInstance, AssetList, AssetPage, BuildContext, BuildInstance, BuildList, BuildPage, EnvironmentContext, EnvironmentInstance, EnvironmentList, EnvironmentPage, FunctionContext, FunctionInstance, FunctionList, FunctionPage

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


180
181
182
183
184
185
186
187
188
189
190
191
192
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 180

def initialize(version, sid)
  super(version)

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

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

Instance Method Details

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

Access the assets

Returns:

Raises:

  • (ArgumentError)

271
272
273
274
275
276
277
278
279
280
281
282
283
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 271

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)

289
290
291
292
293
294
295
296
297
298
299
300
301
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 289

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


206
207
208
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 206

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

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

Access the environments

Returns:

Raises:

  • (ArgumentError)

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

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:


197
198
199
200
201
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 197

def fetch
  payload = @version.fetch('GET', @uri)

  ServiceInstance.new(@version, payload, sid: @solution[:sid], )
end

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

Access the functions

Returns:

Raises:

  • (ArgumentError)

253
254
255
256
257
258
259
260
261
262
263
264
265
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 253

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


312
313
314
315
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 312

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

#to_sObject

Provide a user friendly representation


305
306
307
308
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 305

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:


219
220
221
222
223
224
225
226
227
228
229
# File 'lib/twilio-ruby/rest/serverless/v1/service.rb', line 219

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

  payload = @version.update('POST', @uri, data: data)

  ServiceInstance.new(@version, payload, sid: @solution[:sid], )
end