ngrok-api 0.9.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (100) hide show
  1. checksums.yaml +7 -0
  2. data/.github/workflows/ci.yml +21 -0
  3. data/.gitignore +13 -0
  4. data/.rubocop.yml +28 -0
  5. data/.rubocop_airbnb.yml +2 -0
  6. data/.simplecov +1 -0
  7. data/Gemfile +33 -0
  8. data/Guardfile +16 -0
  9. data/README.md +61 -0
  10. data/Rakefile +7 -0
  11. data/doc/NgrokAPI/Client.html +542 -0
  12. data/doc/NgrokAPI/Error.html +305 -0
  13. data/doc/NgrokAPI/Errors/NotFoundError.html +309 -0
  14. data/doc/NgrokAPI/Errors.html +115 -0
  15. data/doc/NgrokAPI/HttpClient.html +1104 -0
  16. data/doc/NgrokAPI/Models/ApiKey.html +1138 -0
  17. data/doc/NgrokAPI/Models/EndpointConfiguration.html +1366 -0
  18. data/doc/NgrokAPI/Models/Listable.html +934 -0
  19. data/doc/NgrokAPI/Models/ReservedDomain.html +2498 -0
  20. data/doc/NgrokAPI/Models/TlsCertificate.html +1064 -0
  21. data/doc/NgrokAPI/Models.html +117 -0
  22. data/doc/NgrokAPI/PagedIterator.html +631 -0
  23. data/doc/NgrokAPI/Services/ApiKeysClient.html +1333 -0
  24. data/doc/NgrokAPI/Services/EndpointConfigurationsClient.html +2201 -0
  25. data/doc/NgrokAPI/Services/ReservedDomainsClient.html +2541 -0
  26. data/doc/NgrokAPI/Services/TlsCertificatesClient.html +1417 -0
  27. data/doc/NgrokAPI/Services.html +117 -0
  28. data/doc/NgrokAPI.html +157 -0
  29. data/doc/_index.html +309 -0
  30. data/doc/class_list.html +51 -0
  31. data/doc/css/common.css +1 -0
  32. data/doc/css/full_list.css +58 -0
  33. data/doc/css/style.css +497 -0
  34. data/doc/file.README.html +126 -0
  35. data/doc/file_list.html +56 -0
  36. data/doc/frames.html +17 -0
  37. data/doc/index.html +126 -0
  38. data/doc/js/app.js +314 -0
  39. data/doc/js/full_list.js +216 -0
  40. data/doc/js/jquery.js +4 -0
  41. data/doc/method_list.html +1227 -0
  42. data/doc/top-level-namespace.html +110 -0
  43. data/docs/NgrokAPI/Client.html +542 -0
  44. data/docs/NgrokAPI/Error.html +305 -0
  45. data/docs/NgrokAPI/Errors/NotFoundError.html +309 -0
  46. data/docs/NgrokAPI/Errors.html +115 -0
  47. data/docs/NgrokAPI/HttpClient.html +1104 -0
  48. data/docs/NgrokAPI/Models/ApiKey.html +1138 -0
  49. data/docs/NgrokAPI/Models/EndpointConfiguration.html +1366 -0
  50. data/docs/NgrokAPI/Models/Listable.html +934 -0
  51. data/docs/NgrokAPI/Models/ReservedDomain.html +2498 -0
  52. data/docs/NgrokAPI/Models/TlsCertificate.html +1064 -0
  53. data/docs/NgrokAPI/Models.html +117 -0
  54. data/docs/NgrokAPI/PagedIterator.html +631 -0
  55. data/docs/NgrokAPI/Services/ApiKeysClient.html +1333 -0
  56. data/docs/NgrokAPI/Services/EndpointConfigurationsClient.html +2201 -0
  57. data/docs/NgrokAPI/Services/ReservedDomainsClient.html +2541 -0
  58. data/docs/NgrokAPI/Services/TlsCertificatesClient.html +1417 -0
  59. data/docs/NgrokAPI/Services.html +117 -0
  60. data/docs/NgrokAPI.html +157 -0
  61. data/docs/_index.html +309 -0
  62. data/docs/class_list.html +51 -0
  63. data/docs/css/common.css +1 -0
  64. data/docs/css/full_list.css +58 -0
  65. data/docs/css/style.css +497 -0
  66. data/docs/file.README.html +126 -0
  67. data/docs/file_list.html +56 -0
  68. data/docs/frames.html +17 -0
  69. data/docs/index.html +126 -0
  70. data/docs/js/app.js +314 -0
  71. data/docs/js/full_list.js +216 -0
  72. data/docs/js/jquery.js +4 -0
  73. data/docs/method_list.html +1227 -0
  74. data/docs/top-level-namespace.html +110 -0
  75. data/lib/ngrokapi/client.rb +49 -0
  76. data/lib/ngrokapi/error.rb +14 -0
  77. data/lib/ngrokapi/errors/not_found_error.rb +16 -0
  78. data/lib/ngrokapi/http_client.rb +132 -0
  79. data/lib/ngrokapi/models/api_key.rb +64 -0
  80. data/lib/ngrokapi/models/endpoint_configuration.rb +119 -0
  81. data/lib/ngrokapi/models/listable.rb +42 -0
  82. data/lib/ngrokapi/models/reserved_domain.rb +211 -0
  83. data/lib/ngrokapi/models/tls_certificate.rb +62 -0
  84. data/lib/ngrokapi/paged_iterator.rb +40 -0
  85. data/lib/ngrokapi/services/api_keys_client.rb +144 -0
  86. data/lib/ngrokapi/services/endpoint_configurations_client.rb +313 -0
  87. data/lib/ngrokapi/services/reserved_domains_client.rb +313 -0
  88. data/lib/ngrokapi/services/tls_certificates_client.rb +161 -0
  89. data/lib/ngrokapi/version.rb +7 -0
  90. data/lib/ngrokapi.rb +13 -0
  91. data/ngrok-api.gemspec +27 -0
  92. data/spec/ngrokapi/client_spec.rb +33 -0
  93. data/spec/ngrokapi/http_client_spec.rb +75 -0
  94. data/spec/ngrokapi/models/api_key_spec.rb +43 -0
  95. data/spec/ngrokapi/models/listable_spec.rb +43 -0
  96. data/spec/ngrokapi/models/reserved_domain_spec.rb +100 -0
  97. data/spec/ngrokapi/paged_iterator_spec.rb +84 -0
  98. data/spec/ngrokapi/services/api_keys_client_spec.rb +127 -0
  99. data/spec/spec_helper.rb +80 -0
  100. metadata +144 -0
