twilio-ruby 5.22.0 → 5.22.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (53) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGES.md +15 -0
  3. data/README.md +2 -2
  4. data/lib/twilio-ruby/rest/client.rb +7 -0
  5. data/lib/twilio-ruby/rest/flex_api/v1/configuration.rb +14 -0
  6. data/lib/twilio-ruby/rest/messaging/v1/session.rb +1 -7
  7. data/lib/twilio-ruby/rest/proxy/v1/service/phone_number.rb +34 -32
  8. data/lib/twilio-ruby/rest/proxy/v1/service/session/interaction.rb +37 -35
  9. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant/message_interaction.rb +45 -38
  10. data/lib/twilio-ruby/rest/proxy/v1/service/session/participant.rb +38 -34
  11. data/lib/twilio-ruby/rest/proxy/v1/service/session.rb +67 -52
  12. data/lib/twilio-ruby/rest/proxy/v1/service/short_code.rb +32 -23
  13. data/lib/twilio-ruby/rest/proxy/v1/service.rb +123 -79
  14. data/lib/twilio-ruby/rest/proxy/v1.rb +2 -1
  15. data/lib/twilio-ruby/rest/proxy.rb +2 -1
  16. data/lib/twilio-ruby/rest/serverless/v1/service/asset/asset_version.rb +366 -0
  17. data/lib/twilio-ruby/rest/serverless/v1/service/asset.rb +384 -0
  18. data/lib/twilio-ruby/rest/serverless/v1/service/build.rb +348 -0
  19. data/lib/twilio-ruby/rest/serverless/v1/service/environment/deployment.rb +358 -0
  20. data/lib/twilio-ruby/rest/serverless/v1/service/environment/variable.rb +398 -0
  21. data/lib/twilio-ruby/rest/serverless/v1/service/environment.rb +417 -0
  22. data/lib/twilio-ruby/rest/serverless/v1/service/function/function_version.rb +366 -0
  23. data/lib/twilio-ruby/rest/serverless/v1/service/function.rb +384 -0
  24. data/lib/twilio-ruby/rest/{verify → serverless}/v1/service.rb +139 -175
  25. data/lib/twilio-ruby/rest/{verify → serverless}/v1.rb +6 -6
  26. data/lib/twilio-ruby/rest/serverless.rb +46 -0
  27. data/lib/twilio-ruby/rest/trunking/v1/trunk/terminating_sip_domain.rb +419 -0
  28. data/lib/twilio-ruby/rest/trunking/v1/trunk.rb +26 -0
  29. data/lib/twilio-ruby/rest/verify/v2/service/verification.rb +46 -38
  30. data/lib/twilio-ruby/rest/verify/v2/service/verification_check.rb +24 -20
  31. data/lib/twilio-ruby/rest/verify/v2/service.rb +59 -57
  32. data/lib/twilio-ruby/rest/verify/v2.rb +2 -1
  33. data/lib/twilio-ruby/rest/verify.rb +2 -8
  34. data/lib/twilio-ruby/version.rb +1 -1
  35. data/spec/integration/flex_api/v1/configuration_spec.rb +15 -0
  36. data/spec/integration/messaging/v1/session/participant_spec.rb +10 -10
  37. data/spec/integration/serverless/v1/service/asset/asset_version_spec.rb +144 -0
  38. data/spec/integration/serverless/v1/service/asset_spec.rb +177 -0
  39. data/spec/integration/serverless/v1/service/build_spec.rb +184 -0
  40. data/spec/integration/serverless/v1/service/environment/deployment_spec.rb +137 -0
  41. data/spec/integration/serverless/v1/service/environment/variable_spec.rb +181 -0
  42. data/spec/integration/serverless/v1/service/environment_spec.rb +143 -0
  43. data/spec/integration/serverless/v1/service/function/function_version_spec.rb +144 -0
  44. data/spec/integration/serverless/v1/service/function_spec.rb +177 -0
  45. data/spec/integration/serverless/v1/service_spec.rb +180 -0
  46. data/spec/integration/trunking/v1/trunk/terminating_sip_domain_spec.rb +231 -0
  47. data/spec/integration/trunking/v1/trunk_spec.rb +12 -6
  48. metadata +34 -12
  49. data/lib/twilio-ruby/rest/verify/v1/service/verification.rb +0 -340
  50. data/lib/twilio-ruby/rest/verify/v1/service/verification_check.rb +0 -209
  51. data/spec/integration/verify/v1/service/verification_check_spec.rb +0 -54
  52. data/spec/integration/verify/v1/service/verification_spec.rb +0 -169
  53. data/spec/integration/verify/v1/service_spec.rb +0 -231
