ngrok-api 0.9.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.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +21 -0
- data/.gitignore +13 -0
- data/.rubocop.yml +28 -0
- data/.rubocop_airbnb.yml +2 -0
- data/.simplecov +1 -0
- data/Gemfile +33 -0
- data/Guardfile +16 -0
- data/README.md +61 -0
- data/Rakefile +7 -0
- data/doc/NgrokAPI/Client.html +542 -0
- data/doc/NgrokAPI/Error.html +305 -0
- data/doc/NgrokAPI/Errors/NotFoundError.html +309 -0
- data/doc/NgrokAPI/Errors.html +115 -0
- data/doc/NgrokAPI/HttpClient.html +1104 -0
- data/doc/NgrokAPI/Models/ApiKey.html +1138 -0
- data/doc/NgrokAPI/Models/EndpointConfiguration.html +1366 -0
- data/doc/NgrokAPI/Models/Listable.html +934 -0
- data/doc/NgrokAPI/Models/ReservedDomain.html +2498 -0
- data/doc/NgrokAPI/Models/TlsCertificate.html +1064 -0
- data/doc/NgrokAPI/Models.html +117 -0
- data/doc/NgrokAPI/PagedIterator.html +631 -0
- data/doc/NgrokAPI/Services/ApiKeysClient.html +1333 -0
- data/doc/NgrokAPI/Services/EndpointConfigurationsClient.html +2201 -0
- data/doc/NgrokAPI/Services/ReservedDomainsClient.html +2541 -0
- data/doc/NgrokAPI/Services/TlsCertificatesClient.html +1417 -0
- data/doc/NgrokAPI/Services.html +117 -0
- data/doc/NgrokAPI.html +157 -0
- data/doc/_index.html +309 -0
- data/doc/class_list.html +51 -0
- data/doc/css/common.css +1 -0
- data/doc/css/full_list.css +58 -0
- data/doc/css/style.css +497 -0
- data/doc/file.README.html +126 -0
- data/doc/file_list.html +56 -0
- data/doc/frames.html +17 -0
- data/doc/index.html +126 -0
- data/doc/js/app.js +314 -0
- data/doc/js/full_list.js +216 -0
- data/doc/js/jquery.js +4 -0
- data/doc/method_list.html +1227 -0
- data/doc/top-level-namespace.html +110 -0
- data/docs/NgrokAPI/Client.html +542 -0
- data/docs/NgrokAPI/Error.html +305 -0
- data/docs/NgrokAPI/Errors/NotFoundError.html +309 -0
- data/docs/NgrokAPI/Errors.html +115 -0
- data/docs/NgrokAPI/HttpClient.html +1104 -0
- data/docs/NgrokAPI/Models/ApiKey.html +1138 -0
- data/docs/NgrokAPI/Models/EndpointConfiguration.html +1366 -0
- data/docs/NgrokAPI/Models/Listable.html +934 -0
- data/docs/NgrokAPI/Models/ReservedDomain.html +2498 -0
- data/docs/NgrokAPI/Models/TlsCertificate.html +1064 -0
- data/docs/NgrokAPI/Models.html +117 -0
- data/docs/NgrokAPI/PagedIterator.html +631 -0
- data/docs/NgrokAPI/Services/ApiKeysClient.html +1333 -0
- data/docs/NgrokAPI/Services/EndpointConfigurationsClient.html +2201 -0
- data/docs/NgrokAPI/Services/ReservedDomainsClient.html +2541 -0
- data/docs/NgrokAPI/Services/TlsCertificatesClient.html +1417 -0
- data/docs/NgrokAPI/Services.html +117 -0
- data/docs/NgrokAPI.html +157 -0
- data/docs/_index.html +309 -0
- data/docs/class_list.html +51 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +497 -0
- data/docs/file.README.html +126 -0
- data/docs/file_list.html +56 -0
- data/docs/frames.html +17 -0
- data/docs/index.html +126 -0
- data/docs/js/app.js +314 -0
- data/docs/js/full_list.js +216 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +1227 -0
- data/docs/top-level-namespace.html +110 -0
- data/lib/ngrokapi/client.rb +49 -0
- data/lib/ngrokapi/error.rb +14 -0
- data/lib/ngrokapi/errors/not_found_error.rb +16 -0
- data/lib/ngrokapi/http_client.rb +132 -0
- data/lib/ngrokapi/models/api_key.rb +64 -0
- data/lib/ngrokapi/models/endpoint_configuration.rb +119 -0
- data/lib/ngrokapi/models/listable.rb +42 -0
- data/lib/ngrokapi/models/reserved_domain.rb +211 -0
- data/lib/ngrokapi/models/tls_certificate.rb +62 -0
- data/lib/ngrokapi/paged_iterator.rb +40 -0
- data/lib/ngrokapi/services/api_keys_client.rb +144 -0
- data/lib/ngrokapi/services/endpoint_configurations_client.rb +313 -0
- data/lib/ngrokapi/services/reserved_domains_client.rb +313 -0
- data/lib/ngrokapi/services/tls_certificates_client.rb +161 -0
- data/lib/ngrokapi/version.rb +7 -0
- data/lib/ngrokapi.rb +13 -0
- data/ngrok-api.gemspec +27 -0
- data/spec/ngrokapi/client_spec.rb +33 -0
- data/spec/ngrokapi/http_client_spec.rb +75 -0
- data/spec/ngrokapi/models/api_key_spec.rb +43 -0
- data/spec/ngrokapi/models/listable_spec.rb +43 -0
- data/spec/ngrokapi/models/reserved_domain_spec.rb +100 -0
- data/spec/ngrokapi/paged_iterator_spec.rb +84 -0
- data/spec/ngrokapi/services/api_keys_client_spec.rb +127 -0
- data/spec/spec_helper.rb +80 -0
- metadata +144 -0
|
@@ -0,0 +1,211 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NgrokAPI
|
|
4
|
+
module Models
|
|
5
|
+
##
|
|
6
|
+
# A resource representing data from the reserved_domains API
|
|
7
|
+
class ReservedDomain
|
|
8
|
+
attr_reader :id,
|
|
9
|
+
:certificate,
|
|
10
|
+
:certificate_management_policy,
|
|
11
|
+
:certificate_management_status,
|
|
12
|
+
:client,
|
|
13
|
+
:cname_target,
|
|
14
|
+
:created_at,
|
|
15
|
+
:description,
|
|
16
|
+
:domain,
|
|
17
|
+
:http_endpoint_configuration,
|
|
18
|
+
:https_endpoint_configuration,
|
|
19
|
+
:metadata,
|
|
20
|
+
:region,
|
|
21
|
+
:result,
|
|
22
|
+
:uri
|
|
23
|
+
|
|
24
|
+
def initialize(client:, result:)
|
|
25
|
+
@client = client
|
|
26
|
+
@result = result
|
|
27
|
+
@created_at = @result['created_at']
|
|
28
|
+
@certificate = @result['certificate']
|
|
29
|
+
@certificate_management_policy = @result['certificate_management_policy']
|
|
30
|
+
@certificate_management_status = @result['certificate_management_status']
|
|
31
|
+
@cname_target = @result['cname_target']
|
|
32
|
+
@description = @result['description']
|
|
33
|
+
@domain = @result['domain']
|
|
34
|
+
@http_endpoint_configuration = @result['http_endpoint_configuration']
|
|
35
|
+
@https_endpoint_configuration = @result['https_endpoint_configuration']
|
|
36
|
+
@id = @result['id']
|
|
37
|
+
@metadata = @result['metadata']
|
|
38
|
+
@region = @result['region']
|
|
39
|
+
@uri = @result['uri']
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def ==(other)
|
|
43
|
+
@result == other.result
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
def to_s
|
|
47
|
+
@result.to_s
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
##
|
|
51
|
+
# Delete this reserved domain.
|
|
52
|
+
#
|
|
53
|
+
# @return [nil] result from delete request
|
|
54
|
+
#
|
|
55
|
+
# https://ngrok.com/docs/api#api-reserved-domains-delete
|
|
56
|
+
def delete
|
|
57
|
+
@client.delete(id: @id)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
# rubocop:disable LineLength
|
|
61
|
+
|
|
62
|
+
##
|
|
63
|
+
# Update the attributes of this reserved domain.
|
|
64
|
+
#
|
|
65
|
+
# @param [string] description human-readable description of what this reserved domain will be used for
|
|
66
|
+
# @param [string] metadata arbitrary user-defined machine-readable data of this reserved domain. Optional, max 4096 bytes.
|
|
67
|
+
# @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
|
|
68
|
+
# @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
|
|
69
|
+
# @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``.
|
|
70
|
+
# @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``.
|
|
71
|
+
# @return [NgrokAPI::Models::ReservedDomain] result from update request
|
|
72
|
+
#
|
|
73
|
+
# https://ngrok.com/docs/api#api-reserved-domains-update
|
|
74
|
+
def update(
|
|
75
|
+
certificate_id: nil,
|
|
76
|
+
certificate_management_policy: nil,
|
|
77
|
+
description: '',
|
|
78
|
+
http_endpoint_configuration_id: nil,
|
|
79
|
+
https_endpoint_configuration_id: nil,
|
|
80
|
+
metadata: ''
|
|
81
|
+
)
|
|
82
|
+
if certificate_management_policy
|
|
83
|
+
@certificate_management_policy = certificate_management_policy
|
|
84
|
+
end
|
|
85
|
+
@description = description if description
|
|
86
|
+
@metadata = metadata if metadata
|
|
87
|
+
@client.update(
|
|
88
|
+
id: @id,
|
|
89
|
+
description: description,
|
|
90
|
+
metadata: metadata,
|
|
91
|
+
http_endpoint_configuration_id: http_endpoint_configuration_id,
|
|
92
|
+
https_endpoint_configuration_id: https_endpoint_configuration_id,
|
|
93
|
+
certificate_id: certificate_id,
|
|
94
|
+
certificate_management_policy: certificate_management_policy
|
|
95
|
+
)
|
|
96
|
+
# TODO: update @certificate, etc?
|
|
97
|
+
# @certificate = new_result['certificate'] if certificate_id && new_result['certificate']
|
|
98
|
+
# if http_endpoint_configuration_id
|
|
99
|
+
# @http_endpoint_configuration_id = http_endpoint_configuration_id
|
|
100
|
+
# end
|
|
101
|
+
# if https_endpoint_configuration_id
|
|
102
|
+
# @https_endpoint_configuration_id = https_endpoint_configuration_id
|
|
103
|
+
# end
|
|
104
|
+
end
|
|
105
|
+
# rubocop:enable LineLength
|
|
106
|
+
|
|
107
|
+
##
|
|
108
|
+
# Detach the certificate attached from this reserved domain.
|
|
109
|
+
#
|
|
110
|
+
# @return [nil] result from delete request
|
|
111
|
+
#
|
|
112
|
+
# https://ngrok.com/docs/api#api-reserved-domains-delete-certificate
|
|
113
|
+
def delete_certificate
|
|
114
|
+
@certificate = nil
|
|
115
|
+
@client.delete_certificate(id: @id)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
##
|
|
119
|
+
# Detach the certificate management policy attached from this reserved domain.
|
|
120
|
+
#
|
|
121
|
+
# @return [nil] result from delete request
|
|
122
|
+
#
|
|
123
|
+
# https://ngrok.com/docs/api#api-reserved-domains-delete-certificate-management-policy
|
|
124
|
+
def delete_certificate_management_policy
|
|
125
|
+
@certificate_management_policy = nil
|
|
126
|
+
@certificate_management_status = nil
|
|
127
|
+
@client.delete_certificate_management_policy(id: @id)
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
##
|
|
131
|
+
# Detach the http endpoint configuration attached from this reserved domain.
|
|
132
|
+
#
|
|
133
|
+
# @return [nil] result from delete request
|
|
134
|
+
#
|
|
135
|
+
# https://ngrok.com/docs/api#api-reserved-domains-delete-http-endpoint-config
|
|
136
|
+
def delete_http_endpoint_config
|
|
137
|
+
@http_endpoint_configuration = nil
|
|
138
|
+
@client.delete_http_endpoint_config(id: @id)
|
|
139
|
+
end
|
|
140
|
+
|
|
141
|
+
##
|
|
142
|
+
# Detach the https endpoint configuration attached from this reserved domain.
|
|
143
|
+
#
|
|
144
|
+
# @return [nil] result from delete request
|
|
145
|
+
#
|
|
146
|
+
# https://ngrok.com/docs/api#api-reserved-domains-delete-https-endpoint-config
|
|
147
|
+
def delete_https_endpoint_config
|
|
148
|
+
@https_endpoint_configuration = nil
|
|
149
|
+
@client.delete_https_endpoint_config(id: @id)
|
|
150
|
+
end
|
|
151
|
+
|
|
152
|
+
##
|
|
153
|
+
# Restore the certificate attached to this reserved domain.
|
|
154
|
+
# Only works if the @result is still present from a previous action
|
|
155
|
+
#
|
|
156
|
+
# @return [NgrokAPI::Models::ReservedDomain] result from update request
|
|
157
|
+
#
|
|
158
|
+
# https://ngrok.com/docs/api#api-reserved-domains-update
|
|
159
|
+
def restore_certificate
|
|
160
|
+
@certificate = @result['certificate']
|
|
161
|
+
@client.update(id: @id, certificate_id: @result['certificate']['id'])
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
##
|
|
165
|
+
# Restore the certificate management policy attached to this reserved domain.
|
|
166
|
+
# Only works if the @result is still present from a previous action
|
|
167
|
+
#
|
|
168
|
+
# @return [NgrokAPI::Models::ReservedDomain] result from update request
|
|
169
|
+
#
|
|
170
|
+
# https://ngrok.com/docs/api#api-reserved-domains-update
|
|
171
|
+
def restore_certificate_management_policy
|
|
172
|
+
@certificate_management_policy = @result['certificate_management_policy']
|
|
173
|
+
@certificate_management_status = @result['certificate_management_status']
|
|
174
|
+
@client.update(
|
|
175
|
+
id: @id,
|
|
176
|
+
certificate_management_policy: @result['certificate_management_policy']
|
|
177
|
+
)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
##
|
|
181
|
+
# Restore the http endpoint configuration attached to this reserved domain.
|
|
182
|
+
# Only works if the @result is still present from a previous action
|
|
183
|
+
#
|
|
184
|
+
# @return [NgrokAPI::Models::ReservedDomain] result from update request
|
|
185
|
+
#
|
|
186
|
+
# https://ngrok.com/docs/api#api-reserved-domains-update
|
|
187
|
+
def restore_http_endpoint_config
|
|
188
|
+
@http_endpoint_configuration = @result['http_endpoint_configuration']
|
|
189
|
+
@client.update(
|
|
190
|
+
id: @id,
|
|
191
|
+
http_endpoint_configuration_id: @result['http_endpoint_configuration']['id']
|
|
192
|
+
)
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
##
|
|
196
|
+
# Restore the https endpoint configuration attached to this reserved domain.
|
|
197
|
+
# Only works if the @result is still present from a previous action
|
|
198
|
+
#
|
|
199
|
+
# @return [NgrokAPI::Models::ReservedDomain] result from update request
|
|
200
|
+
#
|
|
201
|
+
# https://ngrok.com/docs/api#api-reserved-domains-update
|
|
202
|
+
def restore_https_endpoint_config
|
|
203
|
+
@https_endpoint_configuration = @result['https_endpoint_configuration']
|
|
204
|
+
@client.update(
|
|
205
|
+
id: @id,
|
|
206
|
+
https_endpoint_configuration_id: @result['https_endpoint_configuration']['id']
|
|
207
|
+
)
|
|
208
|
+
end
|
|
209
|
+
end
|
|
210
|
+
end
|
|
211
|
+
end
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NgrokAPI
|
|
4
|
+
module Models
|
|
5
|
+
##
|
|
6
|
+
# A resource representing data from the tls_certificate API
|
|
7
|
+
class TlsCertificate
|
|
8
|
+
attr_reader :id,
|
|
9
|
+
:client,
|
|
10
|
+
:created_at,
|
|
11
|
+
:description,
|
|
12
|
+
:metadata,
|
|
13
|
+
:result,
|
|
14
|
+
:uri
|
|
15
|
+
|
|
16
|
+
def initialize(client:, result:)
|
|
17
|
+
@client = client
|
|
18
|
+
@result = result
|
|
19
|
+
@created_at = @result['created_at']
|
|
20
|
+
@id = @result['id']
|
|
21
|
+
@description = @result['description']
|
|
22
|
+
@metadata = @result['metadata']
|
|
23
|
+
@uri = @result['uri']
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def ==(other)
|
|
27
|
+
@result == other.result
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def to_s
|
|
31
|
+
@result.to_s
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
##
|
|
35
|
+
# Delete this TLS certificate.
|
|
36
|
+
#
|
|
37
|
+
# @return [nil] result from delete request
|
|
38
|
+
#
|
|
39
|
+
# https://ngrok.com/docs/api#api-tls-certificates-delete
|
|
40
|
+
def delete
|
|
41
|
+
@client.delete(id: @id)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# rubocop:disable LineLength
|
|
45
|
+
|
|
46
|
+
##
|
|
47
|
+
# Update the attributes of this TLS Certificate.
|
|
48
|
+
#
|
|
49
|
+
# @param [string] description human-readable description of this TLS certificate. optional, max 255 bytes.
|
|
50
|
+
# @param [string] metadata arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes.
|
|
51
|
+
# @return [NgrokAPI::Models::TlsCertificate] result from update request
|
|
52
|
+
#
|
|
53
|
+
# https://ngrok.com/docs/api#api-tls-certificates-update
|
|
54
|
+
def update(description: nil, metadata: nil)
|
|
55
|
+
@description = description if description
|
|
56
|
+
@metadata = metadata if metadata
|
|
57
|
+
@client.update(id: @id, description: description, metadata: metadata)
|
|
58
|
+
end
|
|
59
|
+
# rubocop:enable LineLength
|
|
60
|
+
end
|
|
61
|
+
end
|
|
62
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NgrokAPI
|
|
4
|
+
##
|
|
5
|
+
# Low level class which allows the user to iterate through the results of a list API call
|
|
6
|
+
class PagedIterator
|
|
7
|
+
attr_accessor :page, :n
|
|
8
|
+
attr_reader :client, :list_property
|
|
9
|
+
|
|
10
|
+
def initialize(
|
|
11
|
+
client:,
|
|
12
|
+
page:,
|
|
13
|
+
list_property:
|
|
14
|
+
)
|
|
15
|
+
@n = 0
|
|
16
|
+
@client = client
|
|
17
|
+
@list_property = list_property
|
|
18
|
+
@page = page
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
##
|
|
22
|
+
# Iterate through the result set, returning the next instance if we already have one, or make
|
|
23
|
+
# a new API call to next_page_uri to get more results and return the next one from that call.
|
|
24
|
+
#
|
|
25
|
+
# @return [object] Returns an instance of a class.
|
|
26
|
+
def get_next
|
|
27
|
+
item = @page.result[@list_property][@n]
|
|
28
|
+
raise "None" if item.nil?
|
|
29
|
+
self.n += 1
|
|
30
|
+
item
|
|
31
|
+
rescue
|
|
32
|
+
if @page.next_page_uri
|
|
33
|
+
res = @client.list(url: @page.next_page_uri)
|
|
34
|
+
self.n = 0
|
|
35
|
+
self.page = res
|
|
36
|
+
get_next
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module NgrokAPI
|
|
4
|
+
module Services
|
|
5
|
+
##
|
|
6
|
+
# A client for interacting with the api_keys API
|
|
7
|
+
#
|
|
8
|
+
# https://ngrok.com/docs/api#api-api-keys
|
|
9
|
+
class ApiKeysClient
|
|
10
|
+
# The List Property from the resulting API for list calls
|
|
11
|
+
LIST_PROPERTY = 'keys'
|
|
12
|
+
# The API path for API keys
|
|
13
|
+
PATH = '/api_keys'
|
|
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 API key. The generated API key can be used to authenticate to the ngrok API.
|
|
25
|
+
#
|
|
26
|
+
# @param [string] description human-readable description of what uses the API key to authenticate. optional, max 255 bytes.
|
|
27
|
+
# @param [string] metadata arbitrary user-defined data of this API key. optional, max 4096 bytes
|
|
28
|
+
# @return [NgrokAPI::Models::ApiKey] result from create request
|
|
29
|
+
#
|
|
30
|
+
# https://ngrok.com/docs/api#api-api-keys-create
|
|
31
|
+
def create(description: nil, metadata: nil)
|
|
32
|
+
result = @client.post(PATH, data: build_data(description: description, metadata: metadata))
|
|
33
|
+
NgrokAPI::Models::ApiKey.new(client: self, result: result)
|
|
34
|
+
end
|
|
35
|
+
# rubocop:enable LineLength
|
|
36
|
+
|
|
37
|
+
##
|
|
38
|
+
# Delete an API key by ID.
|
|
39
|
+
#
|
|
40
|
+
# @param [string] id a resource identifier
|
|
41
|
+
# @return [nil] result from delete request
|
|
42
|
+
#
|
|
43
|
+
# https://ngrok.com/docs/api#api-api-keys-delete
|
|
44
|
+
def delete(id: nil)
|
|
45
|
+
@client.delete("#{PATH}/#{id}")
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
##
|
|
49
|
+
# Delete an API key by ID. Throw an exception if 404.
|
|
50
|
+
#
|
|
51
|
+
# @param [string] id a resource identifier
|
|
52
|
+
# @return [nil] result from delete request
|
|
53
|
+
#
|
|
54
|
+
# https://ngrok.com/docs/api#api-api-keys-delete
|
|
55
|
+
def delete!(id: nil)
|
|
56
|
+
@client.delete("#{PATH}/#{id}", danger: true)
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
##
|
|
60
|
+
# Get the details of an API key by ID.
|
|
61
|
+
#
|
|
62
|
+
# @param [string] id a resource identifier
|
|
63
|
+
# @return [NgrokAPI::Models::ApiKey] result from get request
|
|
64
|
+
#
|
|
65
|
+
# https://ngrok.com/docs/api#api-api-keys-get
|
|
66
|
+
def get(id: nil)
|
|
67
|
+
result = @client.get("#{PATH}/#{id}")
|
|
68
|
+
NgrokAPI::Models::ApiKey.new(client: self, result: result)
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
##
|
|
72
|
+
# Get the details of an API key by ID. Throw an exception if 404.
|
|
73
|
+
#
|
|
74
|
+
# @param [string] id a resource identifier
|
|
75
|
+
# @return [NgrokAPI::Models::ApiKey] result from get request
|
|
76
|
+
#
|
|
77
|
+
# https://ngrok.com/docs/api#api-api-keys-get
|
|
78
|
+
def get!(id: nil)
|
|
79
|
+
result = @client.get("#{PATH}/#{id}", danger: true)
|
|
80
|
+
NgrokAPI::Models::ApiKey.new(client: self, result: result)
|
|
81
|
+
end
|
|
82
|
+
|
|
83
|
+
##
|
|
84
|
+
# List all API keys owned by this account.
|
|
85
|
+
#
|
|
86
|
+
# @param [string] before_id
|
|
87
|
+
# @param [integer] limit
|
|
88
|
+
# @param [string] url optional and mutually exclusive from before_id and limit
|
|
89
|
+
# @return [NgrokAPI::Models::Listable] the result listable
|
|
90
|
+
#
|
|
91
|
+
# https://ngrok.com/docs/api#api-api-keys-list
|
|
92
|
+
def list(before_id: nil, limit: nil, url: nil)
|
|
93
|
+
result = @client.list(before_id: before_id, limit: limit, url: url, path: PATH)
|
|
94
|
+
NgrokAPI::Models::Listable.new(
|
|
95
|
+
client: self,
|
|
96
|
+
result: result,
|
|
97
|
+
list_property: LIST_PROPERTY,
|
|
98
|
+
klass: NgrokAPI::Models::ApiKey
|
|
99
|
+
)
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# rubocop:disable LineLength
|
|
103
|
+
|
|
104
|
+
##
|
|
105
|
+
# Update attributes of an API key by ID.
|
|
106
|
+
#
|
|
107
|
+
# @param [string] id
|
|
108
|
+
# @param [string] description human-readable description of what uses the API key to authenticate. optional, max 255 bytes.
|
|
109
|
+
# @param [string] metadata arbitrary user-defined data of this API key. optional, max 4096 bytes
|
|
110
|
+
# @return [NgrokAPI::Models::ApiKey] result from update request
|
|
111
|
+
#
|
|
112
|
+
# https://ngrok.com/docs/api#api-api-keys-update
|
|
113
|
+
def update(id: nil, description: nil, metadata: nil)
|
|
114
|
+
result = @client.patch("#{PATH}/#{id}", data: build_data(description: description, metadata: metadata))
|
|
115
|
+
NgrokAPI::Models::ApiKey.new(client: self, result: result)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
##
|
|
119
|
+
# Update attributes of an API key by ID.
|
|
120
|
+
#
|
|
121
|
+
# @param [string] id
|
|
122
|
+
# @param [string] description human-readable description of what uses the API key to authenticate. optional, max 255 bytes.
|
|
123
|
+
# @param [string] metadata arbitrary user-defined data of this API key. optional, max 4096 bytes
|
|
124
|
+
# @return [NgrokAPI::Models::ApiKey] result from update request
|
|
125
|
+
#
|
|
126
|
+
# https://ngrok.com/docs/api#api-api-keys-update
|
|
127
|
+
def update!(id: nil, description: nil, metadata: nil)
|
|
128
|
+
data = build_data(description: description, metadata: metadata)
|
|
129
|
+
result = @client.patch("#{PATH}/#{id}", danger: true, data: data)
|
|
130
|
+
NgrokAPI::Models::ApiKey.new(client: self, result: result)
|
|
131
|
+
end
|
|
132
|
+
# rubocop:enable LineLength
|
|
133
|
+
|
|
134
|
+
private
|
|
135
|
+
|
|
136
|
+
def build_data(description: nil, metadata: nil)
|
|
137
|
+
data = {}
|
|
138
|
+
data[:description] = description if description
|
|
139
|
+
data[:metadata] = metadata if metadata
|
|
140
|
+
data
|
|
141
|
+
end
|
|
142
|
+
end
|
|
143
|
+
end
|
|
144
|
+
end
|