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

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 update the Function resource from.

  • sid (String)

    The SID of the Function resource to update.



165
166
167
168
169
170
171
172
173
174
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 165

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



178
179
180
181
182
183
184
185
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 178

def delete

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    @version.delete('DELETE', @uri, headers: headers)
end

#fetchFunctionInstance

Fetch the FunctionInstance

Returns:



190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 190

def fetch

    headers = Twilio::Values.of({'Content-Type' => 'application/x-www-form-urlencoded', })
    
    
    
    
    
    payload = @version.fetch('GET', @uri, headers: headers)
    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)


238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 238

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



263
264
265
266
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 263

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

#to_sObject

Provide a user friendly representation



256
257
258
259
# File 'lib/twilio-ruby/rest/serverless/v1/service/function.rb', line 256

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:



211
212
213
214
215
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 211

def update(
    friendly_name: nil
)

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

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