twilio-ruby 5.1.1 → 5.1.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (30) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +17 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/api/v2010/account/incoming_phone_number.rb +8 -2
  5. data/lib/twilio-ruby/rest/chat/v2/service.rb +13 -2
  6. data/lib/twilio-ruby/rest/chat/v2/service/channel/message.rb +14 -0
  7. data/lib/twilio-ruby/rest/ip_messaging/v2/service.rb +13 -2
  8. data/lib/twilio-ruby/rest/ip_messaging/v2/service/channel/message.rb +14 -0
  9. data/lib/twilio-ruby/rest/preview.rb +16 -0
  10. data/lib/twilio-ruby/rest/preview/bulk_exports/export_configuration.rb +2 -13
  11. data/lib/twilio-ruby/rest/preview/deployed_devices.rb +42 -0
  12. data/lib/twilio-ruby/rest/preview/deployed_devices/fleet.rb +531 -0
  13. data/lib/twilio-ruby/rest/preview/deployed_devices/fleet/certificate.rb +428 -0
  14. data/lib/twilio-ruby/rest/preview/deployed_devices/fleet/deployment.rb +412 -0
  15. data/lib/twilio-ruby/rest/preview/deployed_devices/fleet/device.rb +465 -0
  16. data/lib/twilio-ruby/rest/preview/deployed_devices/fleet/key.rb +425 -0
  17. data/lib/twilio-ruby/rest/sync/v1/service.rb +7 -0
  18. data/lib/twilio-ruby/version.rb +1 -1
  19. data/spec/integration/chat/v2/service/channel/message_spec.rb +68 -0
  20. data/spec/integration/chat/v2/service_spec.rb +20 -4
  21. data/spec/integration/ip_messaging/v2/service/channel/message_spec.rb +68 -0
  22. data/spec/integration/ip_messaging/v2/service_spec.rb +20 -4
  23. data/spec/integration/preview/bulk_exports/export_configuration_spec.rb +1 -3
  24. data/spec/integration/preview/deployed_devices/fleet/certificate_spec.rb +238 -0
  25. data/spec/integration/preview/deployed_devices/fleet/deployment_spec.rb +231 -0
  26. data/spec/integration/preview/deployed_devices/fleet/device_spec.rb +247 -0
  27. data/spec/integration/preview/deployed_devices/fleet/key_spec.rb +235 -0
  28. data/spec/integration/preview/deployed_devices/fleet_spec.rb +244 -0
  29. data/spec/integration/sync/v1/service_spec.rb +4 -0
  30. metadata +19 -3
