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

Inherits:
InstanceContext
  • Object
show all
Defined in:
lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb,
lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb,
lib/twilio-ruby/rest/preview/deployed_devices/fleet/device.rb,
lib/twilio-ruby/rest/preview/deployed_devices/fleet/deployment.rb,
lib/twilio-ruby/rest/preview/deployed_devices/fleet/certificate.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]

Defined Under Namespace

Classes: CertificateContext, CertificateInstance, CertificateList, CertificatePage, DeploymentContext, DeploymentInstance, DeploymentList, DeploymentPage, DeviceContext, DeviceInstance, DeviceList, DevicePage, KeyContext, KeyInstance, KeyList, KeyPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ FleetContext

Initialize the FleetContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

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


168
169
170
171
172
173
174
175
176
177
178
179
180
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 168

def initialize(version, sid)
  super(version)

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

  # Dependents
  @devices = nil
  @deployments = nil
  @certificates = nil
  @keys = nil
end

Instance Method Details

#certificates(sid = :unset) ⇒ CertificateList, CertificateContext

Access the certificates

Returns:

Raises:

  • (ArgumentError)

256
257
258
259
260
261
262
263
264
265
266
267
268
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 256

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

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

  unless @certificates
    @certificates = CertificateList.new(@version, fleet_sid: @solution[:sid], )
  end

  @certificates
end

#deleteBoolean

Delete the FleetInstance

Returns:

  • (Boolean)

    true if delete succeeds, false otherwise


194
195
196
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 194

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

#deployments(sid = :unset) ⇒ DeploymentList, DeploymentContext

Access the deployments

Returns:

Raises:

  • (ArgumentError)

238
239
240
241
242
243
244
245
246
247
248
249
250
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 238

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

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

  unless @deployments
    @deployments = DeploymentList.new(@version, fleet_sid: @solution[:sid], )
  end

  @deployments
end

#devices(sid = :unset) ⇒ DeviceList, DeviceContext

Access the devices

Returns:

Raises:

  • (ArgumentError)

220
221
222
223
224
225
226
227
228
229
230
231
232
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 220

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

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

  unless @devices
    @devices = DeviceList.new(@version, fleet_sid: @solution[:sid], )
  end

  @devices
end

#fetchFleetInstance

Fetch the FleetInstance

Returns:


185
186
187
188
189
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 185

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

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

#inspectObject

Provide a detailed, user friendly representation


297
298
299
300
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 297

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

#keys(sid = :unset) ⇒ KeyList, KeyContext

Access the keys

Returns:

Raises:

  • (ArgumentError)

274
275
276
277
278
279
280
281
282
283
284
285
286
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 274

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

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

  unless @keys
    @keys = KeyList.new(@version, fleet_sid: @solution[:sid], )
  end

  @keys
end

#to_sObject

Provide a user friendly representation


290
291
292
293
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 290

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

#update(friendly_name: :unset, default_deployment_sid: :unset) ⇒ FleetInstance

Update the FleetInstance

Parameters:

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

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

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

    Provides a string identifier of a Deployment that is going to be used as a default one for this Fleet.

Returns:


205
206
207
208
209
210
211
212
213
214
# File 'lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb', line 205

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

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

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