@@ -0,0 +1,398 @@
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 Serverless < Domain
12
+ class V1 < Version
13
+ class ServiceContext < InstanceContext
14
+ class EnvironmentContext < InstanceContext
15
+ ##
16
+ # 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.
17
+ class VariableList < ListResource
18
+ ##
19
+ # Initialize the VariableList
20
+ # @param [Version] version Version that contains the resource
21
+ # @param [String] service_sid The service_sid
22
+ # @param [String] environment_sid The environment_sid
23
+ # @return [VariableList] VariableList
24
+ def initialize(version, service_sid: nil, environment_sid: nil)
25
+ super(version)
26
+
27
+ # Path Solution
28
+ @solution = {service_sid: service_sid, environment_sid: environment_sid}
29
+ @uri = "/Services/#{@solution[:service_sid]}/Environments/#{@solution[:environment_sid]}/Variables"
30
+ end
31
+
32
+ ##
33
+ # Lists VariableInstance records from the API as a list.
34
+ # Unlike stream(), this operation is eager and will load `limit` records into
35
+ # memory before returning.
36
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
37
+ # guarantees to never return more than limit. Default is no limit
38
+ # @param [Integer] page_size Number of records to fetch per request, when
39
+ # not set will use the default value of 50 records. If no page_size is defined
40
+ # but a limit is defined, stream() will attempt to read the limit with the most
41
+ # efficient page size, i.e. min(limit, 1000)
42
+ # @return [Array] Array of up to limit results
43
+ def list(limit: nil, page_size: nil)
44
+ self.stream(limit: limit, page_size: page_size).entries
45
+ end
46
+
47
+ ##
48
+ # Streams VariableInstance records from the API as an Enumerable.
49
+ # This operation lazily loads records as efficiently as possible until the limit
50
+ # is reached.
51
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
52
+ # guarantees to never return more than limit. Default is no limit.
53
+ # @param [Integer] page_size Number of records to fetch per request, when
54
+ # not set will use the default value of 50 records. If no page_size is defined
55
+ # but a limit is defined, stream() will attempt to read the limit with the most
56
+ # efficient page size, i.e. min(limit, 1000)
57
+ # @return [Enumerable] Enumerable that will yield up to limit results
58
+ def stream(limit: nil, page_size: nil)
59
+ limits = @version.read_limits(limit, page_size)
60
+
61
+ page = self.page(page_size: limits[:page_size], )
62
+
63
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
64
+ end
65
+
66
+ ##
67
+ # When passed a block, yields VariableInstance records from the API.
68
+ # This operation lazily loads records as efficiently as possible until the limit
69
+ # is reached.
70
+ def each
71
+ limits = @version.read_limits
72
+
73
+ page = self.page(page_size: limits[:page_size], )
74
+
75
+ @version.stream(page,
76
+ limit: limits[:limit],
77
+ page_limit: limits[:page_limit]).each {|x| yield x}
78
+ end
79
+
80
+ ##
81
+ # Retrieve a single page of VariableInstance records from the API.
82
+ # Request is executed immediately.
83
+ # @param [String] page_token PageToken provided by the API
84
+ # @param [Integer] page_number Page Number, this value is simply for client state
85
+ # @param [Integer] page_size Number of records to return, defaults to 50
86
+ # @return [Page] Page of VariableInstance
87
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
88
+ params = Twilio::Values.of({
89
+ 'PageToken' => page_token,
90
+ 'Page' => page_number,
91
+ 'PageSize' => page_size,
92
+ })
93
+ response = @version.page(
94
+ 'GET',
95
+ @uri,
96
+ params
97
+ )
98
+ VariablePage.new(@version, response, @solution)
99
+ end
100
+
101
+ ##
102
+ # Retrieve a single page of VariableInstance records from the API.
103
+ # Request is executed immediately.
104
+ # @param [String] target_url API-generated URL for the requested results page
105
+ # @return [Page] Page of VariableInstance
106
+ def get_page(target_url)
107
+ response = @version.domain.request(
108
+ 'GET',
109
+ target_url
110
+ )
111
+ VariablePage.new(@version, response, @solution)
112
+ end
113
+
114
+ ##
115
+ # Retrieve a single page of VariableInstance records from the API.
116
+ # Request is executed immediately.
117
+ # @param [String] key The key
118
+ # @param [String] value The value
119
+ # @return [VariableInstance] Newly created VariableInstance
120
+ def create(key: nil, value: nil)
121
+ data = Twilio::Values.of({'Key' => key, 'Value' => value, })
122
+
123
+ payload = @version.create(
124
+ 'POST',
125
+ @uri,
126
+ data: data
127
+ )
128
+
129
+ VariableInstance.new(
130
+ @version,
131
+ payload,
132
+ service_sid: @solution[:service_sid],
133
+ environment_sid: @solution[:environment_sid],
134
+ )
135
+ end
136
+
137
+ ##
138
+ # Provide a user friendly representation
139
+ def to_s
140
+ '#<Twilio.Serverless.V1.VariableList>'
141
+ end
142
+ end
143
+
144
+ ##
145
+ # 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.
146
+ class VariablePage < Page
147
+ ##
148
+ # Initialize the VariablePage
149
+ # @param [Version] version Version that contains the resource
150
+ # @param [Response] response Response from the API
151
+ # @param [Hash] solution Path solution for the resource
152
+ # @return [VariablePage] VariablePage
153
+ def initialize(version, response, solution)
154
+ super(version, response)
155
+
156
+ # Path Solution
157
+ @solution = solution
158
+ end
159
+
160
+ ##
161
+ # Build an instance of VariableInstance
162
+ # @param [Hash] payload Payload response from the API
163
+ # @return [VariableInstance] VariableInstance
164
+ def get_instance(payload)
165
+ VariableInstance.new(
166
+ @version,
167
+ payload,
168
+ service_sid: @solution[:service_sid],
169
+ environment_sid: @solution[:environment_sid],
170
+ )
171
+ end
172
+
173
+ ##
174
+ # Provide a user friendly representation
175
+ def to_s
176
+ '<Twilio.Serverless.V1.VariablePage>'
177
+ end
178
+ end
179
+
180
+ ##
181
+ # 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.
182
+ class VariableContext < InstanceContext
183
+ ##
184
+ # Initialize the VariableContext
185
+ # @param [Version] version Version that contains the resource
186
+ # @param [String] service_sid The service_sid
187
+ # @param [String] environment_sid The environment_sid
188
+ # @param [String] sid The sid
189
+ # @return [VariableContext] VariableContext
190
+ def initialize(version, service_sid, environment_sid, sid)
191
+ super(version)
192
+
193
+ # Path Solution
194
+ @solution = {service_sid: service_sid, environment_sid: environment_sid, sid: sid, }
195
+ @uri = "/Services/#{@solution[:service_sid]}/Environments/#{@solution[:environment_sid]}/Variables/#{@solution[:sid]}"
196
+ end
197
+
198
+ ##
199
+ # Fetch a VariableInstance
200
+ # @return [VariableInstance] Fetched VariableInstance
201
+ def fetch
202
+ params = Twilio::Values.of({})
203
+
204
+ payload = @version.fetch(
205
+ 'GET',
206
+ @uri,
207
+ params,
208
+ )
209
+
210
+ VariableInstance.new(
211
+ @version,
212
+ payload,
213
+ service_sid: @solution[:service_sid],
214
+ environment_sid: @solution[:environment_sid],
215
+ sid: @solution[:sid],
216
+ )
217
+ end
218
+
219
+ ##
220
+ # Update the VariableInstance
221
+ # @param [String] key The key
222
+ # @param [String] value The value
223
+ # @return [VariableInstance] Updated VariableInstance
224
+ def update(key: :unset, value: :unset)
225
+ data = Twilio::Values.of({'Key' => key, 'Value' => value, })
226
+
227
+ payload = @version.update(
228
+ 'POST',
229
+ @uri,
230
+ data: data,
231
+ )
232
+
233
+ VariableInstance.new(
234
+ @version,
235
+ payload,
236
+ service_sid: @solution[:service_sid],
237
+ environment_sid: @solution[:environment_sid],
238
+ sid: @solution[:sid],
239
+ )
240
+ end
241
+
242
+ ##
243
+ # Provide a user friendly representation
244
+ def to_s
245
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
246
+ "#<Twilio.Serverless.V1.VariableContext #{context}>"
247
+ end
248
+
249
+ ##
250
+ # Provide a detailed, user friendly representation
251
+ def inspect
252
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
253
+ "#<Twilio.Serverless.V1.VariableContext #{context}>"
254
+ end
255
+ end
256
+
257
+ ##
258
+ # 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.
259
+ class VariableInstance < InstanceResource
260
+ ##
261
+ # Initialize the VariableInstance
262
+ # @param [Version] version Version that contains the resource
263
+ # @param [Hash] payload payload that contains response from Twilio
264
+ # @param [String] service_sid The service_sid
265
+ # @param [String] environment_sid The environment_sid
266
+ # @param [String] sid The sid
267
+ # @return [VariableInstance] VariableInstance
268
+ def initialize(version, payload, service_sid: nil, environment_sid: nil, sid: nil)
269
+ super(version)
270
+
271
+ # Marshaled Properties
272
+ @properties = {
273
+ 'sid' => payload['sid'],
274
+ 'account_sid' => payload['account_sid'],
275
+ 'service_sid' => payload['service_sid'],
276
+ 'environment_sid' => payload['environment_sid'],
277
+ 'key' => payload['key'],
278
+ 'value' => payload['value'],
279
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
280
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
281
+ 'url' => payload['url'],
282
+ }
283
+
284
+ # Context
285
+ @instance_context = nil
286
+ @params = {
287
+ 'service_sid' => service_sid,
288
+ 'environment_sid' => environment_sid,
289
+ 'sid' => sid || @properties['sid'],
290
+ }
291
+ end
292
+
293
+ ##
294
+ # Generate an instance context for the instance, the context is capable of
295
+ # performing various actions. All instance actions are proxied to the context
296
+ # @return [VariableContext] VariableContext for this VariableInstance
297
+ def context
298
+ unless @instance_context
299
+ @instance_context = VariableContext.new(
300
+ @version,
301
+ @params['service_sid'],
302
+ @params['environment_sid'],
303
+ @params['sid'],
304
+ )
305
+ end
306
+ @instance_context
307
+ end
308
+
309
+ ##
310
+ # @return [String] The sid
311
+ def sid
312
+ @properties['sid']
313
+ end
314
+
315
+ ##
316
+ # @return [String] The account_sid
317
+ def account_sid
318
+ @properties['account_sid']
319
+ end
320
+
321
+ ##
322
+ # @return [String] The service_sid
323
+ def service_sid
324
+ @properties['service_sid']
325
+ end
326
+
327
+ ##
328
+ # @return [String] The environment_sid
329
+ def environment_sid
330
+ @properties['environment_sid']
331
+ end
332
+
333
+ ##
334
+ # @return [String] The key
335
+ def key
336
+ @properties['key']
337
+ end
338
+
339
+ ##
340
+ # @return [String] The value
341
+ def value
342
+ @properties['value']
343
+ end
344
+
345
+ ##
346
+ # @return [Time] The date_created
347
+ def date_created
348
+ @properties['date_created']
349
+ end
350
+
351
+ ##
352
+ # @return [Time] The date_updated
353
+ def date_updated
354
+ @properties['date_updated']
355
+ end
356
+
357
+ ##
358
+ # @return [String] The url
359
+ def url
360
+ @properties['url']
361
+ end
362
+
363
+ ##
364
+ # Fetch a VariableInstance
365
+ # @return [VariableInstance] Fetched VariableInstance
366
+ def fetch
367
+ context.fetch
368
+ end
369
+
370
+ ##
371
+ # Update the VariableInstance
372
+ # @param [String] key The key
373
+ # @param [String] value The value
374
+ # @return [VariableInstance] Updated VariableInstance
375
+ def update(key: :unset, value: :unset)
376
+ context.update(key: key, value: value, )
377
+ end
378
+
379
+ ##
380
+ # Provide a user friendly representation
381
+ def to_s
382
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
383
+ "<Twilio.Serverless.V1.VariableInstance #{values}>"
384
+ end
385
+
386
+ ##
387
+ # Provide a detailed, user friendly representation
388
+ def inspect
389
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
390
+ "<Twilio.Serverless.V1.VariableInstance #{values}>"
391
+ end
392
+ end
393
+ end
394
+ end
395
+ end
396
+ end
397
+ end
398
+ end
@@ -0,0 +1,417 @@
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 Serverless < Domain
12
+ class V1 < Version
13
+ class ServiceContext < InstanceContext
14
+ ##
15
+ # 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.
16
+ class EnvironmentList < ListResource
17
+ ##
18
+ # Initialize the EnvironmentList
19
+ # @param [Version] version Version that contains the resource
20
+ # @param [String] service_sid The service_sid
21
+ # @return [EnvironmentList] EnvironmentList
22
+ def initialize(version, service_sid: nil)
23
+ super(version)
24
+
25
+ # Path Solution
26
+ @solution = {service_sid: service_sid}
27
+ @uri = "/Services/#{@solution[:service_sid]}/Environments"
28
+ end
29
+
30
+ ##
31
+ # Lists EnvironmentInstance records from the API as a list.
32
+ # Unlike stream(), this operation is eager and will load `limit` records into
33
+ # memory before returning.
34
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
35
+ # guarantees to never return more than limit. Default is no limit
36
+ # @param [Integer] page_size Number of records to fetch per request, when
37
+ # not set will use the default value of 50 records. If no page_size is defined
38
+ # but a limit is defined, stream() will attempt to read the limit with the most
39
+ # efficient page size, i.e. min(limit, 1000)
40
+ # @return [Array] Array of up to limit results
41
+ def list(limit: nil, page_size: nil)
42
+ self.stream(limit: limit, page_size: page_size).entries
43
+ end
44
+
45
+ ##
46
+ # Streams EnvironmentInstance records from the API as an Enumerable.
47
+ # This operation lazily loads records as efficiently as possible until the limit
48
+ # is reached.
49
+ # @param [Integer] limit Upper limit for the number of records to return. stream()
50
+ # guarantees to never return more than limit. Default is no limit.
51
+ # @param [Integer] page_size Number of records to fetch per request, when
52
+ # not set will use the default value of 50 records. If no page_size is defined
53
+ # but a limit is defined, stream() will attempt to read the limit with the most
54
+ # efficient page size, i.e. min(limit, 1000)
55
+ # @return [Enumerable] Enumerable that will yield up to limit results
56
+ def stream(limit: nil, page_size: nil)
57
+ limits = @version.read_limits(limit, page_size)
58
+
59
+ page = self.page(page_size: limits[:page_size], )
60
+
61
+ @version.stream(page, limit: limits[:limit], page_limit: limits[:page_limit])
62
+ end
63
+
64
+ ##
65
+ # When passed a block, yields EnvironmentInstance records from the API.
66
+ # This operation lazily loads records as efficiently as possible until the limit
67
+ # is reached.
68
+ def each
69
+ limits = @version.read_limits
70
+
71
+ page = self.page(page_size: limits[:page_size], )
72
+
73
+ @version.stream(page,
74
+ limit: limits[:limit],
75
+ page_limit: limits[:page_limit]).each {|x| yield x}
76
+ end
77
+
78
+ ##
79
+ # Retrieve a single page of EnvironmentInstance records from the API.
80
+ # Request is executed immediately.
81
+ # @param [String] page_token PageToken provided by the API
82
+ # @param [Integer] page_number Page Number, this value is simply for client state
83
+ # @param [Integer] page_size Number of records to return, defaults to 50
84
+ # @return [Page] Page of EnvironmentInstance
85
+ def page(page_token: :unset, page_number: :unset, page_size: :unset)
86
+ params = Twilio::Values.of({
87
+ 'PageToken' => page_token,
88
+ 'Page' => page_number,
89
+ 'PageSize' => page_size,
90
+ })
91
+ response = @version.page(
92
+ 'GET',
93
+ @uri,
94
+ params
95
+ )
96
+ EnvironmentPage.new(@version, response, @solution)
97
+ end
98
+
99
+ ##
100
+ # Retrieve a single page of EnvironmentInstance records from the API.
101
+ # Request is executed immediately.
102
+ # @param [String] target_url API-generated URL for the requested results page
103
+ # @return [Page] Page of EnvironmentInstance
104
+ def get_page(target_url)
105
+ response = @version.domain.request(
106
+ 'GET',
107
+ target_url
108
+ )
109
+ EnvironmentPage.new(@version, response, @solution)
110
+ end
111
+
112
+ ##
113
+ # Retrieve a single page of EnvironmentInstance records from the API.
114
+ # Request is executed immediately.
115
+ # @param [String] unique_name The unique_name
116
+ # @param [String] domain_suffix The domain_suffix
117
+ # @return [EnvironmentInstance] Newly created EnvironmentInstance
118
+ def create(unique_name: nil, domain_suffix: :unset)
119
+ data = Twilio::Values.of({'UniqueName' => unique_name, 'DomainSuffix' => domain_suffix, })
120
+
121
+ payload = @version.create(
122
+ 'POST',
123
+ @uri,
124
+ data: data
125
+ )
126
+
127
+ EnvironmentInstance.new(@version, payload, service_sid: @solution[:service_sid], )
128
+ end
129
+
130
+ ##
131
+ # Provide a user friendly representation
132
+ def to_s
133
+ '#<Twilio.Serverless.V1.EnvironmentList>'
134
+ end
135
+ end
136
+
137
+ ##
138
+ # 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.
139
+ class EnvironmentPage < Page
140
+ ##
141
+ # Initialize the EnvironmentPage
142
+ # @param [Version] version Version that contains the resource
143
+ # @param [Response] response Response from the API
144
+ # @param [Hash] solution Path solution for the resource
145
+ # @return [EnvironmentPage] EnvironmentPage
146
+ def initialize(version, response, solution)
147
+ super(version, response)
148
+
149
+ # Path Solution
150
+ @solution = solution
151
+ end
152
+
153
+ ##
154
+ # Build an instance of EnvironmentInstance
155
+ # @param [Hash] payload Payload response from the API
156
+ # @return [EnvironmentInstance] EnvironmentInstance
157
+ def get_instance(payload)
158
+ EnvironmentInstance.new(@version, payload, service_sid: @solution[:service_sid], )
159
+ end
160
+
161
+ ##
162
+ # Provide a user friendly representation
163
+ def to_s
164
+ '<Twilio.Serverless.V1.EnvironmentPage>'
165
+ end
166
+ end
167
+
168
+ ##
169
+ # 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.
170
+ class EnvironmentContext < InstanceContext
171
+ ##
172
+ # Initialize the EnvironmentContext
173
+ # @param [Version] version Version that contains the resource
174
+ # @param [String] service_sid The service_sid
175
+ # @param [String] sid The sid
176
+ # @return [EnvironmentContext] EnvironmentContext
177
+ def initialize(version, service_sid, sid)
178
+ super(version)
179
+
180
+ # Path Solution
181
+ @solution = {service_sid: service_sid, sid: sid, }
182
+ @uri = "/Services/#{@solution[:service_sid]}/Environments/#{@solution[:sid]}"
183
+
184
+ # Dependents
185
+ @variables = nil
186
+ @deployments = nil
187
+ end
188
+
189
+ ##
190
+ # Fetch a EnvironmentInstance
191
+ # @return [EnvironmentInstance] Fetched EnvironmentInstance
192
+ def fetch
193
+ params = Twilio::Values.of({})
194
+
195
+ payload = @version.fetch(
196
+ 'GET',
197
+ @uri,
198
+ params,
199
+ )
200
+
201
+ EnvironmentInstance.new(
202
+ @version,
203
+ payload,
204
+ service_sid: @solution[:service_sid],
205
+ sid: @solution[:sid],
206
+ )
207
+ end
208
+
209
+ ##
210
+ # Access the variables
211
+ # @return [VariableList]
212
+ # @return [VariableContext] if sid was passed.
213
+ def variables(sid=:unset)
214
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
215
+
216
+ if sid != :unset
217
+ return VariableContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
218
+ end
219
+
220
+ unless @variables
221
+ @variables = VariableList.new(
222
+ @version,
223
+ service_sid: @solution[:service_sid],
224
+ environment_sid: @solution[:sid],
225
+ )
226
+ end
227
+
228
+ @variables
229
+ end
230
+
231
+ ##
232
+ # Access the deployments
233
+ # @return [DeploymentList]
234
+ # @return [DeploymentContext] if sid was passed.
235
+ def deployments(sid=:unset)
236
+ raise ArgumentError, 'sid cannot be nil' if sid.nil?
237
+
238
+ if sid != :unset
239
+ return DeploymentContext.new(@version, @solution[:service_sid], @solution[:sid], sid, )
240
+ end
241
+
242
+ unless @deployments
243
+ @deployments = DeploymentList.new(
244
+ @version,
245
+ service_sid: @solution[:service_sid],
246
+ environment_sid: @solution[:sid],
247
+ )
248
+ end
249
+
250
+ @deployments
251
+ end
252
+
253
+ ##
254
+ # Provide a user friendly representation
255
+ def to_s
256
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
257
+ "#<Twilio.Serverless.V1.EnvironmentContext #{context}>"
258
+ end
259
+
260
+ ##
261
+ # Provide a detailed, user friendly representation
262
+ def inspect
263
+ context = @solution.map {|k, v| "#{k}: #{v}"}.join(',')
264
+ "#<Twilio.Serverless.V1.EnvironmentContext #{context}>"
265
+ end
266
+ end
267
+
268
+ ##
269
+ # 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.
270
+ class EnvironmentInstance < InstanceResource
271
+ ##
272
+ # Initialize the EnvironmentInstance
273
+ # @param [Version] version Version that contains the resource
274
+ # @param [Hash] payload payload that contains response from Twilio
275
+ # @param [String] service_sid The service_sid
276
+ # @param [String] sid The sid
277
+ # @return [EnvironmentInstance] EnvironmentInstance
278
+ def initialize(version, payload, service_sid: nil, sid: nil)
279
+ super(version)
280
+
281
+ # Marshaled Properties
282
+ @properties = {
283
+ 'sid' => payload['sid'],
284
+ 'account_sid' => payload['account_sid'],
285
+ 'service_sid' => payload['service_sid'],
286
+ 'build_sid' => payload['build_sid'],
287
+ 'unique_name' => payload['unique_name'],
288
+ 'domain_suffix' => payload['domain_suffix'],
289
+ 'domain_name' => payload['domain_name'],
290
+ 'date_created' => Twilio.deserialize_iso8601_datetime(payload['date_created']),
291
+ 'date_updated' => Twilio.deserialize_iso8601_datetime(payload['date_updated']),
292
+ 'url' => payload['url'],
293
+ 'links' => payload['links'],
294
+ }
295
+
296
+ # Context
297
+ @instance_context = nil
298
+ @params = {'service_sid' => service_sid, 'sid' => sid || @properties['sid'], }
299
+ end
300
+
301
+ ##
302
+ # Generate an instance context for the instance, the context is capable of
303
+ # performing various actions. All instance actions are proxied to the context
304
+ # @return [EnvironmentContext] EnvironmentContext for this EnvironmentInstance
305
+ def context
306
+ unless @instance_context
307
+ @instance_context = EnvironmentContext.new(@version, @params['service_sid'], @params['sid'], )
308
+ end
309
+ @instance_context
310
+ end
311
+
312
+ ##
313
+ # @return [String] The sid
314
+ def sid
315
+ @properties['sid']
316
+ end
317
+
318
+ ##
319
+ # @return [String] The account_sid
320
+ def account_sid
321
+ @properties['account_sid']
322
+ end
323
+
324
+ ##
325
+ # @return [String] The service_sid
326
+ def service_sid
327
+ @properties['service_sid']
328
+ end
329
+
330
+ ##
331
+ # @return [String] The build_sid
332
+ def build_sid
333
+ @properties['build_sid']
334
+ end
335
+
336
+ ##
337
+ # @return [String] The unique_name
338
+ def unique_name
339
+ @properties['unique_name']
340
+ end
341
+
342
+ ##
343
+ # @return [String] The domain_suffix
344
+ def domain_suffix
345
+ @properties['domain_suffix']
346
+ end
347
+
348
+ ##
349
+ # @return [String] The domain_name
350
+ def domain_name
351
+ @properties['domain_name']
352
+ end
353
+
354
+ ##
355
+ # @return [Time] The date_created
356
+ def date_created
357
+ @properties['date_created']
358
+ end
359
+
360
+ ##
361
+ # @return [Time] The date_updated
362
+ def date_updated
363
+ @properties['date_updated']
364
+ end
365
+
366
+ ##
367
+ # @return [String] The url
368
+ def url
369
+ @properties['url']
370
+ end
371
+
372
+ ##
373
+ # @return [String] The links
374
+ def links
375
+ @properties['links']
376
+ end
377
+
378
+ ##
379
+ # Fetch a EnvironmentInstance
380
+ # @return [EnvironmentInstance] Fetched EnvironmentInstance
381
+ def fetch
382
+ context.fetch
383
+ end
384
+
385
+ ##
386
+ # Access the variables
387
+ # @return [variables] variables
388
+ def variables
389
+ context.variables
390
+ end
391
+
392
+ ##
393
+ # Access the deployments
394
+ # @return [deployments] deployments
395
+ def deployments
396
+ context.deployments
397
+ end
398
+
399
+ ##
400
+ # Provide a user friendly representation
401
+ def to_s
402
+ values = @params.map{|k, v| "#{k}: #{v}"}.join(" ")
403
+ "<Twilio.Serverless.V1.EnvironmentInstance #{values}>"
404
+ end
405
+
406
+ ##
407
+ # Provide a detailed, user friendly representation
408
+ def inspect
409
+ values = @properties.map{|k, v| "#{k}: #{v}"}.join(" ")
410
+ "<Twilio.Serverless.V1.EnvironmentInstance #{values}>"
411
+ end
412
+ end
413
+ end
414
+ end
415
+ end
416
+ end
417
+ end