twilio-ruby 5.34.0 → 5.38.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +126 -0
  3. data/README.md +24 -3
  4. data/lib/twilio-ruby.rb +1 -1
  5. data/lib/twilio-ruby/rest/api/v2010/account/call.rb +87 -87
  6. data/lib/twilio-ruby/rest/api/v2010/account/conference.rb +14 -0
  7. data/lib/twilio-ruby/rest/api/v2010/account/conference/participant.rb +47 -9
  8. data/lib/twilio-ruby/rest/api/v2010/account/message.rb +71 -71
  9. data/lib/twilio-ruby/rest/api/v2010/account/queue.rb +29 -29
  10. data/lib/twilio-ruby/rest/api/v2010/account/sip/domain.rb +38 -3
  11. data/lib/twilio-ruby/rest/api/v2010/account/validation_request.rb +12 -12
  12. data/lib/twilio-ruby/rest/autopilot.rb +6 -0
  13. data/lib/twilio-ruby/rest/autopilot/v1.rb +7 -0
  14. data/lib/twilio-ruby/rest/autopilot/v1/assistant.rb +0 -16
  15. data/lib/twilio-ruby/rest/autopilot/v1/assistant/query.rb +12 -3
  16. data/lib/twilio-ruby/rest/autopilot/v1/restore_assistant.rb +198 -0
  17. data/lib/twilio-ruby/rest/client.rb +35 -15
  18. data/lib/twilio-ruby/rest/conversations/v1/conversation.rb +28 -3
  19. data/lib/twilio-ruby/rest/conversations/v1/conversation/participant.rb +27 -4
  20. data/lib/twilio-ruby/rest/flex_api/v1/channel.rb +2 -1
  21. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +7 -0
  22. data/lib/twilio-ruby/rest/flex_api/v1/flex_flow.rb +6 -3
  23. data/lib/twilio-ruby/rest/monitor/v1/alert.rb +8 -8
  24. data/lib/twilio-ruby/rest/notify/v1/service.rb +20 -1
  25. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle.rb +26 -0
  26. data/lib/twilio-ruby/rest/numbers/v2/regulatory_compliance/bundle/evaluation.rb +324 -0
  27. data/lib/twilio-ruby/rest/preview.rb +6 -0
  28. data/lib/twilio-ruby/rest/preview/trusted_comms.rb +7 -0
  29. data/lib/twilio-ruby/rest/preview/trusted_comms/brands_information.rb +193 -0
  30. data/lib/twilio-ruby/rest/preview/trusted_comms/business.rb +26 -0
  31. data/lib/twilio-ruby/rest/{autopilot/v1/assistant/export_assistant.rb → preview/trusted_comms/business/brand.rb} +88 -71
  32. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel.rb +266 -0
  33. data/lib/twilio-ruby/rest/preview/trusted_comms/business/brand/branded_channel/channel.rb +194 -0
  34. data/lib/twilio-ruby/rest/serverless/v1/service/environment/log.rb +7 -0
  35. data/lib/twilio-ruby/rest/supersim.rb +18 -0
  36. data/lib/twilio-ruby/rest/supersim/v1.rb +30 -0
  37. data/lib/twilio-ruby/rest/supersim/v1/fleet.rb +63 -16
  38. data/lib/twilio-ruby/rest/supersim/v1/network.rb +315 -0
  39. data/lib/twilio-ruby/rest/{authy/v1/service.rb → supersim/v1/network_access_profile.rb} +95 -121
  40. data/lib/twilio-ruby/rest/supersim/v1/network_access_profile/network_access_profile_network.rb +352 -0
  41. data/lib/twilio-ruby/rest/verify.rb +9 -0
  42. data/lib/twilio-ruby/rest/verify/v2.rb +16 -0
  43. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/form.rb +8 -8
  44. data/lib/twilio-ruby/rest/verify/v2/service.rb +74 -3
  45. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/service/entity.rb +32 -8
  46. data/lib/twilio-ruby/rest/verify/v2/service/entity/access_token.rb +141 -0
  47. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/service/entity/factor.rb +8 -8
  48. data/lib/twilio-ruby/rest/{authy/v1 → verify/v2}/service/entity/factor/challenge.rb +8 -8
  49. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +3 -3
  50. data/lib/twilio-ruby/rest/verify/v2/service/webhook.rb +425 -0
  51. data/lib/twilio-ruby/rest/video/v1/composition_settings.rb +8 -4
  52. data/lib/twilio-ruby/rest/video/v1/recording_settings.rb +8 -4
  53. data/lib/twilio-ruby/rest/voice.rb +36 -0
  54. data/lib/twilio-ruby/rest/voice/v1.rb +64 -0
  55. data/lib/twilio-ruby/rest/voice/v1/byoc_trunk.rb +513 -0
  56. data/lib/twilio-ruby/rest/voice/v1/connection_policy.rb +379 -0
  57. data/lib/twilio-ruby/rest/voice/v1/connection_policy/connection_policy_target.rb +458 -0
  58. data/lib/twilio-ruby/rest/voice/v1/ip_record.rb +366 -0
  59. data/lib/twilio-ruby/rest/voice/v1/source_ip_mapping.rb +346 -0
  60. data/lib/twilio-ruby/util/configuration.rb +9 -1
  61. data/lib/twilio-ruby/version.rb +1 -1
  62. data/spec/integration/api/v2010/account/call_spec.rb +5 -5
  63. data/spec/integration/api/v2010/account/conference/participant_spec.rb +177 -0
  64. data/spec/integration/api/v2010/account/conference_spec.rb +42 -14
  65. data/spec/integration/api/v2010/account/outgoing_caller_id_spec.rb +8 -14
  66. data/spec/integration/api/v2010/account/sip/domain_spec.rb +12 -4
  67. data/spec/integration/api/v2010/account/token_spec.rb +23 -11
  68. data/spec/integration/api/v2010/account/validation_request_spec.rb +1 -1
  69. data/spec/integration/autopilot/v1/assistant/query_spec.rb +4 -4
  70. data/spec/integration/autopilot/v1/assistant_spec.rb +4 -8
  71. data/spec/integration/autopilot/v1/restore_assistant_spec.rb +53 -0
  72. data/spec/integration/conversations/v1/conversation/participant_spec.rb +7 -0
  73. data/spec/integration/conversations/v1/conversation_spec.rb +16 -0
  74. data/spec/integration/flex_api/v1/configuration_spec.rb +3 -0
  75. data/spec/integration/numbers/v2/regulatory_compliance/bundle/evaluation_spec.rb +623 -0
  76. data/spec/integration/numbers/v2/regulatory_compliance/bundle_spec.rb +4 -0
  77. data/spec/integration/preview/trusted_comms/brands_information_spec.rb +44 -0
  78. data/spec/integration/preview/trusted_comms/business/brand/branded_channel/channel_spec.rb +54 -0
  79. data/spec/integration/preview/trusted_comms/business/brand/branded_channel_spec.rb +52 -0
  80. data/spec/integration/preview/trusted_comms/business/brand_spec.rb +49 -0
  81. data/spec/integration/preview/trusted_comms/business_spec.rb +1 -0
  82. data/spec/integration/serverless/v1/service/environment/log_spec.rb +1 -0
  83. data/spec/integration/supersim/v1/fleet_spec.rb +16 -7
  84. data/spec/integration/supersim/v1/network_access_profile/network_access_profile_network_spec.rb +179 -0
  85. data/spec/integration/supersim/v1/network_access_profile_spec.rb +223 -0
  86. data/spec/integration/supersim/v1/network_spec.rb +139 -0
  87. data/spec/integration/supersim/v1/sim_spec.rb +78 -6
  88. data/spec/integration/trunking/v1/trunk/credential_list_spec.rb +13 -13
  89. data/spec/integration/trunking/v1/trunk/ip_access_control_list_spec.rb +23 -23
  90. data/spec/integration/trunking/v1/trunk/origination_url_spec.rb +28 -28
  91. data/spec/integration/trunking/v1/trunk/phone_number_spec.rb +17 -17
  92. data/spec/integration/trunking/v1/trunk_spec.rb +33 -33
  93. data/spec/integration/{authy/v1 → verify/v2}/form_spec.rb +4 -4
  94. data/spec/integration/verify/v2/service/entity/access_token_spec.rb +46 -0
  95. data/spec/integration/{authy/v1 → verify/v2}/service/entity/factor/challenge_spec.rb +73 -73
  96. data/spec/integration/{authy/v1 → verify/v2}/service/entity/factor_spec.rb +54 -54
  97. data/spec/integration/verify/v2/service/entity_spec.rb +204 -0
  98. data/spec/integration/verify/v2/service/webhook_spec.rb +262 -0
  99. data/spec/integration/verify/v2/service_spec.rb +32 -4
  100. data/spec/integration/voice/v1/byoc_trunk_spec.rb +250 -0
  101. data/spec/integration/voice/v1/connection_policy/connection_policy_target_spec.rb +246 -0
  102. data/spec/integration/voice/v1/connection_policy_spec.rb +226 -0
  103. data/spec/integration/voice/v1/ip_record_spec.rb +223 -0
  104. data/spec/integration/voice/v1/source_ip_mapping_spec.rb +219 -0
  105. data/spec/rest/client_spec.rb +168 -58
  106. data/spec/util/configuration_spec.rb +12 -0
  107. data/twilio-ruby.gemspec +1 -1
  108. metadata +63 -23
  109. data/lib/twilio-ruby/rest/authy.rb +0 -55
  110. data/lib/twilio-ruby/rest/authy/v1.rb +0 -59
  111. data/spec/integration/authy/v1/service/entity_spec.rb +0 -201
  112. data/spec/integration/authy/v1/service_spec.rb +0 -231
  113. data/spec/integration/autopilot/v1/assistant/export_assistant_spec.rb +0 -49