@@ -0,0 +1,428 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Preview < Domain
10
+ class DeployedDevices < Version
11
+ class FleetContext < InstanceContext
12
+ ##
13
+ # 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 help@twilio.com.
14
+ class CertificateList < ListResource
15
+ ##
16
+ # Initialize the CertificateList
17
+ # @param [Version] version Version that contains the resource
18
+ # @param [String] fleet_sid Specifies the unique string identifier of the Fleet
19
+ # that the given Certificate credential belongs to.
20
+ # @return [CertificateList] CertificateList
21
+ def initialize(version, fleet_sid: nil)
22
+ super(version)
23
+
24
+ # Path Solution
25
+ @solution = {
26
+ fleet_sid: fleet_sid
27
+ }
28
+ @uri = "/Fleets/#{@solution[:fleet_sid]}/Certificates"
29
+ end
30
+
31
+ ##
32
+ # Retrieve a single page of CertificateInstance records from the API.
33
+ # Request is executed immediately.
34
+ # @param [String] certificate_data Provides a URL encoded representation of the
35
+ # public certificate in PEM format.
36
+ # @param [String] friendly_name Provides a human readable descriptive text for
37
+ # this Certificate credential, up to 256 characters long.
38
+ # @param [String] device_sid Provides the unique string identifier of an existing
39
+ # Device to become authenticated with this Certificate credential.
40
+ # @return [CertificateInstance] Newly created CertificateInstance
41
+ def create(certificate_data: nil, friendly_name: :unset, device_sid: :unset)
42
+ data = Twilio::Values.of({
43
+ 'CertificateData' => certificate_data,
44
+ 'FriendlyName' => friendly_name,
45
+ 'DeviceSid' => device_sid,
46
+ })
47
+
48
+ payload = @version.create(
49
+ 'POST',
50
+ @uri,
51
+ data: data
52
+ )
53
+
54
+ CertificateInstance.new(
55
+ @version,
56
+ payload,
57
+ fleet_sid: @solution[:fleet_sid],
58
+ )
59
+ end
60
+
61
+ ##
62
+ # Lists CertificateInstance records from the API as a list.
63
+ # Unlike stream(), this operation is eager and will load `limit` records into
64
+ # memory before returning.
65
+ # @param [String] device_sid Filters the resulting list of Certificates by a
66
+ # unique string identifier of an authenticated Device.
67
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
68
+ # guarantees to never return more than limit. Default is no limit
69
+ # @param [Integer] page_size Number of records to fetch per request, when
70
+ # not set will use the default value of 50 records. If no page_size is defined
71
+ # but a limit is defined, stream() will attempt to read the limit with the most
72
+ # efficient page size, i.e. min(limit, 1000)
73
+ # @return [Array] Array of up to limit results
74
+ def list(device_sid: :unset, limit: nil, page_size: nil)
75
+ self.stream(
76
+ device_sid: device_sid,
77
+ limit: limit,
78
+ page_size: page_size
79
+ ).entries
80
+ end
81
+
82
+ ##
83
+ # Streams CertificateInstance records from the API as an Enumerable.
84
+ # This operation lazily loads records as efficiently as possible until the limit
85
+ # is reached.
86
+ # @param [String] device_sid Filters the resulting list of Certificates by a
87
+ # unique string identifier of an authenticated Device.
88
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
89
+ # guarantees to never return more than limit. Default is no limit.
90
+ # @param [Integer] page_size Number of records to fetch per request, when
91
+ # not set will use the default value of 50 records. If no page_size is defined
92
+ # but a limit is defined, stream() will attempt to read the limit with the most
93
+ # efficient page size, i.e. min(limit, 1000)
94
+ # @return [Enumerable] Enumerable that will yield up to limit results
95
+ def stream(device_sid: :unset, limit: nil, page_size: nil)
96
+ limits = @version.read_limits(limit, page_size)
97
+
98
+ page = self.page(
99
+ device_sid: device_sid,
100
+ page_size: limits[:page_size],
101
+ )
102
+
103
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
104
+ end
105
+
106
+ ##
107
+ # When passed a block, yields CertificateInstance records from the API.
108
+ # This operation lazily loads records as efficiently as possible until the limit
109
+ # is reached.
110
+ def each
111
+ limits = @version.read_limits
112
+
113
+ page = self.page(
114
+ page_size: limits[:page_size],
115
+ )
116
+
117
+ @version.stream(page,
118
+ limit: limits[:limit],
119
+ page_limit: limits[:page_limit]).each {|x| yield x}
120
+ end
121
+
122
+ ##
123
+ # Retrieve a single page of CertificateInstance records from the API.
124
+ # Request is executed immediately.
125
+ # @param [String] device_sid Filters the resulting list of Certificates by a
126
+ # unique string identifier of an authenticated Device.
127
+ # @param [String] page_token PageToken provided by the API
128
+ # @param [Integer] page_number Page Number, this value is simply for client state
129
+ # @param [Integer] page_size Number of records to return, defaults to 50
130
+ # @return [Page] Page of CertificateInstance
131
+ def page(device_sid: :unset, page_token: :unset, page_number: :unset, page_size: :unset)
132
+ params = Twilio::Values.of({
133
+ 'DeviceSid' => device_sid,
134
+ 'PageToken' => page_token,
135
+ 'Page' => page_number,
136
+ 'PageSize' => page_size,
137
+ })
138
+ response = @version.page(
139
+ 'GET',
140
+ @uri,
141
+ params
142
+ )
143
+ CertificatePage.new(@version, response, @solution)
144
+ end
145
+
146
+ ##
147
+ # Retrieve a single page of CertificateInstance records from the API.
148
+ # Request is executed immediately.
149
+ # @param [String] target_url API-generated URL for the requested results page
150
+ # @return [Page] Page of CertificateInstance
151
+ def get_page(target_url)
152
+ response = @version.domain.request(
153
+ 'GET',
154
+ target_url
155
+ )
156
+ CertificatePage.new(@version, response, @solution)
157
+ end
158
+
159
+ ##
160
+ # Provide a user friendly representation
161
+ def to_s
162
+ '#<Twilio.Preview.DeployedDevices.CertificateList>'
163
+ end
164
+ end
165
+
166
+ ##
167
+ # 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 help@twilio.com.
168
+ class CertificatePage < Page
169
+ ##
170
+ # Initialize the CertificatePage
171
+ # @param [Version] version Version that contains the resource
172
+ # @param [Response] response Response from the API
173
+ # @param [Hash] solution Path solution for the resource
174
+ # @return [CertificatePage] CertificatePage
175
+ def initialize(version, response, solution)
176
+ super(version, response)
177
+
178
+ # Path Solution
179
+ @solution = solution
180
+ end
181
+
182
+ ##
183
+ # Build an instance of CertificateInstance
184
+ # @param [Hash] payload Payload response from the API
185
+ # @return [CertificateInstance] CertificateInstance
186
+ def get_instance(payload)
187
+ CertificateInstance.new(
188
+ @version,
189
+ payload,
190
+ fleet_sid: @solution[:fleet_sid],
191
+ )
192
+ end
193
+
194
+ ##
195
+ # Provide a user friendly representation
196
+ def to_s
197
+ '<Twilio.Preview.DeployedDevices.CertificatePage>'
198
+ end
199
+ end
200
+
201
+ ##
202
+ # 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 help@twilio.com.
203
+ class CertificateContext < InstanceContext
204
+ ##
205
+ # Initialize the CertificateContext
206
+ # @param [Version] version Version that contains the resource
207
+ # @param [String] fleet_sid The fleet_sid
208
+ # @param [String] sid Provides a 34 character string that uniquely identifies the
209
+ # requested Certificate credential resource.
210
+ # @return [CertificateContext] CertificateContext
211
+ def initialize(version, fleet_sid, sid)
212
+ super(version)
213
+
214
+ # Path Solution
215
+ @solution = {
216
+ fleet_sid: fleet_sid,
217
+ sid: sid,
218
+ }
219
+ @uri = "/Fleets/#{@solution[:fleet_sid]}/Certificates/#{@solution[:sid]}"
220
+ end
221
+
222
+ ##
223
+ # Fetch a CertificateInstance
224
+ # @return [CertificateInstance] Fetched CertificateInstance
225
+ def fetch
226
+ params = Twilio::Values.of({})
227
+
228
+ payload = @version.fetch(
229
+ 'GET',
230
+ @uri,
231
+ params,
232
+ )
233
+
234
+ CertificateInstance.new(
235
+ @version,
236
+ payload,
237
+ fleet_sid: @solution[:fleet_sid],
238
+ sid: @solution[:sid],
239
+ )
240
+ end
241
+
242
+ ##
243
+ # Deletes the CertificateInstance
244
+ # @return [Boolean] true if delete succeeds, true otherwise
245
+ def delete
246
+ @version.delete('delete', @uri)
247
+ end
248
+
249
+ ##
250
+ # Update the CertificateInstance
251
+ # @param [String] friendly_name Provides a human readable descriptive text for
252
+ # this Certificate credential, up to 256 characters long.
253
+ # @param [String] device_sid Provides the unique string identifier of an existing
254
+ # Device to become authenticated with this Certificate credential.
255
+ # @return [CertificateInstance] Updated CertificateInstance
256
+ def update(friendly_name: :unset, device_sid: :unset)
257
+ data = Twilio::Values.of({
258
+ 'FriendlyName' => friendly_name,
259
+ 'DeviceSid' => device_sid,
260
+ })
261
+
262
+ payload = @version.update(
263
+ 'POST',
264
+ @uri,
265
+ data: data,
266
+ )
267
+
268
+ CertificateInstance.new(
269
+ @version,
270
+ payload,
271
+ fleet_sid: @solution[:fleet_sid],
272
+ sid: @solution[:sid],
273
+ )
274
+ end
275
+
276
+ ##
277
+ # Provide a user friendly representation
278
+ def to_s
279
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
280
+ "#<Twilio.Preview.DeployedDevices.CertificateContext #{context}>"
281
+ end
282
+ end
283
+
284
+ ##
285
+ # 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 help@twilio.com.
286
+ class CertificateInstance < InstanceResource
287
+ ##
288
+ # Initialize the CertificateInstance
289
+ # @param [Version] version Version that contains the resource
290
+ # @param [Hash] payload payload that contains response from Twilio
291
+ # @param [String] fleet_sid Specifies the unique string identifier of the Fleet
292
+ # that the given Certificate credential belongs to.
293
+ # @param [String] sid Provides a 34 character string that uniquely identifies the
294
+ # requested Certificate credential resource.
295
+ # @return [CertificateInstance] CertificateInstance
296
+ def initialize(version, payload, fleet_sid: nil, sid: nil)
297
+ super(version)
298
+
299
+ # Marshaled Properties
300
+ @properties = {
301
+ 'sid' => payload['sid'],
302
+ 'url' => payload['url'],
303
+ 'friendly_name' => payload['friendly_name'],
304
+ 'fleet_sid' => payload['fleet_sid'],
305
+ 'account_sid' => payload['account_sid'],
306
+ 'device_sid' => payload['device_sid'],
307
+ 'thumbprint' => payload['thumbprint'],
308
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
309
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
310
+ }
311
+
312
+ # Context
313
+ @instance_context = nil
314
+ @params = {
315
+ 'fleet_sid' => fleet_sid,
316
+ 'sid' => sid || @properties['sid'],
317
+ }
318
+ end
319
+
320
+ ##
321
+ # Generate an instance context for the instance, the context is capable of
322
+ # performing various actions. All instance actions are proxied to the context
323
+ # @return [CertificateContext] CertificateContext for this CertificateInstance
324
+ def context
325
+ unless @instance_context
326
+ @instance_context = CertificateContext.new(
327
+ @version,
328
+ @params['fleet_sid'],
329
+ @params['sid'],
330
+ )
331
+ end
332
+ @instance_context
333
+ end
334
+
335
+ ##
336
+ # @return [String] A string that uniquely identifies this Certificate.
337
+ def sid
338
+ @properties['sid']
339
+ end
340
+
341
+ ##
342
+ # @return [String] URL of this Certificate.
343
+ def url
344
+ @properties['url']
345
+ end
346
+
347
+ ##
348
+ # @return [String] A human readable description for this Certificate.
349
+ def friendly_name
350
+ @properties['friendly_name']
351
+ end
352
+
353
+ ##
354
+ # @return [String] The unique identifier of the Fleet.
355
+ def fleet_sid
356
+ @properties['fleet_sid']
357
+ end
358
+
359
+ ##
360
+ # @return [String] The unique SID that identifies this Account.
361
+ def account_sid
362
+ @properties['account_sid']
363
+ end
364
+
365
+ ##
366
+ # @return [String] The unique identifier of a mapped Device.
367
+ def device_sid
368
+ @properties['device_sid']
369
+ end
370
+
371
+ ##
372
+ # @return [String] A Certificate unique payload hash.
373
+ def thumbprint
374
+ @properties['thumbprint']
375
+ end
376
+
377
+ ##
378
+ # @return [Time] The date this Certificate was created.
379
+ def date_created
380
+ @properties['date_created']
381
+ end
382
+
383
+ ##
384
+ # @return [Time] The date this Certificate was updated.
385
+ def date_updated
386
+ @properties['date_updated']
387
+ end
388
+
389
+ ##
390
+ # Fetch a CertificateInstance
391
+ # @return [CertificateInstance] Fetched CertificateInstance
392
+ def fetch
393
+ context.fetch
394
+ end
395
+
396
+ ##
397
+ # Deletes the CertificateInstance
398
+ # @return [Boolean] true if delete succeeds, true otherwise
399
+ def delete
400
+ context.delete
401
+ end
402
+
403
+ ##
404
+ # Update the CertificateInstance
405
+ # @param [String] friendly_name Provides a human readable descriptive text for
406
+ # this Certificate credential, up to 256 characters long.
407
+ # @param [String] device_sid Provides the unique string identifier of an existing
408
+ # Device to become authenticated with this Certificate credential.
409
+ # @return [CertificateInstance] Updated CertificateInstance
410
+ def update(friendly_name: :unset, device_sid: :unset)
411
+ context.update(
412
+ friendly_name: friendly_name,
413
+ device_sid: device_sid,
414
+ )
415
+ end
416
+
417
+ ##
418
+ # Provide a user friendly representation
419
+ def to_s
420
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
421
+ "<Twilio.Preview.DeployedDevices.CertificateInstance #{values}>"
422
+ end
423
+ end
424
+ end
425
+ end
426
+ end
427
+ end
428
+ end
@@ -0,0 +1,412 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+
7
+ module Twilio
8
+ module REST
9
+ class Preview < Domain
10
+ class DeployedDevices < Version
11
+ class FleetContext < InstanceContext
12
+ ##
13
+ # 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 help@twilio.com.
14
+ class DeploymentList < ListResource
15
+ ##
16
+ # Initialize the DeploymentList
17
+ # @param [Version] version Version that contains the resource
18
+ # @param [String] fleet_sid Specifies the unique string identifier of the Fleet
19
+ # that the given Deployment belongs to.
20
+ # @return [DeploymentList] DeploymentList
21
+ def initialize(version, fleet_sid: nil)
22
+ super(version)
23
+
24
+ # Path Solution
25
+ @solution = {
26
+ fleet_sid: fleet_sid
27
+ }
28
+ @uri = "/Fleets/#{@solution[:fleet_sid]}/Deployments"
29
+ end
30
+
31
+ ##
32
+ # Retrieve a single page of DeploymentInstance records from the API.
33
+ # Request is executed immediately.
34
+ # @param [String] friendly_name Provides a human readable descriptive text for
35
+ # this Deployment, up to 256 characters long.
36
+ # @param [String] sync_service_sid Provides the unique string identifier of the
37
+ # Twilio Sync service instance that will be linked to and accessible by this
38
+ # Deployment.
39
+ # @return [DeploymentInstance] Newly created DeploymentInstance
40
+ def create(friendly_name: :unset, sync_service_sid: :unset)
41
+ data = Twilio::Values.of({
42
+ 'FriendlyName' => friendly_name,
43
+ 'SyncServiceSid' => sync_service_sid,
44
+ })
45
+
46
+ payload = @version.create(
47
+ 'POST',
48
+ @uri,
49
+ data: data
50
+ )
51
+
52
+ DeploymentInstance.new(
53
+ @version,
54
+ payload,
55
+ fleet_sid: @solution[:fleet_sid],
56
+ )
57
+ end
58
+
59
+ ##
60
+ # Lists DeploymentInstance records from the API as a list.
61
+ # Unlike stream(), this operation is eager and will load `limit` records into
62
+ # memory before returning.
63
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
64
+ # guarantees to never return more than limit. Default is no limit
65
+ # @param [Integer] page_size Number of records to fetch per request, when
66
+ # not set will use the default value of 50 records. If no page_size is defined
67
+ # but a limit is defined, stream() will attempt to read the limit with the most
68
+ # efficient page size, i.e. min(limit, 1000)
69
+ # @return [Array] Array of up to limit results
70
+ def list(limit: nil, page_size: nil)
71
+ self.stream(
72
+ limit: limit,
73
+ page_size: page_size
74
+ ).entries
75
+ end
76
+
77
+ ##
78
+ # Streams DeploymentInstance records from the API as an Enumerable.
79
+ # This operation lazily loads records as efficiently as possible until the limit
80
+ # is reached.
81
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
82
+ # guarantees to never return more than limit. Default is no limit.
83
+ # @param [Integer] page_size Number of records to fetch per request, when
84
+ # not set will use the default value of 50 records. If no page_size is defined
85
+ # but a limit is defined, stream() will attempt to read the limit with the most
86
+ # efficient page size, i.e. min(limit, 1000)
87
+ # @return [Enumerable] Enumerable that will yield up to limit results
88
+ def stream(limit: nil, page_size: nil)
89
+ limits = @version.read_limits(limit, page_size)
90
+
91
+ page = self.page(
92
+ page_size: limits[:page_size],
93
+ )
94
+
95
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
96
+ end
97
+
98
+ ##
99
+ # When passed a block, yields DeploymentInstance records from the API.
100
+ # This operation lazily loads records as efficiently as possible until the limit
101
+ # is reached.
102
+ def each
103
+ limits = @version.read_limits
104
+
105
+ page = self.page(
106
+ page_size: limits[:page_size],
107
+ )
108
+
109
+ @version.stream(page,
110
+ limit: limits[:limit],
111
+ page_limit: limits[:page_limit]).each {|x| yield x}
112
+ end
113
+
114
+ ##
115
+ # Retrieve a single page of DeploymentInstance records from the API.
116
+ # Request is executed immediately.
117
+ # @param [String] page_token PageToken provided by the API
118
+ # @param [Integer] page_number Page Number, this value is simply for client state
119
+ # @param [Integer] page_size Number of records to return, defaults to 50
120
+ # @return [Page] Page of DeploymentInstance
121
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
122
+ params = Twilio::Values.of({
123
+ 'PageToken' => page_token,
124
+ 'Page' => page_number,
125
+ 'PageSize' => page_size,
126
+ })
127
+ response = @version.page(
128
+ 'GET',
129
+ @uri,
130
+ params
131
+ )
132
+ DeploymentPage.new(@version, response, @solution)
133
+ end
134
+
135
+ ##
136
+ # Retrieve a single page of DeploymentInstance records from the API.
137
+ # Request is executed immediately.
138
+ # @param [String] target_url API-generated URL for the requested results page
139
+ # @return [Page] Page of DeploymentInstance
140
+ def get_page(target_url)
141
+ response = @version.domain.request(
142
+ 'GET',
143
+ target_url
144
+ )
145
+ DeploymentPage.new(@version, response, @solution)
146
+ end
147
+
148
+ ##
149
+ # Provide a user friendly representation
150
+ def to_s
151
+ '#<Twilio.Preview.DeployedDevices.DeploymentList>'
152
+ end
153
+ end
154
+
155
+ ##
156
+ # 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 help@twilio.com.
157
+ class DeploymentPage < Page
158
+ ##
159
+ # Initialize the DeploymentPage
160
+ # @param [Version] version Version that contains the resource
161
+ # @param [Response] response Response from the API
162
+ # @param [Hash] solution Path solution for the resource
163
+ # @return [DeploymentPage] DeploymentPage
164
+ def initialize(version, response, solution)
165
+ super(version, response)
166
+
167
+ # Path Solution
168
+ @solution = solution
169
+ end
170
+
171
+ ##
172
+ # Build an instance of DeploymentInstance
173
+ # @param [Hash] payload Payload response from the API
174
+ # @return [DeploymentInstance] DeploymentInstance
175
+ def get_instance(payload)
176
+ DeploymentInstance.new(
177
+ @version,
178
+ payload,
179
+ fleet_sid: @solution[:fleet_sid],
180
+ )
181
+ end
182
+
183
+ ##
184
+ # Provide a user friendly representation
185
+ def to_s
186
+ '<Twilio.Preview.DeployedDevices.DeploymentPage>'
187
+ end
188
+ end
189
+
190
+ ##
191
+ # 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 help@twilio.com.
192
+ class DeploymentContext < InstanceContext
193
+ ##
194
+ # Initialize the DeploymentContext
195
+ # @param [Version] version Version that contains the resource
196
+ # @param [String] fleet_sid The fleet_sid
197
+ # @param [String] sid Provides a 34 character string that uniquely identifies the
198
+ # requested Deployment resource.
199
+ # @return [DeploymentContext] DeploymentContext
200
+ def initialize(version, fleet_sid, sid)
201
+ super(version)
202
+
203
+ # Path Solution
204
+ @solution = {
205
+ fleet_sid: fleet_sid,
206
+ sid: sid,
207
+ }
208
+ @uri = "/Fleets/#{@solution[:fleet_sid]}/Deployments/#{@solution[:sid]}"
209
+ end
210
+
211
+ ##
212
+ # Fetch a DeploymentInstance
213
+ # @return [DeploymentInstance] Fetched DeploymentInstance
214
+ def fetch
215
+ params = Twilio::Values.of({})
216
+
217
+ payload = @version.fetch(
218
+ 'GET',
219
+ @uri,
220
+ params,
221
+ )
222
+
223
+ DeploymentInstance.new(
224
+ @version,
225
+ payload,
226
+ fleet_sid: @solution[:fleet_sid],
227
+ sid: @solution[:sid],
228
+ )
229
+ end
230
+
231
+ ##
232
+ # Deletes the DeploymentInstance
233
+ # @return [Boolean] true if delete succeeds, true otherwise
234
+ def delete
235
+ @version.delete('delete', @uri)
236
+ end
237
+
238
+ ##
239
+ # Update the DeploymentInstance
240
+ # @param [String] friendly_name Provides a human readable descriptive text for
241
+ # this Deployment, up to 64 characters long
242
+ # @param [String] sync_service_sid Provides the unique string identifier of the
243
+ # Twilio Sync service instance that will be linked to and accessible by this
244
+ # Deployment.
245
+ # @return [DeploymentInstance] Updated DeploymentInstance
246
+ def update(friendly_name: :unset, sync_service_sid: :unset)
247
+ data = Twilio::Values.of({
248
+ 'FriendlyName' => friendly_name,
249
+ 'SyncServiceSid' => sync_service_sid,
250
+ })
251
+
252
+ payload = @version.update(
253
+ 'POST',
254
+ @uri,
255
+ data: data,
256
+ )
257
+
258
+ DeploymentInstance.new(
259
+ @version,
260
+ payload,
261
+ fleet_sid: @solution[:fleet_sid],
262
+ sid: @solution[:sid],
263
+ )
264
+ end
265
+
266
+ ##
267
+ # Provide a user friendly representation
268
+ def to_s
269
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
270
+ "#<Twilio.Preview.DeployedDevices.DeploymentContext #{context}>"
271
+ end
272
+ end
273
+
274
+ ##
275
+ # 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 help@twilio.com.
276
+ class DeploymentInstance < InstanceResource
277
+ ##
278
+ # Initialize the DeploymentInstance
279
+ # @param [Version] version Version that contains the resource
280
+ # @param [Hash] payload payload that contains response from Twilio
281
+ # @param [String] fleet_sid Specifies the unique string identifier of the Fleet
282
+ # that the given Deployment belongs to.
283
+ # @param [String] sid Provides a 34 character string that uniquely identifies the
284
+ # requested Deployment resource.
285
+ # @return [DeploymentInstance] DeploymentInstance
286
+ def initialize(version, payload, fleet_sid: nil, sid: nil)
287
+ super(version)
288
+
289
+ # Marshaled Properties
290
+ @properties = {
291
+ 'sid' => payload['sid'],
292
+ 'url' => payload['url'],
293
+ 'friendly_name' => payload['friendly_name'],
294
+ 'fleet_sid' => payload['fleet_sid'],
295
+ 'account_sid' => payload['account_sid'],
296
+ 'sync_service_sid' => payload['sync_service_sid'],
297
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
298
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
299
+ }
300
+
301
+ # Context
302
+ @instance_context = nil
303
+ @params = {
304
+ 'fleet_sid' => fleet_sid,
305
+ 'sid' => sid || @properties['sid'],
306
+ }
307
+ end
308
+
309
+ ##
310
+ # Generate an instance context for the instance, the context is capable of
311
+ # performing various actions. All instance actions are proxied to the context
312
+ # @return [DeploymentContext] DeploymentContext for this DeploymentInstance
313
+ def context
314
+ unless @instance_context
315
+ @instance_context = DeploymentContext.new(
316
+ @version,
317
+ @params['fleet_sid'],
318
+ @params['sid'],
319
+ )
320
+ end
321
+ @instance_context
322
+ end
323
+
324
+ ##
325
+ # @return [String] A string that uniquely identifies this Deployment.
326
+ def sid
327
+ @properties['sid']
328
+ end
329
+
330
+ ##
331
+ # @return [String] URL of this Deployment.
332
+ def url
333
+ @properties['url']
334
+ end
335
+
336
+ ##
337
+ # @return [String] A human readable description for this Deployment
338
+ def friendly_name
339
+ @properties['friendly_name']
340
+ end
341
+
342
+ ##
343
+ # @return [String] The unique identifier of the Fleet.
344
+ def fleet_sid
345
+ @properties['fleet_sid']
346
+ end
347
+
348
+ ##
349
+ # @return [String] The unique SID that identifies this Account.
350
+ def account_sid
351
+ @properties['account_sid']
352
+ end
353
+
354
+ ##
355
+ # @return [String] The unique identifier of the Sync service instance.
356
+ def sync_service_sid
357
+ @properties['sync_service_sid']
358
+ end
359
+
360
+ ##
361
+ # @return [Time] The date this Deployment was created.
362
+ def date_created
363
+ @properties['date_created']
364
+ end
365
+
366
+ ##
367
+ # @return [Time] The date this Deployment was updated.
368
+ def date_updated
369
+ @properties['date_updated']
370
+ end
371
+
372
+ ##
373
+ # Fetch a DeploymentInstance
374
+ # @return [DeploymentInstance] Fetched DeploymentInstance
375
+ def fetch
376
+ context.fetch
377
+ end
378
+
379
+ ##
380
+ # Deletes the DeploymentInstance
381
+ # @return [Boolean] true if delete succeeds, true otherwise
382
+ def delete
383
+ context.delete
384
+ end
385
+
386
+ ##
387
+ # Update the DeploymentInstance
388
+ # @param [String] friendly_name Provides a human readable descriptive text for
389
+ # this Deployment, up to 64 characters long
390
+ # @param [String] sync_service_sid Provides the unique string identifier of the
391
+ # Twilio Sync service instance that will be linked to and accessible by this
392
+ # Deployment.
393
+ # @return [DeploymentInstance] Updated DeploymentInstance
394
+ def update(friendly_name: :unset, sync_service_sid: :unset)
395
+ context.update(
396
+ friendly_name: friendly_name,
397
+ sync_service_sid: sync_service_sid,
398
+ )
399
+ end
400
+
401
+ ##
402
+ # Provide a user friendly representation
403
+ def to_s
404
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
405
+ "<Twilio.Preview.DeployedDevices.DeploymentInstance #{values}>"
406
+ end
407
+ end
408
+ end
409
+ end
410
+ end
411
+ end
412
+ end