Class: Twilio::REST::Microvisor::V1::DeviceContext

Inherits:
InstanceContext show all
Defined in:
lib/twilio-ruby/rest/microvisor/v1/device.rb,
lib/twilio-ruby/rest/microvisor/v1/device/device_config.rb,
lib/twilio-ruby/rest/microvisor/v1/device/device_secret.rb

Defined Under Namespace

Classes: DeviceConfigContext, DeviceConfigInstance, DeviceConfigList, DeviceConfigPage, DeviceSecretContext, DeviceSecretInstance, DeviceSecretList, DeviceSecretPage

Instance Method Summary collapse

Constructor Details

#initialize(version, sid) ⇒ DeviceContext

Initialize the DeviceContext

Parameters:

  • version (Version)

    Version that contains the resource

  • sid (String)

    A 34-character string that uniquely identifies this Device.



136
137
138
139
140
141
142
143
144
145
146
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 136

def initialize(version, sid)
    super(version)

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

    # Dependents
    @device_secrets = nil
    @device_configs = nil
end

Instance Method Details

#device_configs(key = :unset) ⇒ DeviceConfigList, DeviceConfigContext

Access the device_configs

Returns:

Raises:

  • (ArgumentError)


224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 224

def device_configs(key=:unset)

    raise ArgumentError, 'key cannot be nil' if key.nil?

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

    unless @device_configs
        @device_configs = DeviceConfigList.new(
            @version, device_sid: @solution[:sid], )
    end

 @device_configs
end

#device_secrets(key = :unset) ⇒ DeviceSecretList, DeviceSecretContext

Access the device_secrets

Returns:

Raises:

  • (ArgumentError)


205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 205

def device_secrets(key=:unset)

    raise ArgumentError, 'key cannot be nil' if key.nil?

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

    unless @device_secrets
        @device_secrets = DeviceSecretList.new(
            @version, device_sid: @solution[:sid], )
    end

 @device_secrets
end

#fetchDeviceInstance

Fetch the DeviceInstance

Returns:



150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 150

def fetch

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

#inspectObject

Provide a detailed, user friendly representation



249
250
251
252
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 249

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

#to_sObject

Provide a user friendly representation



242
243
244
245
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 242

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

#update(unique_name: :unset, target_app: :unset, logging_enabled: :unset, restart_app: :unset) ⇒ DeviceInstance

Update the DeviceInstance

Parameters:

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

    A unique and addressable name to be assigned to this Device by the developer. It may be used in place of the Device SID.

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

    The SID or unique name of the App to be targeted to the Device.

  • logging_enabled (Boolean) (defaults to: :unset)

    A Boolean flag specifying whether to enable application logging. Logs will be enabled or extended for 24 hours.

  • restart_app (Boolean) (defaults to: :unset)

    Set to true to restart the App running on the Device.

Returns:



173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
# File 'lib/twilio-ruby/rest/microvisor/v1/device.rb', line 173

def update(
    unique_name: :unset, 
    target_app: :unset, 
    logging_enabled: :unset, 
    restart_app: :unset
)

    data = Twilio::Values.of({
        'UniqueName' => unique_name,
        'TargetApp' => target_app,
        'LoggingEnabled' => logging_enabled,
        'RestartApp' => restart_app,
    })

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