@@ -0,0 +1,379 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Voice < Domain
12
+ class V1 < Version
13
+ class ConnectionPolicyList < ListResource
14
+ ##
15
+ # Initialize the ConnectionPolicyList
16
+ # @param [Version] version Version that contains the resource
17
+ # @return [ConnectionPolicyList] ConnectionPolicyList
18
+ def initialize(version)
19
+ super(version)
20
+
21
+ # Path Solution
22
+ @solution = {}
23
+ @uri = "/ConnectionPolicies"
24
+ end
25
+
26
+ ##
27
+ # Retrieve a single page of ConnectionPolicyInstance records from the API.
28
+ # Request is executed immediately.
29
+ # @param [String] friendly_name A descriptive string that you create to describe
30
+ # the resource. It is not unique and can be up to 255 characters long.
31
+ # @return [ConnectionPolicyInstance] Newly created ConnectionPolicyInstance
32
+ def create(friendly_name: :unset)
33
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, })
34
+
35
+ payload = @version.create(
36
+ 'POST',
37
+ @uri,
38
+ data: data
39
+ )
40
+
41
+ ConnectionPolicyInstance.new(@version, payload, )
42
+ end
43
+
44
+ ##
45
+ # Lists ConnectionPolicyInstance records from the API as a list.
46
+ # Unlike stream(), this operation is eager and will load `limit` records into
47
+ # memory before returning.
48
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
49
+ # guarantees to never return more than limit. Default is no limit
50
+ # @param [Integer] page_size Number of records to fetch per request, when
51
+ # not set will use the default value of 50 records. If no page_size is defined
52
+ # but a limit is defined, stream() will attempt to read the limit with the most
53
+ # efficient page size, i.e. min(limit, 1000)
54
+ # @return [Array] Array of up to limit results
55
+ def list(limit: nil, page_size: nil)
56
+ self.stream(limit: limit, page_size: page_size).entries
57
+ end
58
+
59
+ ##
60
+ # Streams ConnectionPolicyInstance records from the API as an Enumerable.
61
+ # This operation lazily loads records as efficiently as possible until the limit
62
+ # is reached.
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 [Enumerable] Enumerable that will yield up to limit results
70
+ def stream(limit: nil, page_size: nil)
71
+ limits = @version.read_limits(limit, page_size)
72
+
73
+ page = self.page(page_size: limits[:page_size], )
74
+
75
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
76
+ end
77
+
78
+ ##
79
+ # When passed a block, yields ConnectionPolicyInstance records from the API.
80
+ # This operation lazily loads records as efficiently as possible until the limit
81
+ # is reached.
82
+ def each
83
+ limits = @version.read_limits
84
+
85
+ page = self.page(page_size: limits[:page_size], )
86
+
87
+ @version.stream(page,
88
+ limit: limits[:limit],
89
+ page_limit: limits[:page_limit]).each {|x| yield x}
90
+ end
91
+
92
+ ##
93
+ # Retrieve a single page of ConnectionPolicyInstance records from the API.
94
+ # Request is executed immediately.
95
+ # @param [String] page_token PageToken provided by the API
96
+ # @param [Integer] page_number Page Number, this value is simply for client state
97
+ # @param [Integer] page_size Number of records to return, defaults to 50
98
+ # @return [Page] Page of ConnectionPolicyInstance
99
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
100
+ params = Twilio::Values.of({
101
+ 'PageToken' => page_token,
102
+ 'Page' => page_number,
103
+ 'PageSize' => page_size,
104
+ })
105
+ response = @version.page(
106
+ 'GET',
107
+ @uri,
108
+ params
109
+ )
110
+ ConnectionPolicyPage.new(@version, response, @solution)
111
+ end
112
+
113
+ ##
114
+ # Retrieve a single page of ConnectionPolicyInstance records from the API.
115
+ # Request is executed immediately.
116
+ # @param [String] target_url API-generated URL for the requested results page
117
+ # @return [Page] Page of ConnectionPolicyInstance
118
+ def get_page(target_url)
119
+ response = @version.domain.request(
120
+ 'GET',
121
+ target_url
122
+ )
123
+ ConnectionPolicyPage.new(@version, response, @solution)
124
+ end
125
+
126
+ ##
127
+ # Provide a user friendly representation
128
+ def to_s
129
+ '#<Twilio.Voice.V1.ConnectionPolicyList>'
130
+ end
131
+ end
132
+
133
+ class ConnectionPolicyPage < Page
134
+ ##
135
+ # Initialize the ConnectionPolicyPage
136
+ # @param [Version] version Version that contains the resource
137
+ # @param [Response] response Response from the API
138
+ # @param [Hash] solution Path solution for the resource
139
+ # @return [ConnectionPolicyPage] ConnectionPolicyPage
140
+ def initialize(version, response, solution)
141
+ super(version, response)
142
+
143
+ # Path Solution
144
+ @solution = solution
145
+ end
146
+
147
+ ##
148
+ # Build an instance of ConnectionPolicyInstance
149
+ # @param [Hash] payload Payload response from the API
150
+ # @return [ConnectionPolicyInstance] ConnectionPolicyInstance
151
+ def get_instance(payload)
152
+ ConnectionPolicyInstance.new(@version, payload, )
153
+ end
154
+
155
+ ##
156
+ # Provide a user friendly representation
157
+ def to_s
158
+ '<Twilio.Voice.V1.ConnectionPolicyPage>'
159
+ end
160
+ end
161
+
162
+ class ConnectionPolicyContext < InstanceContext
163
+ ##
164
+ # Initialize the ConnectionPolicyContext
165
+ # @param [Version] version Version that contains the resource
166
+ # @param [String] sid The unique string that we created to identify the Connection
167
+ # Policy resource to fetch.
168
+ # @return [ConnectionPolicyContext] ConnectionPolicyContext
169
+ def initialize(version, sid)
170
+ super(version)
171
+
172
+ # Path Solution
173
+ @solution = {sid: sid, }
174
+ @uri = "/ConnectionPolicies/#{@solution[:sid]}"
175
+
176
+ # Dependents
177
+ @targets = nil
178
+ end
179
+
180
+ ##
181
+ # Fetch a ConnectionPolicyInstance
182
+ # @return [ConnectionPolicyInstance] Fetched ConnectionPolicyInstance
183
+ def fetch
184
+ params = Twilio::Values.of({})
185
+
186
+ payload = @version.fetch(
187
+ 'GET',
188
+ @uri,
189
+ params,
190
+ )
191
+
192
+ ConnectionPolicyInstance.new(@version, payload, sid: @solution[:sid], )
193
+ end
194
+
195
+ ##
196
+ # Update the ConnectionPolicyInstance
197
+ # @param [String] friendly_name A descriptive string that you create to describe
198
+ # the resource. It is not unique and can be up to 255 characters long.
199
+ # @return [ConnectionPolicyInstance] Updated ConnectionPolicyInstance
200
+ def update(friendly_name: :unset)
201
+ data = Twilio::Values.of({'FriendlyName' => friendly_name, })
202
+
203
+ payload = @version.update(
204
+ 'POST',
205
+ @uri,
206
+ data: data,
207
+ )
208
+
209
+ ConnectionPolicyInstance.new(@version, payload, sid: @solution[:sid], )
210
+ end
211
+
212
+ ##
213
+ # Deletes the ConnectionPolicyInstance
214
+ # @return [Boolean] true if delete succeeds, false otherwise
215
+ def delete
216
+ @version.delete('delete', @uri)
217
+ end
218
+
219
+ ##
220
+ # Access the targets
221
+ # @return [ConnectionPolicyTargetList]
222
+ # @return [ConnectionPolicyTargetContext] if sid was passed.
223
+ def targets(sid=:unset)
224
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
225
+
226
+ if sid != :unset
227
+ return ConnectionPolicyTargetContext.new(@version, @solution[:sid], sid, )
228
+ end
229
+
230
+ unless @targets
231
+ @targets = ConnectionPolicyTargetList.new(@version, connection_policy_sid: @solution[:sid], )
232
+ end
233
+
234
+ @targets
235
+ end
236
+
237
+ ##
238
+ # Provide a user friendly representation
239
+ def to_s
240
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
241
+ "#<Twilio.Voice.V1.ConnectionPolicyContext #{context}>"
242
+ end
243
+
244
+ ##
245
+ # Provide a detailed, user friendly representation
246
+ def inspect
247
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
248
+ "#<Twilio.Voice.V1.ConnectionPolicyContext #{context}>"
249
+ end
250
+ end
251
+
252
+ class ConnectionPolicyInstance < InstanceResource
253
+ ##
254
+ # Initialize the ConnectionPolicyInstance
255
+ # @param [Version] version Version that contains the resource
256
+ # @param [Hash] payload payload that contains response from Twilio
257
+ # @param [String] sid The unique string that we created to identify the Connection
258
+ # Policy resource to fetch.
259
+ # @return [ConnectionPolicyInstance] ConnectionPolicyInstance
260
+ def initialize(version, payload, sid: nil)
261
+ super(version)
262
+
263
+ # Marshaled Properties
264
+ @properties = {
265
+ 'account_sid' => payload['account_sid'],
266
+ 'sid' => payload['sid'],
267
+ 'friendly_name' => payload['friendly_name'],
268
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
269
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
270
+ 'url' => payload['url'],
271
+ 'links' => payload['links'],
272
+ }
273
+
274
+ # Context
275
+ @instance_context = nil
276
+ @params = {'sid' => sid || @properties['sid'], }
277
+ end
278
+
279
+ ##
280
+ # Generate an instance context for the instance, the context is capable of
281
+ # performing various actions. All instance actions are proxied to the context
282
+ # @return [ConnectionPolicyContext] ConnectionPolicyContext for this ConnectionPolicyInstance
283
+ def context
284
+ unless @instance_context
285
+ @instance_context = ConnectionPolicyContext.new(@version, @params['sid'], )
286
+ end
287
+ @instance_context
288
+ end
289
+
290
+ ##
291
+ # @return [String] The SID of the Account that created the resource
292
+ def account_sid
293
+ @properties['account_sid']
294
+ end
295
+
296
+ ##
297
+ # @return [String] The unique string that identifies the resource
298
+ def sid
299
+ @properties['sid']
300
+ end
301
+
302
+ ##
303
+ # @return [String] The string that you assigned to describe the resource
304
+ def friendly_name
305
+ @properties['friendly_name']
306
+ end
307
+
308
+ ##
309
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was created
310
+ def date_created
311
+ @properties['date_created']
312
+ end
313
+
314
+ ##
315
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was last updated
316
+ def date_updated
317
+ @properties['date_updated']
318
+ end
319
+
320
+ ##
321
+ # @return [String] The absolute URL of the resource
322
+ def url
323
+ @properties['url']
324
+ end
325
+
326
+ ##
327
+ # @return [String] The URLs of related resources
328
+ def links
329
+ @properties['links']
330
+ end
331
+
332
+ ##
333
+ # Fetch a ConnectionPolicyInstance
334
+ # @return [ConnectionPolicyInstance] Fetched ConnectionPolicyInstance
335
+ def fetch
336
+ context.fetch
337
+ end
338
+
339
+ ##
340
+ # Update the ConnectionPolicyInstance
341
+ # @param [String] friendly_name A descriptive string that you create to describe
342
+ # the resource. It is not unique and can be up to 255 characters long.
343
+ # @return [ConnectionPolicyInstance] Updated ConnectionPolicyInstance
344
+ def update(friendly_name: :unset)
345
+ context.update(friendly_name: friendly_name, )
346
+ end
347
+
348
+ ##
349
+ # Deletes the ConnectionPolicyInstance
350
+ # @return [Boolean] true if delete succeeds, false otherwise
351
+ def delete
352
+ context.delete
353
+ end
354
+
355
+ ##
356
+ # Access the targets
357
+ # @return [targets] targets
358
+ def targets
359
+ context.targets
360
+ end
361
+
362
+ ##
363
+ # Provide a user friendly representation
364
+ def to_s
365
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
366
+ "<Twilio.Voice.V1.ConnectionPolicyInstance #{values}>"
367
+ end
368
+
369
+ ##
370
+ # Provide a detailed, user friendly representation
371
+ def inspect
372
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
373
+ "<Twilio.Voice.V1.ConnectionPolicyInstance #{values}>"
374
+ end
375
+ end
376
+ end
377
+ end
378
+ end
379
+ end
@@ -0,0 +1,458 @@
1
+ ##
2
+ # This code was generated by
3
+ # \ / _ _ _| _ _
4
+ # | (_)\/(_)(_|\/| |(/_ v1.0.0
5
+ # / /
6
+ #
7
+ # frozen_string_literal: true
8
+
9
+ module Twilio
10
+ module REST
11
+ class Voice < Domain
12
+ class V1 < Version
13
+ class ConnectionPolicyContext < InstanceContext
14
+ class ConnectionPolicyTargetList < ListResource
15
+ ##
16
+ # Initialize the ConnectionPolicyTargetList
17
+ # @param [Version] version Version that contains the resource
18
+ # @param [String] connection_policy_sid The SID of the Connection Policy that owns
19
+ # the Target.
20
+ # @return [ConnectionPolicyTargetList] ConnectionPolicyTargetList
21
+ def initialize(version, connection_policy_sid: nil)
22
+ super(version)
23
+
24
+ # Path Solution
25
+ @solution = {connection_policy_sid: connection_policy_sid}
26
+ @uri = "/ConnectionPolicies/#{@solution[:connection_policy_sid]}/Targets"
27
+ end
28
+
29
+ ##
30
+ # Retrieve a single page of ConnectionPolicyTargetInstance records from the API.
31
+ # Request is executed immediately.
32
+ # @param [String] target The SIP address you want Twilio to route your calls to.
33
+ # This must be a `sip:` schema. `sips` is NOT supported.
34
+ # @param [String] friendly_name A descriptive string that you create to describe
35
+ # the resource. It is not unique and can be up to 255 characters long.
36
+ # @param [String] priority The relative importance of the target. Can be an
37
+ # integer from 0 to 65535, inclusive, and the default is 10. The lowest number
38
+ # represents the most important target.
39
+ # @param [String] weight The value that determines the relative share of the load
40
+ # the Target should receive compared to other Targets with the same priority. Can
41
+ # be an integer from 1 to 65535, inclusive, and the default is 10. Targets with
42
+ # higher values receive more load than those with lower ones with the same
43
+ # priority.
44
+ # @param [Boolean] enabled Whether the Target is enabled. The default is `true`.
45
+ # @return [ConnectionPolicyTargetInstance] Newly created ConnectionPolicyTargetInstance
46
+ def create(target: nil, friendly_name: :unset, priority: :unset, weight: :unset, enabled: :unset)
47
+ data = Twilio::Values.of({
48
+ 'Target' => target,
49
+ 'FriendlyName' => friendly_name,
50
+ 'Priority' => priority,
51
+ 'Weight' => weight,
52
+ 'Enabled' => enabled,
53
+ })
54
+
55
+ payload = @version.create(
56
+ 'POST',
57
+ @uri,
58
+ data: data
59
+ )
60
+
61
+ ConnectionPolicyTargetInstance.new(
62
+ @version,
63
+ payload,
64
+ connection_policy_sid: @solution[:connection_policy_sid],
65
+ )
66
+ end
67
+
68
+ ##
69
+ # Lists ConnectionPolicyTargetInstance records from the API as a list.
70
+ # Unlike stream(), this operation is eager and will load `limit` records into
71
+ # memory before returning.
72
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
73
+ # guarantees to never return more than limit. Default is no limit
74
+ # @param [Integer] page_size Number of records to fetch per request, when
75
+ # not set will use the default value of 50 records. If no page_size is defined
76
+ # but a limit is defined, stream() will attempt to read the limit with the most
77
+ # efficient page size, i.e. min(limit, 1000)
78
+ # @return [Array] Array of up to limit results
79
+ def list(limit: nil, page_size: nil)
80
+ self.stream(limit: limit, page_size: page_size).entries
81
+ end
82
+
83
+ ##
84
+ # Streams ConnectionPolicyTargetInstance records from the API as an Enumerable.
85
+ # This operation lazily loads records as efficiently as possible until the limit
86
+ # is reached.
87
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
88
+ # guarantees to never return more than limit. Default is no limit.
89
+ # @param [Integer] page_size Number of records to fetch per request, when
90
+ # not set will use the default value of 50 records. If no page_size is defined
91
+ # but a limit is defined, stream() will attempt to read the limit with the most
92
+ # efficient page size, i.e. min(limit, 1000)
93
+ # @return [Enumerable] Enumerable that will yield up to limit results
94
+ def stream(limit: nil, page_size: nil)
95
+ limits = @version.read_limits(limit, page_size)
96
+
97
+ page = self.page(page_size: limits[:page_size], )
98
+
99
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
100
+ end
101
+
102
+ ##
103
+ # When passed a block, yields ConnectionPolicyTargetInstance records from the API.
104
+ # This operation lazily loads records as efficiently as possible until the limit
105
+ # is reached.
106
+ def each
107
+ limits = @version.read_limits
108
+
109
+ page = self.page(page_size: limits[:page_size], )
110
+
111
+ @version.stream(page,
112
+ limit: limits[:limit],
113
+ page_limit: limits[:page_limit]).each {|x| yield x}
114
+ end
115
+
116
+ ##
117
+ # Retrieve a single page of ConnectionPolicyTargetInstance records from the API.
118
+ # Request is executed immediately.
119
+ # @param [String] page_token PageToken provided by the API
120
+ # @param [Integer] page_number Page Number, this value is simply for client state
121
+ # @param [Integer] page_size Number of records to return, defaults to 50
122
+ # @return [Page] Page of ConnectionPolicyTargetInstance
123
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
124
+ params = Twilio::Values.of({
125
+ 'PageToken' => page_token,
126
+ 'Page' => page_number,
127
+ 'PageSize' => page_size,
128
+ })
129
+ response = @version.page(
130
+ 'GET',
131
+ @uri,
132
+ params
133
+ )
134
+ ConnectionPolicyTargetPage.new(@version, response, @solution)
135
+ end
136
+
137
+ ##
138
+ # Retrieve a single page of ConnectionPolicyTargetInstance records from the API.
139
+ # Request is executed immediately.
140
+ # @param [String] target_url API-generated URL for the requested results page
141
+ # @return [Page] Page of ConnectionPolicyTargetInstance
142
+ def get_page(target_url)
143
+ response = @version.domain.request(
144
+ 'GET',
145
+ target_url
146
+ )
147
+ ConnectionPolicyTargetPage.new(@version, response, @solution)
148
+ end
149
+
150
+ ##
151
+ # Provide a user friendly representation
152
+ def to_s
153
+ '#<Twilio.Voice.V1.ConnectionPolicyTargetList>'
154
+ end
155
+ end
156
+
157
+ class ConnectionPolicyTargetPage < Page
158
+ ##
159
+ # Initialize the ConnectionPolicyTargetPage
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 [ConnectionPolicyTargetPage] ConnectionPolicyTargetPage
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 ConnectionPolicyTargetInstance
173
+ # @param [Hash] payload Payload response from the API
174
+ # @return [ConnectionPolicyTargetInstance] ConnectionPolicyTargetInstance
175
+ def get_instance(payload)
176
+ ConnectionPolicyTargetInstance.new(
177
+ @version,
178
+ payload,
179
+ connection_policy_sid: @solution[:connection_policy_sid],
180
+ )
181
+ end
182
+
183
+ ##
184
+ # Provide a user friendly representation
185
+ def to_s
186
+ '<Twilio.Voice.V1.ConnectionPolicyTargetPage>'
187
+ end
188
+ end
189
+
190
+ class ConnectionPolicyTargetContext < InstanceContext
191
+ ##
192
+ # Initialize the ConnectionPolicyTargetContext
193
+ # @param [Version] version Version that contains the resource
194
+ # @param [String] connection_policy_sid The SID of the Connection Policy that owns
195
+ # the Target.
196
+ # @param [String] sid The unique string that we created to identify the Target
197
+ # resource to fetch.
198
+ # @return [ConnectionPolicyTargetContext] ConnectionPolicyTargetContext
199
+ def initialize(version, connection_policy_sid, sid)
200
+ super(version)
201
+
202
+ # Path Solution
203
+ @solution = {connection_policy_sid: connection_policy_sid, sid: sid, }
204
+ @uri = "/ConnectionPolicies/#{@solution[:connection_policy_sid]}/Targets/#{@solution[:sid]}"
205
+ end
206
+
207
+ ##
208
+ # Fetch a ConnectionPolicyTargetInstance
209
+ # @return [ConnectionPolicyTargetInstance] Fetched ConnectionPolicyTargetInstance
210
+ def fetch
211
+ params = Twilio::Values.of({})
212
+
213
+ payload = @version.fetch(
214
+ 'GET',
215
+ @uri,
216
+ params,
217
+ )
218
+
219
+ ConnectionPolicyTargetInstance.new(
220
+ @version,
221
+ payload,
222
+ connection_policy_sid: @solution[:connection_policy_sid],
223
+ sid: @solution[:sid],
224
+ )
225
+ end
226
+
227
+ ##
228
+ # Update the ConnectionPolicyTargetInstance
229
+ # @param [String] friendly_name A descriptive string that you create to describe
230
+ # the resource. It is not unique and can be up to 255 characters long.
231
+ # @param [String] target The SIP address you want Twilio to route your calls to.
232
+ # This must be a `sip:` schema. `sips` is NOT supported.
233
+ # @param [String] priority The relative importance of the target. Can be an
234
+ # integer from 0 to 65535, inclusive. The lowest number represents the most
235
+ # important target.
236
+ # @param [String] weight The value that determines the relative share of the load
237
+ # the Target should receive compared to other Targets with the same priority. Can
238
+ # be an integer from 1 to 65535, inclusive. Targets with higher values receive
239
+ # more load than those with lower ones with the same priority.
240
+ # @param [Boolean] enabled Whether the Target is enabled.
241
+ # @return [ConnectionPolicyTargetInstance] Updated ConnectionPolicyTargetInstance
242
+ def update(friendly_name: :unset, target: :unset, priority: :unset, weight: :unset, enabled: :unset)
243
+ data = Twilio::Values.of({
244
+ 'FriendlyName' => friendly_name,
245
+ 'Target' => target,
246
+ 'Priority' => priority,
247
+ 'Weight' => weight,
248
+ 'Enabled' => enabled,
249
+ })
250
+
251
+ payload = @version.update(
252
+ 'POST',
253
+ @uri,
254
+ data: data,
255
+ )
256
+
257
+ ConnectionPolicyTargetInstance.new(
258
+ @version,
259
+ payload,
260
+ connection_policy_sid: @solution[:connection_policy_sid],
261
+ sid: @solution[:sid],
262
+ )
263
+ end
264
+
265
+ ##
266
+ # Deletes the ConnectionPolicyTargetInstance
267
+ # @return [Boolean] true if delete succeeds, false otherwise
268
+ def delete
269
+ @version.delete('delete', @uri)
270
+ end
271
+
272
+ ##
273
+ # Provide a user friendly representation
274
+ def to_s
275
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
276
+ "#<Twilio.Voice.V1.ConnectionPolicyTargetContext #{context}>"
277
+ end
278
+
279
+ ##
280
+ # Provide a detailed, user friendly representation
281
+ def inspect
282
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
283
+ "#<Twilio.Voice.V1.ConnectionPolicyTargetContext #{context}>"
284
+ end
285
+ end
286
+
287
+ class ConnectionPolicyTargetInstance < InstanceResource
288
+ ##
289
+ # Initialize the ConnectionPolicyTargetInstance
290
+ # @param [Version] version Version that contains the resource
291
+ # @param [Hash] payload payload that contains response from Twilio
292
+ # @param [String] connection_policy_sid The SID of the Connection Policy that owns
293
+ # the Target.
294
+ # @param [String] sid The unique string that we created to identify the Target
295
+ # resource to fetch.
296
+ # @return [ConnectionPolicyTargetInstance] ConnectionPolicyTargetInstance
297
+ def initialize(version, payload, connection_policy_sid: nil, sid: nil)
298
+ super(version)
299
+
300
+ # Marshaled Properties
301
+ @properties = {
302
+ 'account_sid' => payload['account_sid'],
303
+ 'connection_policy_sid' => payload['connection_policy_sid'],
304
+ 'sid' => payload['sid'],
305
+ 'friendly_name' => payload['friendly_name'],
306
+ 'target' => payload['target'],
307
+ 'priority' => payload['priority'].to_i,
308
+ 'weight' => payload['weight'].to_i,
309
+ 'enabled' => payload['enabled'],
310
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
311
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
312
+ 'url' => payload['url'],
313
+ }
314
+
315
+ # Context
316
+ @instance_context = nil
317
+ @params = {'connection_policy_sid' => connection_policy_sid, 'sid' => sid || @properties['sid'], }
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 [ConnectionPolicyTargetContext] ConnectionPolicyTargetContext for this ConnectionPolicyTargetInstance
324
+ def context
325
+ unless @instance_context
326
+ @instance_context = ConnectionPolicyTargetContext.new(
327
+ @version,
328
+ @params['connection_policy_sid'],
329
+ @params['sid'],
330
+ )
331
+ end
332
+ @instance_context
333
+ end
334
+
335
+ ##
336
+ # @return [String] The SID of the Account that created the resource
337
+ def account_sid
338
+ @properties['account_sid']
339
+ end
340
+
341
+ ##
342
+ # @return [String] The SID of the Connection Policy that owns the Target
343
+ def connection_policy_sid
344
+ @properties['connection_policy_sid']
345
+ end
346
+
347
+ ##
348
+ # @return [String] The unique string that identifies the resource
349
+ def sid
350
+ @properties['sid']
351
+ end
352
+
353
+ ##
354
+ # @return [String] The string that you assigned to describe the resource
355
+ def friendly_name
356
+ @properties['friendly_name']
357
+ end
358
+
359
+ ##
360
+ # @return [String] The SIP address you want Twilio to route your calls to
361
+ def target
362
+ @properties['target']
363
+ end
364
+
365
+ ##
366
+ # @return [String] The relative importance of the target
367
+ def priority
368
+ @properties['priority']
369
+ end
370
+
371
+ ##
372
+ # @return [String] The value that determines the relative load the Target should receive compared to others with the same priority
373
+ def weight
374
+ @properties['weight']
375
+ end
376
+
377
+ ##
378
+ # @return [Boolean] Whether the target is enabled
379
+ def enabled
380
+ @properties['enabled']
381
+ end
382
+
383
+ ##
384
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was created
385
+ def date_created
386
+ @properties['date_created']
387
+ end
388
+
389
+ ##
390
+ # @return [Time] The RFC 2822 date and time in GMT when the resource was last updated
391
+ def date_updated
392
+ @properties['date_updated']
393
+ end
394
+
395
+ ##
396
+ # @return [String] The absolute URL of the resource
397
+ def url
398
+ @properties['url']
399
+ end
400
+
401
+ ##
402
+ # Fetch a ConnectionPolicyTargetInstance
403
+ # @return [ConnectionPolicyTargetInstance] Fetched ConnectionPolicyTargetInstance
404
+ def fetch
405
+ context.fetch
406
+ end
407
+
408
+ ##
409
+ # Update the ConnectionPolicyTargetInstance
410
+ # @param [String] friendly_name A descriptive string that you create to describe
411
+ # the resource. It is not unique and can be up to 255 characters long.
412
+ # @param [String] target The SIP address you want Twilio to route your calls to.
413
+ # This must be a `sip:` schema. `sips` is NOT supported.
414
+ # @param [String] priority The relative importance of the target. Can be an
415
+ # integer from 0 to 65535, inclusive. The lowest number represents the most
416
+ # important target.
417
+ # @param [String] weight The value that determines the relative share of the load
418
+ # the Target should receive compared to other Targets with the same priority. Can
419
+ # be an integer from 1 to 65535, inclusive. Targets with higher values receive
420
+ # more load than those with lower ones with the same priority.
421
+ # @param [Boolean] enabled Whether the Target is enabled.
422
+ # @return [ConnectionPolicyTargetInstance] Updated ConnectionPolicyTargetInstance
423
+ def update(friendly_name: :unset, target: :unset, priority: :unset, weight: :unset, enabled: :unset)
424
+ context.update(
425
+ friendly_name: friendly_name,
426
+ target: target,
427
+ priority: priority,
428
+ weight: weight,
429
+ enabled: enabled,
430
+ )
431
+ end
432
+
433
+ ##
434
+ # Deletes the ConnectionPolicyTargetInstance
435
+ # @return [Boolean] true if delete succeeds, false otherwise
436
+ def delete
437
+ context.delete
438
+ end
439
+
440
+ ##
441
+ # Provide a user friendly representation
442
+ def to_s
443
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
444
+ "<Twilio.Voice.V1.ConnectionPolicyTargetInstance #{values}>"
445
+ end
446
+
447
+ ##
448
+ # Provide a detailed, user friendly representation
449
+ def inspect
450
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
451
+ "<Twilio.Voice.V1.ConnectionPolicyTargetInstance #{values}>"
452
+ end
453
+ end
454
+ end
455
+ end
456
+ end
457
+ end
458
+ end