Class: Twilio::REST::Preview::DeployedDevices::FleetContext::KeyContext

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb

Overview

PLEASE NOTE that this class contains preview products that are subject to change. Use them with caution. If you currently do not have developer preview access, please contact [email protected].

Instance Method Summary collapse

Constructor Details

#initialize(version, fleet_sid, sid) ⇒ KeyContext

Initialize the KeyContext

Parameters:

  • version (Version)

    Version that contains the resource

  • fleet_sid (String)
  • sid (String)

    Provides a 34 character string that uniquely identifies the requested Key credential resource.



166
167
168
169
170
171
172
173
174
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 166

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

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

    
end

Instance Method Details

#deleteBoolean

Delete the KeyInstance

Returns:

  • (Boolean)

    True if delete succeeds, false otherwise



178
179
180
181
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 178

def delete

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

#fetchKeyInstance

Fetch the KeyInstance

Returns:



186
187
188
189
190
191
192
193
194
195
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 186

def fetch

    payload = @version.fetch('GET', @uri)
    KeyInstance.new(
        @version,
        payload,
        fleet_sid: @solution[:fleet_sid],
        sid: @solution[:sid],
    )
end

#inspectObject

Provide a detailed, user friendly representation



231
232
233
234
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 231

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

#to_sObject

Provide a user friendly representation



224
225
226
227
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 224

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

#update(friendly_name: :unset, device_sid: :unset) ⇒ KeyInstance

Update the KeyInstance

Parameters:

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

    Provides a human readable descriptive text for this Key credential, up to 256 characters long.

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

    Provides the unique string identifier of an existing Device to become authenticated with this Key credential.

Returns:



202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb', line 202

def update(
    friendly_name: :unset, 
    device_sid: :unset
)

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

    payload = @version.update('POST', @uri, data: data)
    KeyInstance.new(
        @version,
        payload,
        fleet_sid: @solution[:fleet_sid],
        sid: @solution[:sid],
    )
end