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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/serverless/v1/service/function.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: FunctionVersionContext, FunctionVersionInstance, FunctionVersionList, FunctionVersionPage

Instance Method Summary collapse

Constructor Details

#initialize(version, service_sid, sid) ⇒ FunctionContext

Initialize the FunctionContext

Parameters:

  • version (Version)

    Version that contains the resource

  • service_sid (String)

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

  • sid (String)

    The SID of the Function resource to fetch.


172
173
174
175
176
177
178
179
180
181
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 172

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

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

  # Dependents
  @function_versions = nil
end

Instance Method Details

#deleteBoolean

Delete the FunctionInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


195
196
197
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 195

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

#fetchFunctionInstance

Fetch the FunctionInstance

Returns:


186
187
188
189
190
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 186

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

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

#function_versions(sid = :unset) ⇒ FunctionVersionList, FunctionVersionContext

Access the function_versions

Returns:

Raises:

  • (ArgumentError)

216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 216

def function_versions(sid=:unset)
  raise ArgumentError, 'sid cannot be nil' if sid.nil?

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

  unless @function_versions
    @function_versions = FunctionVersionList.new(
        @version,
        service_sid: @solution[:service_sid],
        function_sid: @solution[:sid],
    )
  end

  @function_versions
end

#inspectObject

Provide a detailed, user friendly representation


243
244
245
246
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 243

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

#to_sObject

Provide a user friendly representation


236
237
238
239
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 236

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

#update(friendly_name: nil) ⇒ FunctionInstance

Update the FunctionInstance

Parameters:

  • friendly_name (String) (defaults to: nil)

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

Returns:


204
205
206
207
208
209
210
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 204

def update(friendly_name: nil)
  data = Twilio::Values.of({'FriendlyName' => friendly_name, })

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

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