@@ -0,0 +1,313 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NgrokAPI
4
+ module Services
5
+ ##
6
+ # A client for interacting with the endpoint_configuration API
7
+ #
8
+ # https://ngrok.com/docs/api#api-endpoint-configurations
9
+ class EndpointConfigurationsClient
10
+ # The List Property from the resulting API for list calls
11
+ LIST_PROPERTY = 'endpoint_configurations'
12
+ # The API path for endpoint configurations
13
+ PATH = '/endpoint_configurations'
14
+
15
+ attr_reader :client
16
+
17
+ def initialize(client:)
18
+ @client = client
19
+ end
20
+
21
+ # rubocop:disable LineLength
22
+
23
+ ##
24
+ # Create a new endpoint configuration
25
+ #
26
+ # @param [string] description human-readable description of what this endpoint configuration will be do when applied or what traffic it will be applied to. Optional, max 255 bytes
27
+ # @param [string] metadata arbitrary user-defined machine-readable data of this endpoint configuration. Optional, max 4096 bytes.
28
+ # @param [string] type they type of traffic this endpoint configuration can be applied to. one of: ``http``, ``https``, ``tcp``
29
+ # @param [string] circuit_breaker circuit breaker module configuration
30
+ # @param [string] compression compression module configuration
31
+ # @param [string] request_headers request headers module configuration
32
+ # @param [string] response_headers response headers module configuration
33
+ # @param [string] ip_policy ip policy module configuration
34
+ # @param [string] mutual_tls mutual TLS module configuration
35
+ # @param [string] tls_termination TLS termination module configuration
36
+ # @param [string] webhook_validation webhook validation module configuration
37
+ # @param [string] oauth oauth module configuration
38
+ # @param [string] logging logging module configuration
39
+ # @param [string] saml saml module configuration
40
+ # @param [string] oidc oidc module configuration
41
+ # @return [NgrokAPI::Models::EndpointConfiguration] result from create request
42
+ #
43
+ # https://ngrok.com/docs/api#api-endpoint-configurations-create
44
+ def create(
45
+ description: '',
46
+ metadata: '',
47
+ type: '',
48
+ circuit_breaker: nil,
49
+ compression: nil,
50
+ request_headers: nil,
51
+ response_headers: nil,
52
+ ip_policy: nil,
53
+ mutual_tls: nil,
54
+ tls_termination: nil,
55
+ webhook_validation: nil,
56
+ oauth: nil,
57
+ logging: nil,
58
+ saml: nil,
59
+ oidc: nil
60
+ )
61
+ data = {
62
+ type: type,
63
+ description: description,
64
+ metadata: metadata,
65
+ circuit_breaker: circuit_breaker,
66
+ compression: compression,
67
+ request_headers: request_headers,
68
+ response_headers: response_headers,
69
+ ip_policy: ip_policy,
70
+ mutual_tls: mutual_tls,
71
+ tls_termination: tls_termination,
72
+ webhook_validation: webhook_validation,
73
+ oauth: oauth,
74
+ logging: logging,
75
+ saml: saml,
76
+ oidc: oidc,
77
+ }
78
+ result = @client.post(PATH, data: data)
79
+ NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result)
80
+ end
81
+ # rubocop:enable LineLength
82
+
83
+ ##
84
+ # Delete an endpoint configuration.
85
+ # This operation will fail if the endpoint configuration is still referenced by
86
+ # any reserved domain or reserved address.
87
+ #
88
+ # @param [string] id a resource identifier
89
+ # @return [nil] result from delete request
90
+ #
91
+ # https://ngrok.com/docs/api#api-endpoint-configurations-delete
92
+ def delete(id: nil)
93
+ @client.delete("#{PATH}/#{id}")
94
+ end
95
+
96
+ ##
97
+ # Delete an endpoint configuration. Throw an exception if 404.
98
+ # This operation will fail if the endpoint configuration is still referenced by
99
+ # any reserved domain or reserved address.
100
+ #
101
+ # @param [string] id a resource identifier
102
+ # @return [nil] result from delete request
103
+ #
104
+ # https://ngrok.com/docs/api#api-endpoint-configurations-delete
105
+ def delete!(id: nil)
106
+ @client.delete("#{PATH}/#{id}", danger: true)
107
+ end
108
+
109
+ ##
110
+ # Returns detailed information about an endpoint configuration by ID.
111
+ #
112
+ # @param [string] id a resource identifier
113
+ # @return [NgrokAPI::Models::EndpointConfiguration] result from get request
114
+ #
115
+ # https://ngrok.com/docs/api#api-endpoint-configurations-get
116
+ def get(id: nil)
117
+ result = @client.get("#{PATH}/#{id}")
118
+ NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result)
119
+ end
120
+
121
+ ##
122
+ # Returns detailed information about an endpoint configuration by ID. Throw an execption if 404.
123
+ #
124
+ # @param [string] id a resource identifier
125
+ # @return [NgrokAPI::Models::EndpointConfiguration] result from get request
126
+ #
127
+ # https://ngrok.com/docs/api#api-endpoint-configurations-get
128
+ def get!(id: nil)
129
+ result = @client.get("#{PATH}/#{id}", danger: true)
130
+ NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result)
131
+ end
132
+
133
+ ##
134
+ # Returns a list of all endpoint configurations on this account.
135
+ #
136
+ # @param [string] before_id
137
+ # @param [integer] limit
138
+ # @param [string] url optional and mutually exclusive from before_id and limit
139
+ # @return [NgrokAPI::Models::Listable] the result listable
140
+ #
141
+ # https://ngrok.com/docs/api#api-endpoint-configurations-list
142
+ def list(before_id: nil, limit: nil, url: nil)
143
+ result = @client.list(before_id: before_id, limit: limit, url: url, path: PATH)
144
+ NgrokAPI::Models::Listable.new(
145
+ client: self,
146
+ result: result,
147
+ list_property: LIST_PROPERTY,
148
+ klass: NgrokAPI::Models::EndpointConfiguration
149
+ )
150
+ end
151
+
152
+ # rubocop:disable LineLength
153
+
154
+ ##
155
+ # Updates an endpoint configuration. If a module is not specified in the update, it will not be modified.
156
+ # However, each module configuration that is specified will completely replace the existing value.
157
+ # There is no way to delete an existing module via this API, instead use the delete module API.
158
+ #
159
+ # @param [string] id unique identifier of this endpoint configuration
160
+ # @param [string] description human-readable description of what this endpoint configuration will be do when applied or what traffic it will be applied to. Optional, max 255 bytes
161
+ # @param [string] metadata arbitrary user-defined machine-readable data of this endpoint configuration. Optional, max 4096 bytes.
162
+ # @param [string] circuit_breaker circuit breaker module configuration
163
+ # @param [string] compression compression module configuration
164
+ # @param [string] request_headers request headers module configuration
165
+ # @param [string] response_headers response headers module configuration
166
+ # @param [string] ip_policy ip policy module configuration
167
+ # @param [string] mutual_tls mutual TLS module configuration
168
+ # @param [string] tls_termination TLS termination module configuration
169
+ # @param [string] webhook_validation webhook validation module configuration
170
+ # @param [string] oauth oauth module configuration
171
+ # @param [string] logging logging module configuration
172
+ # @param [string] saml saml module configuration
173
+ # @param [string] oidc oidc module configuration
174
+ # @return [NgrokAPI::Models::EndpointConfiguration] result from update request
175
+ #
176
+ # https://ngrok.com/docs/api#api-endpoint-configurations-update
177
+ def update(
178
+ id: nil,
179
+ description: nil,
180
+ metadata: nil,
181
+ circuit_breaker: nil,
182
+ compression: nil,
183
+ request_headers: nil,
184
+ response_headers: nil,
185
+ ip_policy: nil,
186
+ mutual_tls: nil,
187
+ tls_termination: nil,
188
+ webhook_validation: nil,
189
+ oauth: nil,
190
+ logging: nil,
191
+ saml: nil,
192
+ oidc: nil
193
+ )
194
+ data = build_data(
195
+ description: description,
196
+ metadata: metadata,
197
+ circuit_breaker: circuit_breaker,
198
+ compression: compression,
199
+ request_headers: request_headers,
200
+ response_headers: response_headers,
201
+ ip_policy: ip_policy,
202
+ mutual_tls: mutual_tls,
203
+ tls_termination: tls_termination,
204
+ webhook_validation: webhook_validation,
205
+ oauth: oauth,
206
+ logging: logging,
207
+ saml: saml,
208
+ oidc: oidc
209
+ )
210
+ result = @client.patch("#{PATH}/#{id}", data: data)
211
+ NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result)
212
+ end
213
+
214
+ ##
215
+ # Updates an endpoint configuration. If a module is not specified in the update, it will not be modified.
216
+ # However, each module configuration that is specified will completely replace the existing value.
217
+ # There is no way to delete an existing module via this API, instead use the delete module API.
218
+ # Throw an exception if 404.
219
+ #
220
+ # @param [string] id unique identifier of this endpoint configuration
221
+ # @param [string] description human-readable description of what this endpoint configuration will be do when applied or what traffic it will be applied to. Optional, max 255 bytes
222
+ # @param [string] metadata arbitrary user-defined machine-readable data of this endpoint configuration. Optional, max 4096 bytes.
223
+ # @param [string] circuit_breaker circuit breaker module configuration
224
+ # @param [string] compression compression module configuration
225
+ # @param [string] request_headers request headers module configuration
226
+ # @param [string] response_headers response headers module configuration
227
+ # @param [string] ip_policy ip policy module configuration
228
+ # @param [string] mutual_tls mutual TLS module configuration
229
+ # @param [string] tls_termination TLS termination module configuration
230
+ # @param [string] webhook_validation webhook validation module configuration
231
+ # @param [string] oauth oauth module configuration
232
+ # @param [string] logging logging module configuration
233
+ # @param [string] saml saml module configuration
234
+ # @param [string] oidc oidc module configuration
235
+ # @return [NgrokAPI::Models::EndpointConfiguration] result from update request
236
+ #
237
+ # https://ngrok.com/docs/api#api-endpoint-configurations-update
238
+ def update!(
239
+ id: nil,
240
+ description: nil,
241
+ metadata: nil,
242
+ circuit_breaker: nil,
243
+ compression: nil,
244
+ request_headers: nil,
245
+ response_headers: nil,
246
+ ip_policy: nil,
247
+ mutual_tls: nil,
248
+ tls_termination: nil,
249
+ webhook_validation: nil,
250
+ oauth: nil,
251
+ logging: nil,
252
+ saml: nil,
253
+ oidc: nil
254
+ )
255
+ data = build_data(
256
+ description: description,
257
+ metadata: metadata,
258
+ circuit_breaker: circuit_breaker,
259
+ compression: compression,
260
+ request_headers: request_headers,
261
+ response_headers: response_headers,
262
+ ip_policy: ip_policy,
263
+ mutual_tls: mutual_tls,
264
+ tls_termination: tls_termination,
265
+ webhook_validation: webhook_validation,
266
+ oauth: oauth,
267
+ logging: logging,
268
+ saml: saml,
269
+ oidc: oidc
270
+ )
271
+ result = @client.patch("#{PATH}/#{id}", danger: true, data: data)
272
+ NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result)
273
+ end
274
+ # rubocop:enable LineLength
275
+
276
+ private
277
+
278
+ def build_data(
279
+ description: nil,
280
+ metadata: nil,
281
+ circuit_breaker: nil,
282
+ compression: nil,
283
+ request_headers: nil,
284
+ response_headers: nil,
285
+ ip_policy: nil,
286
+ mutual_tls: nil,
287
+ tls_termination: nil,
288
+ webhook_validation: nil,
289
+ oauth: nil,
290
+ logging: nil,
291
+ saml: nil,
292
+ oidc: nil
293
+ )
294
+ data = {}
295
+ data[:description] = description if description
296
+ data[:metadata] = metadata if metadata
297
+ data[:circuit_breaker] = circuit_breaker if circuit_breaker
298
+ data[:compression] = compression if compression
299
+ data[:request_headers] = request_headers if request_headers
300
+ data[:response_headers] = response_headers if response_headers
301
+ data[:ip_policy] = ip_policy if ip_policy
302
+ data[:mutual_tls] = mutual_tls if mutual_tls
303
+ data[:tls_termination] = tls_termination if tls_termination
304
+ data[:webhook_validation] = webhook_validation if webhook_validation
305
+ data[:oauth] = oauth if oauth
306
+ data[:logging] = logging if logging
307
+ data[:saml] = saml if saml
308
+ data[:oidc] = oidc if oidc
309
+ data
310
+ end
311
+ end
312
+ end
313
+ end
@@ -0,0 +1,313 @@
1
+ # frozen_string_literal: true
2
+
3
+ module NgrokAPI
4
+ module Services
5
+ ##
6
+ # A client for interacting with the reserved_domains API
7
+ #
8
+ # https://ngrok.com/docs/api#api-reserved-domains
9
+ class ReservedDomainsClient
10
+ # The List Property from the resulting API for list calls
11
+ LIST_PROPERTY = 'reserved_domains'
12
+ # The API path for reserved domains
13
+ PATH = '/reserved_domains'
14
+
15
+ attr_reader :client
16
+
17
+ def initialize(client:)
18
+ @client = client
19
+ end
20
+
21
+ # rubocop:disable LineLength
22
+
23
+ ##
24
+ # Create a new reserved domain.
25
+ #
26
+ # @param [string] name the domain name to reserve. It may be a full domain name like app.example.com. If the name does not contain a '.' it will reserve that subdomain on ngrok.io.
27
+ # @param [string] region reserve the domain in this geographic ngrok datacenter. Optional, default is us. (au, eu, ap, us, jp, in, sa)
28
+ # @param [string] description human-readable description of what this reserved domain will be used for
29
+ # @param [string] metadata arbitrary user-defined machine-readable data of this reserved domain. Optional, max 4096 bytes.
30
+ # @param [string] http_endpoint_configuration_id ID of an endpoint configuration of type http that will be used to handle inbound http traffic to this domain
31
+ # @param [string] https_endpoint_configuration_id ID of an endpoint configuration of type https that will be used to handle inbound https traffic to this domain
32
+ # @param [string] certificate_id ID of a user-uploaded TLS certificate to use for connections to targeting this domain. Optional, mutually exclusive with ``certificate_management_policy``.
33
+ # @param [string] certificate_management_policy configuration for automatic management of TLS certificates for this domain, or null if automatic management is disabled. Optional, mutually exclusive with ``certificate_id``.
34
+ # @return [NgrokAPI::Models::ReservedDomain] result from create request
35
+ #
36
+ # https://ngrok.com/docs/api#api-reserved-domains-create
37
+ def create(
38
+ name: '',
39
+ region: '',
40
+ description: '',
41
+ metadata: '',
42
+ http_endpoint_configuration_id: '',
43
+ https_endpoint_configuration_id: '',
44
+ certificate_id: nil,
45
+ certificate_management_policy: nil
46
+ )
47
+ data = {
48
+ name: name,
49
+ region: region,
50
+ description: description,
51
+ metadata: metadata,
52
+ http_endpoint_configuration_id: http_endpoint_configuration_id,
53
+ https_endpoint_configuration_id: https_endpoint_configuration_id,
54
+ certificate_id: certificate_id,
55
+ certificate_management_policy: certificate_management_policy,
56
+ }
57
+ result = @client.post(PATH, data: data)
58
+ NgrokAPI::Models::ReservedDomain.new(client: self, result: result)
59
+ end
60
+ # rubocop:enable LineLength
61
+
62
+ ##
63
+ # Delete a reserved domain.
64
+ #
65
+ # @param [string] id a resource identifier
66
+ # @return [nil] result from delete request
67
+ #
68
+ # https://ngrok.com/docs/api#api-reserved-domains-delete
69
+ def delete(id: nil)
70
+ @client.delete("#{PATH}/#{id}")
71
+ end
72
+
73
+ ##
74
+ # Delete a reserved domain. Throw an exception if 404.
75
+ #
76
+ # @param [string] id a resource identifier
77
+ # @return [nil] result from delete request
78
+ #
79
+ # https://ngrok.com/docs/api#api-reserved-domains-delete
80
+ def delete!(id: nil)
81
+ @client.delete("#{PATH}/#{id}", danger: true)
82
+ end
83
+
84
+ ##
85
+ # Get the details of a reserved domain.
86
+ #
87
+ # @param [string] id a resource identifier
88
+ # @return [NgrokAPI::Models::ReservedDomain] result from get request
89
+ #
90
+ # https://ngrok.com/docs/api#api-reserved-domains-get
91
+ def get(id: nil)
92
+ result = @client.get("#{PATH}/#{id}")
93
+ NgrokAPI::Models::ReservedDomain.new(client: self, result: result)
94
+ end
95
+
96
+ ##
97
+ # Get the details of a reserved domain. Throw an exception if 404.
98
+ #
99
+ # @param [string] id a resource identifier
100
+ # @return [NgrokAPI::Models::ReservedDomain] result from get request
101
+ #
102
+ # https://ngrok.com/docs/api#api-reserved-domains-get
103
+ def get!(id: nil)
104
+ result = @client.get!("#{PATH}/#{id}")
105
+ NgrokAPI::Models::ReservedDomain.new(client: self, result: result)
106
+ end
107
+
108
+ ##
109
+ # List all reserved domains on this account.
110
+ #
111
+ # @param [string] before_id
112
+ # @param [integer] limit
113
+ # @param [string] url optional and mutually exclusive from before_id and limit
114
+ # @return [NgrokAPI::Models::Listable] result from list request
115
+ #
116
+ # https://ngrok.com/docs/api#api-reserved-domains-list
117
+ def list(before_id: nil, limit: nil, url: nil)
118
+ result = @client.list(before_id: before_id, limit: limit, url: url, path: PATH)
119
+ NgrokAPI::Models::Listable.new(
120
+ client: self,
121
+ result: result,
122
+ list_property: LIST_PROPERTY,
123
+ klass: NgrokAPI::Models::ReservedDomain
124
+ )
125
+ end
126
+
127
+ # rubocop:disable LineLength
128
+
129
+ ##
130
+ # Update the attributes of a reserved domain.
131
+ #
132
+ # @param [string] id
133
+ # @param [string] description human-readable description of what this reserved domain will be used for
134
+ # @param [string] metadata arbitrary user-defined machine-readable data of this reserved domain. Optional, max 4096 bytes.
135
+ # @param [string] http_endpoint_configuration_id ID of an endpoint configuration of type http that will be used to handle inbound http traffic to this domain
136
+ # @param [string] https_endpoint_configuration_id ID of an endpoint configuration of type https that will be used to handle inbound https traffic to this domain
137
+ # @param [string] certificate_id ID of a user-uploaded TLS certificate to use for connections to targeting this domain. Optional, mutually exclusive with ``certificate_management_policy``.
138
+ # @param [string] certificate_management_policy configuration for automatic management of TLS certificates for this domain, or null if automatic management is disabled. Optional, mutually exclusive with ``certificate_id``.
139
+ # @return [NgrokAPI::Models::ReservedDomain] result from update request
140
+ #
141
+ # https://ngrok.com/docs/api#api-reserved-domains-update
142
+ def update(
143
+ id: nil,
144
+ certificate_id: nil,
145
+ certificate_management_policy: nil,
146
+ description: nil,
147
+ http_endpoint_configuration_id: nil,
148
+ https_endpoint_configuration_id: nil,
149
+ metadata: nil
150
+ )
151
+ data = build_data(
152
+ description: description,
153
+ metadata: metadata,
154
+ http_endpoint_configuration_id: http_endpoint_configuration_id,
155
+ https_endpoint_configuration_id: https_endpoint_configuration_id,
156
+ certificate_id: certificate_id,
157
+ certificate_management_policy: certificate_management_policy
158
+ )
159
+ result = @client.patch("#{PATH}/#{id}", data: data)
160
+ NgrokAPI::Models::ReservedDomain.new(client: self, result: result)
161
+ end
162
+
163
+ ##
164
+ # Update the attributes of a reserved domain. Throw an exception if 404.
165
+ #
166
+ # @param [string] id
167
+ # @param [string] description human-readable description of what this reserved domain will be used for
168
+ # @param [string] metadata arbitrary user-defined machine-readable data of this reserved domain. Optional, max 4096 bytes.
169
+ # @param [string] http_endpoint_configuration_id ID of an endpoint configuration of type http that will be used to handle inbound http traffic to this domain
170
+ # @param [string] https_endpoint_configuration_id ID of an endpoint configuration of type https that will be used to handle inbound https traffic to this domain
171
+ # @param [string] certificate_id ID of a user-uploaded TLS certificate to use for connections to targeting this domain. Optional, mutually exclusive with ``certificate_management_policy``.
172
+ # @param [string] certificate_management_policy configuration for automatic management of TLS certificates for this domain, or null if automatic management is disabled. Optional, mutually exclusive with ``certificate_id``.
173
+ # @return [NgrokAPI::Models::ReservedDomain] result from update request
174
+ #
175
+ # https://ngrok.com/docs/api#api-reserved-domains-update
176
+ def update!(
177
+ id: nil,
178
+ certificate_id: nil,
179
+ certificate_management_policy: nil,
180
+ description: nil,
181
+ http_endpoint_configuration_id: nil,
182
+ https_endpoint_configuration_id: nil,
183
+ metadata: nil
184
+ )
185
+ data = build_data(
186
+ description: description,
187
+ metadata: metadata,
188
+ http_endpoint_configuration_id: http_endpoint_configuration_id,
189
+ https_endpoint_configuration_id: https_endpoint_configuration_id,
190
+ certificate_id: certificate_id,
191
+ certificate_management_policy: certificate_management_policy
192
+ )
193
+ result = @client.patch("#{PATH}/#{id}", danger: true, data: data)
194
+ NgrokAPI::Models::ReservedDomain.new(client: self, result: result)
195
+ end
196
+ # rubocop:enable LineLength
197
+
198
+ ##
199
+ # Detach the certificate attached from a reserved domain.
200
+ #
201
+ # @param [string] id a resource identifier
202
+ # @return [nil] result from delete request
203
+ #
204
+ # https://ngrok.com/docs/api#api-reserved-domains-delete-certificate
205
+ def delete_certificate(id: nil)
206
+ @client.delete("#{PATH}/#{id}/certificate")
207
+ end
208
+
209
+ ##
210
+ # Detach the certificate attached from a reserved domain. Throw an exception if 404.
211
+ #
212
+ # @param [string] id a resource identifier
213
+ # @return [nil] result from delete request
214
+ #
215
+ # https://ngrok.com/docs/api#api-reserved-domains-delete-certificate
216
+ def delete_certificate!(id: nil)
217
+ @client.delete("#{PATH}/#{id}/certificate", danger: true)
218
+ end
219
+
220
+ ##
221
+ # Detach the certificate management policy attached from a reserved domain.
222
+ #
223
+ # @param [string] id a resource identifier
224
+ # @return [nil] result from delete request
225
+ #
226
+ # https://ngrok.com/docs/api#api-reserved-domains-delete-certificate-management-policy
227
+ def delete_certificate_management_policy(id: nil)
228
+ @client.delete("#{PATH}/#{id}/certificate_management_policy")
229
+ end
230
+
231
+ ##
232
+ # Detach the certificate management policy attached from a reserved domain.
233
+ #
234
+ # @param [string] id a resource identifier
235
+ # @return [nil] result from delete request
236
+ #
237
+ # https://ngrok.com/docs/api#api-reserved-domains-delete-certificate-management-policy
238
+ def delete_certificate_management_policy!(id: nil)
239
+ @client.delete("#{PATH}/#{id}/certificate_management_policy", danger: true)
240
+ end
241
+
242
+ ##
243
+ # Detach the http endpoint configuration attached from a reserved domain.
244
+ #
245
+ # @param [string] id a resource identifier
246
+ # @return [nil] result from delete request
247
+ #
248
+ # https://ngrok.com/docs/api#api-reserved-domains-delete-http-endpoint-config
249
+ def delete_http_endpoint_config(id: nil)
250
+ @client.delete("#{PATH}/#{id}/http_endpoint_configuration")
251
+ end
252
+
253
+ ##
254
+ # Detach the http endpoint configuration attached from a reserved domain. Throw an exception if 404.
255
+ #
256
+ # @param [string] id a resource identifier
257
+ # @return [nil] result from delete request
258
+ #
259
+ # https://ngrok.com/docs/api#api-reserved-domains-delete-http-endpoint-config
260
+ def delete_http_endpoint_config!(id: nil)
261
+ @client.delete("#{PATH}/#{id}/http_endpoint_configuration", danger: true)
262
+ end
263
+
264
+ ##
265
+ # Detach the https endpoint configuration attached from a reserved domain.
266
+ #
267
+ # @param [string] id a resource identifier
268
+ # @return [nil] result from delete request
269
+ #
270
+ # https://ngrok.com/docs/api#api-reserved-domains-delete-https-endpoint-config
271
+ def delete_https_endpoint_config(id: nil)
272
+ @client.delete("#{PATH}/#{id}/https_endpoint_configuration")
273
+ end
274
+
275
+ ##
276
+ # Detach the https endpoint configuration attached from a reserved domain. Throw an exception if 404.
277
+ #
278
+ # @param [string] id a resource identifier
279
+ # @return [nil] result from delete request
280
+ #
281
+ # https://ngrok.com/docs/api#api-reserved-domains-delete-https-endpoint-config
282
+ def delete_https_endpoint_config!(id: nil)
283
+ @client.delete("#{PATH}/#{id}/https_endpoint_configuration", danger: true)
284
+ end
285
+
286
+ private
287
+
288
+ def build_data(
289
+ description: nil,
290
+ metadata: nil,
291
+ http_endpoint_configuration_id: nil,
292
+ https_endpoint_configuration_id: nil,
293
+ certificate_id: nil,
294
+ certificate_management_policy: nily
295
+ )
296
+ data = {}
297
+ data[:certificate_id] = certificate_id if certificate_id
298
+ if certificate_management_policy
299
+ data[:certificate_management_policy] = certificate_management_policy
300
+ end
301
+ data[:description] = description if description
302
+ if http_endpoint_configuration_id
303
+ data[:http_endpoint_configuration_id] = http_endpoint_configuration_id
304
+ end
305
+ if https_endpoint_configuration_id
306
+ data[:https_endpoint_configuration_id] = https_endpoint_configuration_id
307
+ end
308
+ data[:metadata] = metadata if metadata
309
+ data
310
+ end
311
+ end
312
+ end
313
+ end