diff --git a/doc/NgrokAPI.html b/doc/NgrokAPI.html index b9988ba..0d587a1 100644 --- a/doc/NgrokAPI.html +++ b/doc/NgrokAPI.html @@ -79,7 +79,7 @@
Defined in:
lib/ngrokapi.rb,
- lib/ngrokapi/client.rb,
lib/ngrokapi/version.rb,
lib/ngrokapi/http_client.rb,
lib/ngrokapi/models/api_key.rb,
lib/ngrokapi/paged_iterator.rb,
lib/ngrokapi/models/listable.rb,
lib/ngrokapi/models/reserved_domain.rb,
lib/ngrokapi/models/tls_certificate.rb,
lib/ngrokapi/services/api_keys_client.rb,
lib/ngrokapi/models/endpoint_configuration.rb,
lib/ngrokapi/services/reserved_domains_client.rb,
lib/ngrokapi/services/tls_certificates_client.rb,
lib/ngrokapi/services/endpoint_configurations_client.rb
+ lib/ngrokapi/client.rb,
lib/ngrokapi/version.rb,
lib/ngrokapi/http_client.rb,
lib/ngrokapi/models/api_key.rb,
lib/ngrokapi/paged_iterator.rb,
lib/ngrokapi/models/listable.rb,
lib/ngrokapi/errors/not_found_error.rb,
lib/ngrokapi/models/reserved_domain.rb,
lib/ngrokapi/models/tls_certificate.rb,
lib/ngrokapi/services/api_keys_client.rb,
lib/ngrokapi/models/endpoint_configuration.rb,
lib/ngrokapi/services/reserved_domains_client.rb,
lib/ngrokapi/services/tls_certificates_client.rb,
lib/ngrokapi/services/endpoint_configurations_client.rb
@@ -100,7 +100,7 @@

- Modules: Models, Services + Modules: Errors, Models, Services @@ -147,7 +147,7 @@

diff --git a/doc/NgrokAPI/Client.html b/doc/NgrokAPI/Client.html index e479ab6..f9ef45e 100644 --- a/doc/NgrokAPI/Client.html +++ b/doc/NgrokAPI/Client.html @@ -532,7 +532,7 @@ diff --git a/doc/NgrokAPI/Errors.html b/doc/NgrokAPI/Errors.html new file mode 100644 index 0000000..a764b3c --- /dev/null +++ b/doc/NgrokAPI/Errors.html @@ -0,0 +1,115 @@ + + + + + + + Module: NgrokAPI::Errors + + — Documentation by YARD 0.9.26 + + + + + + + + + + + + + + + + + + + +
+ + +

Module: NgrokAPI::Errors + + + +

+
+ + + + + + + + + + + +
+
Defined in:
+
lib/ngrokapi/errors/not_found_error.rb
+
+ +
+ +

Defined Under Namespace

+

+ + + + + Classes: NotFoundError + + +

+ + + + + + + + + +
+ + + +
+ + \ No newline at end of file diff --git a/doc/NgrokAPI/Errors/NotFoundError.html b/doc/NgrokAPI/Errors/NotFoundError.html new file mode 100644 index 0000000..6460753 --- /dev/null +++ b/doc/NgrokAPI/Errors/NotFoundError.html @@ -0,0 +1,301 @@ + + + + + + + Exception: NgrokAPI::Errors::NotFoundError + + — Documentation by YARD 0.9.26 + + + + + + + + + + + + + + + + + + + +
+ + +

Exception: NgrokAPI::Errors::NotFoundError + + + +

+
+ +
+
Inherits:
+
+ StandardError + +
    +
  • Object
  • + + + + + +
+ show all + +
+
+ + + + + + + + + + + +
+
Defined in:
+
lib/ngrokapi/errors/not_found_error.rb
+
+ +
+ +

Overview

+
+ +

Error representing a 404 not found

+ + +
+
+
+ + +
+ + + +

Instance Attribute Summary collapse

+ + + + + + +

+ Instance Method Summary + collapse +

+ + + + + +
+

Constructor Details

+ +
+

+ + #initialize(msg: "Resource not found", response: nil) ⇒ NotFoundError + + + + + +

+
+ +

Returns a new instance of NotFoundError.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+10
+11
+12
+13
+
+
# File 'lib/ngrokapi/errors/not_found_error.rb', line 10
+
+def initialize(msg: "Resource not found", response: nil)
+  @response = response
+  super(msg)
+end
+
+
+ +
+ +
+

Instance Attribute Details

+ + + +
+

+ + #response ⇒ Object (readonly) + + + + + +

+
+ +

Returns the value of attribute response.

+ + +
+
+
+ + +
+ + + + +
+
+
+
+8
+9
+10
+
+
# File 'lib/ngrokapi/errors/not_found_error.rb', line 8
+
+def response
+  @response
+end
+
+
+ +
+ + +
+ + + +
+ + \ No newline at end of file diff --git a/doc/NgrokAPI/HttpClient.html b/doc/NgrokAPI/HttpClient.html index 9ce8d8e..0bec5b2 100644 --- a/doc/NgrokAPI/HttpClient.html +++ b/doc/NgrokAPI/HttpClient.html @@ -191,7 +191,7 @@
  • - #delete(path) ⇒ nil + #delete(path, danger: false) ⇒ nil @@ -215,7 +215,7 @@
  • - #get(path, data: {}) ⇒ json + #get(path, danger: false, data: {}) ⇒ json @@ -289,7 +289,7 @@
  • - #patch(path, data: {}) ⇒ json + #patch(path, danger: false, data: {}) ⇒ json @@ -313,7 +313,7 @@
  • - #post(path, data: {}) ⇒ json + #post(path, danger: false, data: {}) ⇒ json @@ -490,7 +490,7 @@

    - #delete(path) ⇒ nil + #delete(path, danger: false) ⇒ nil @@ -519,7 +519,25 @@ —
    -

    URL resource path

    +

    URL resource path.

    +
    + +

  • + +
  • + + danger + + + (boolean) + + + (defaults to: false) + + + — +
    +

    determine if we should throw an exception on 404 or not

  • @@ -546,19 +564,19 @@
     
     
    -24
     25
     26
     27
    -28
    +28 +29 -
    # File 'lib/ngrokapi/http_client.rb', line 24
    +      
    # File 'lib/ngrokapi/http_client.rb', line 25
     
    -def delete(path)
    +def delete(path, danger: false)
       uri = get_uri(path)
       req = Net::HTTP::Delete.new(uri, headers)
    -  json_do(uri, req)
    +  json_do(uri, req, danger: danger)
     end
    @@ -568,7 +586,7 @@

    - #get(path, data: {}) ⇒ json + #get(path, danger: false, data: {}) ⇒ json @@ -602,6 +620,24 @@ +
  • + + danger + + + (boolean) + + + (defaults to: false) + + + — +
    +

    determine if we should throw an exception on 404 or not

    +
    + +
  • +
  • data @@ -647,19 +683,19 @@
     
     
    -36
    -37
     38
     39
    -40
    +40 +41 +42
  • -
    # File 'lib/ngrokapi/http_client.rb', line 36
    +      
    # File 'lib/ngrokapi/http_client.rb', line 38
     
    -def get(path, data: {})
    +def get(path, danger: false, data: {})
       uri = get_uri(path, data: data)
       req = Net::HTTP::Get.new(uri, headers)
    -  json_do(uri, req)
    +  json_do(uri, req, danger: danger)
     end
    @@ -786,8 +822,6 @@
     
     
    -50
    -51
     52
     53
     54
    @@ -795,10 +829,12 @@
     56
     57
     58
    -59
    +59 +60 +61
    -
    # File 'lib/ngrokapi/http_client.rb', line 50
    +      
    # File 'lib/ngrokapi/http_client.rb', line 52
     
     def list(before_id: nil, limit: nil, path: nil, url: nil)
       if url
    @@ -818,7 +854,7 @@
           

    - #patch(path, data: {}) ⇒ json + #patch(path, danger: false, data: {}) ⇒ json @@ -852,6 +888,24 @@ +
  • + + danger + + + (boolean) + + + (defaults to: false) + + + — +
    +

    determine if we should throw an exception on 404 or not

    +
    + +
  • +
  • data @@ -897,19 +951,19 @@
     
     
    -67
    -68
    -69
     70
    -71
    +71 +72 +73 +74
  • -
    # File 'lib/ngrokapi/http_client.rb', line 67
    +      
    # File 'lib/ngrokapi/http_client.rb', line 70
     
    -def patch(path, data: {})
    +def patch(path, danger: false, data: {})
       uri = get_uri(path)
       req = Net::HTTP::Patch.new(uri, headers_with_json)
    -  json_do(uri, req, data: data.to_json)
    +  json_do(uri, req, danger: danger, data: data.to_json)
     end
    @@ -919,7 +973,7 @@

    - #post(path, data: {}) ⇒ json + #post(path, danger: false, data: {}) ⇒ json @@ -953,6 +1007,24 @@ +
  • + + danger + + + (boolean) + + + (defaults to: false) + + + — +
    +

    determine if we should throw an exception on 404 or not

    +
    + +
  • +
  • data @@ -998,19 +1070,19 @@
     
     
    -79
    -80
    -81
    -82
    -83
    +83 +84 +85 +86 +87
  • -
    # File 'lib/ngrokapi/http_client.rb', line 79
    +      
    # File 'lib/ngrokapi/http_client.rb', line 83
     
    -def post(path, data: {})
    +def post(path, danger: false, data: {})
       uri = get_uri(path)
       req = Net::HTTP::Post.new(uri, headers_with_json)
    -  json_do(uri, req, data: data.to_json)
    +  json_do(uri, req, danger: danger, data: data.to_json)
     end
    @@ -1022,7 +1094,7 @@ diff --git a/doc/NgrokAPI/Models.html b/doc/NgrokAPI/Models.html index 7c525d6..7020e95 100644 --- a/doc/NgrokAPI/Models.html +++ b/doc/NgrokAPI/Models.html @@ -107,7 +107,7 @@ diff --git a/doc/NgrokAPI/Models/ApiKey.html b/doc/NgrokAPI/Models/ApiKey.html index b0a4c81..66b4d22 100644 --- a/doc/NgrokAPI/Models/ApiKey.html +++ b/doc/NgrokAPI/Models/ApiKey.html @@ -1128,7 +1128,7 @@ diff --git a/doc/NgrokAPI/Models/EndpointConfiguration.html b/doc/NgrokAPI/Models/EndpointConfiguration.html index f521257..5db1628 100644 --- a/doc/NgrokAPI/Models/EndpointConfiguration.html +++ b/doc/NgrokAPI/Models/EndpointConfiguration.html @@ -1356,7 +1356,7 @@ diff --git a/doc/NgrokAPI/Models/Listable.html b/doc/NgrokAPI/Models/Listable.html index 5b96a0a..a1883c8 100644 --- a/doc/NgrokAPI/Models/Listable.html +++ b/doc/NgrokAPI/Models/Listable.html @@ -924,7 +924,7 @@ diff --git a/doc/NgrokAPI/Models/ReservedDomain.html b/doc/NgrokAPI/Models/ReservedDomain.html index 33b4dda..73b2e65 100644 --- a/doc/NgrokAPI/Models/ReservedDomain.html +++ b/doc/NgrokAPI/Models/ReservedDomain.html @@ -2488,7 +2488,7 @@ diff --git a/doc/NgrokAPI/Models/TlsCertificate.html b/doc/NgrokAPI/Models/TlsCertificate.html index 304bcab..3aa05b7 100644 --- a/doc/NgrokAPI/Models/TlsCertificate.html +++ b/doc/NgrokAPI/Models/TlsCertificate.html @@ -1054,7 +1054,7 @@ diff --git a/doc/NgrokAPI/PagedIterator.html b/doc/NgrokAPI/PagedIterator.html index 017c4d6..ee50be9 100644 --- a/doc/NgrokAPI/PagedIterator.html +++ b/doc/NgrokAPI/PagedIterator.html @@ -621,7 +621,7 @@ diff --git a/doc/NgrokAPI/Services.html b/doc/NgrokAPI/Services.html index 3119498..23f86ea 100644 --- a/doc/NgrokAPI/Services.html +++ b/doc/NgrokAPI/Services.html @@ -107,7 +107,7 @@ diff --git a/doc/NgrokAPI/Services/ApiKeysClient.html b/doc/NgrokAPI/Services/ApiKeysClient.html index 1bb3b82..724bcd1 100644 --- a/doc/NgrokAPI/Services/ApiKeysClient.html +++ b/doc/NgrokAPI/Services/ApiKeysClient.html @@ -245,6 +245,30 @@ +
    +

    Delete an API key by ID.

    +
    + + + + +
  • + + + #delete!(id: nil) ⇒ nil + + + + + + + + + + + + +

    Delete an API key by ID.

    @@ -269,6 +293,30 @@ +
    +

    Get the details of an API key by ID.

    +
    + +
  • + + +
  • + + + #get!(id: nil) ⇒ NgrokAPI::Models::ApiKey + + + + + + + + + + + + +

    Get the details of an API key by ID.

    @@ -343,6 +391,30 @@ +
    +

    Update attributes of an API key by ID.

    +
    + +
  • + + +
  • + + + #update!(id: nil, description: nil, metadata: nil) ⇒ NgrokAPI::Models::ApiKey + + + + + + + + + + + + +

    Update attributes of an API key by ID.

    @@ -541,19 +613,13 @@ 31 32 33 -34 -35 -36 -37
  • +34
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 31
     
     def create(description: nil, metadata: nil)
    -  data = {}
    -  data[:description] = description if description
    -  data[:metadata] = metadata if metadata
    -  result = @client.post(PATH, data: data)
    +  result = @client.post(PATH, data: build_data(description: description, metadata: metadata))
       NgrokAPI::Models::ApiKey.new(client: self, result: result)
     end
    @@ -629,12 +695,12 @@
     
     
    -47
    -48
    -49
    +44 +45 +46 -
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 47
    +      
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 44
     
     def delete(id: nil)
       @client.delete("#{PATH}/#{id}")
    @@ -642,6 +708,89 @@
         
       
     
    +
    +    
    +      
    +

    + + #delete!(id: nil) ⇒ nil + + + + + +

    +
    + +

    Delete an API key by ID. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-api-keys-delete

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (nil) + + + + — +
      +

      result from delete request

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +55
    +56
    +57
    +
    +
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 55
    +
    +def delete!(id: nil)
    +  @client.delete("#{PATH}/#{id}", danger: true)
    +end
    +
    @@ -712,13 +861,13 @@
     
     
    -58
    -59
    -60
    -61
    +66 +67 +68 +69
    -
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 58
    +      
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 66
     
     def get(id: nil)
       result = @client.get("#{PATH}/#{id}")
    @@ -727,6 +876,91 @@
         
       
     
    +
    +    
    +      
    +

    + + #get!(id: nil) ⇒ NgrokAPI::Models::ApiKey + + + + + +

    +
    + +

    Get the details of an API key by ID. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-api-keys-get

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +78
    +79
    +80
    +81
    +
    +
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 78
    +
    +def get!(id: nil)
    +  result = @client.get("#{PATH}/#{id}", danger: true)
    +  NgrokAPI::Models::ApiKey.new(client: self, result: result)
    +end
    +
    @@ -823,18 +1057,18 @@
     
     
    -72
    -73
    -74
    -75
    -76
    -77
    -78
    -79
    -80
    +92 +93 +94 +95 +96 +97 +98 +99 +100
    -
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 72
    +      
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 92
     
     def list(before_id: nil, limit: nil, url: nil)
       result = @client.list(before_id: before_id, limit: limit, url: url, path: PATH)
    @@ -949,22 +1183,134 @@
           
     
     
    -93
    -94
    -95
    -96
    -97
    -98
    -99
    +113 +114 +115 +116
    -
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 93
    +      
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 113
     
     def update(id: nil, description: nil, metadata: nil)
    -  data = {}
    -  data[:description] = description if description
    -  data[:metadata] =  if 
    -  result = @client.patch("#{PATH}/#{id}", data: data)
    +  result = @client.patch("#{PATH}/#{id}", data: build_data(description: description, metadata: ))
    +  NgrokAPI::Models::ApiKey.new(client: self, result: result)
    +end
    + + + + + +
    +

    + + #update!(id: nil, description: nil, metadata: nil) ⇒ NgrokAPI::Models::ApiKey + + + + + +

    +
    + +

    Update attributes of an API key by ID.

    + +

    ngrok.com/docs/api#api-api-keys-update

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + +
    • + +
    • + + description + + + (string) + + + (defaults to: nil) + + + — +
      +

      human-readable description of what uses the API key to authenticate. optional, max 255 bytes.

      +
      + +
    • + +
    • + + metadata + + + (string) + + + (defaults to: nil) + + + — +
      +

      arbitrary user-defined data of this API key. optional, max 4096 bytes

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + @@ -977,7 +1323,7 @@ diff --git a/doc/NgrokAPI/Services/EndpointConfigurationsClient.html b/doc/NgrokAPI/Services/EndpointConfigurationsClient.html index af21be2..e8a6cf6 100644 --- a/doc/NgrokAPI/Services/EndpointConfigurationsClient.html +++ b/doc/NgrokAPI/Services/EndpointConfigurationsClient.html @@ -245,6 +245,30 @@ +
    +

    Delete an endpoint configuration.

    +
    + + + + +
  • + + + #delete!(id: nil) ⇒ nil + + + + + + + + + + + + +

    Delete an endpoint configuration.

    @@ -269,6 +293,30 @@ +
    +

    Returns detailed information about an endpoint configuration by ID.

    +
    + +
  • + + +
  • + + + #get!(id: nil) ⇒ NgrokAPI::Models::EndpointConfiguration + + + + + + + + + + + + +

    Returns detailed information about an endpoint configuration by ID.

    @@ -343,6 +391,30 @@ +
    +

    Updates an endpoint configuration.

    +
    + +
  • + + +
  • + + + #update!(id: nil, description: nil, metadata: nil, circuit_breaker: nil, compression: nil, request_headers: nil, response_headers: nil, ip_policy: nil, mutual_tls: nil, tls_termination: nil, webhook_validation: nil, oauth: nil, logging: nil, saml: nil, oidc: nil) ⇒ NgrokAPI::Models::EndpointConfiguration + + + + + + + + + + + + +

    Updates an endpoint configuration.

    @@ -936,6 +1008,89 @@
  • +
    +
    +
    +127
    +128
    +129
    +130
    +131
    +
    +
    # File 'lib/ngrokapi/services/api_keys_client.rb', line 127
    +
    +def update!(id: nil, description: nil, metadata: nil)
    +  data = build_data(description: description, metadata: )
    +  result = @client.patch("#{PATH}/#{id}", danger: true, data: data)
       NgrokAPI::Models::ApiKey.new(client: self, result: result)
     end
    +
    + +
    +

    + + #delete!(id: nil) ⇒ nil + + + + + +

    +
    + +

    Delete an endpoint configuration. Throw an exception if 404. This operation will fail if the endpoint configuration is still referenced by any reserved domain or reserved address.

    + +

    ngrok.com/docs/api#api-endpoint-configurations-delete

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (nil) + + + + — +
      +

      result from delete request

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +105
    +106
    +107
    +
    +
    # File 'lib/ngrokapi/services/endpoint_configurations_client.rb', line 105
    +
    +def delete!(id: nil)
    +  @client.delete("#{PATH}/#{id}", danger: true)
    +end
    +
    @@ -1006,13 +1161,13 @@
     
     
    -103
    -104
    -105
    -106
    +116 +117 +118 +119
    -
    # File 'lib/ngrokapi/services/endpoint_configurations_client.rb', line 103
    +      
    # File 'lib/ngrokapi/services/endpoint_configurations_client.rb', line 116
     
     def get(id: nil)
       result = @client.get("#{PATH}/#{id}")
    @@ -1021,6 +1176,91 @@
         
       
     
    +
    +    
    +      
    +

    + + #get!(id: nil) ⇒ NgrokAPI::Models::EndpointConfiguration + + + + + +

    +
    + +

    Returns detailed information about an endpoint configuration by ID. Throw an execption if 404.

    + +

    ngrok.com/docs/api#api-endpoint-configurations-get

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +128
    +129
    +130
    +131
    +
    +
    # File 'lib/ngrokapi/services/endpoint_configurations_client.rb', line 128
    +
    +def get!(id: nil)
    +  result = @client.get("#{PATH}/#{id}", danger: true)
    +  NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result)
    +end
    +
    @@ -1117,18 +1357,18 @@
     
     
    -117
    -118
    -119
    -120
    -121
    -122
    -123
    -124
    -125
    +142 +143 +144 +145 +146 +147 +148 +149 +150
    -
    # File 'lib/ngrokapi/services/endpoint_configurations_client.rb', line 117
    +      
    # File 'lib/ngrokapi/services/endpoint_configurations_client.rb', line 142
     
     def list(before_id: nil, limit: nil, url: nil)
       result = @client.list(before_id: before_id, limit: limit, url: url, path: PATH)
    @@ -1464,31 +1704,6 @@
           
     
     
    -152
    -153
    -154
    -155
    -156
    -157
    -158
    -159
    -160
    -161
    -162
    -163
    -164
    -165
    -166
    -167
    -168
    -169
    -170
    -171
    -172
    -173
    -174
    -175
    -176
     177
     178
     179
    @@ -1498,10 +1713,36 @@
     183
     184
     185
    -186
    +186 +187 +188 +189 +190 +191 +192 +193 +194 +195 +196 +197 +198 +199 +200 +201 +202 +203 +204 +205 +206 +207 +208 +209 +210 +211 +212
    -
    # File 'lib/ngrokapi/services/endpoint_configurations_client.rb', line 152
    +      
    # File 'lib/ngrokapi/services/endpoint_configurations_client.rb', line 177
     
     def update(
       id: nil,
    @@ -1520,27 +1761,429 @@
       saml: nil,
       oidc: nil
     )
    -  data = {}
    -  data[:description] = description if description
    -  data[:metadata] =  if 
    -  data[:circuit_breaker] = circuit_breaker if circuit_breaker
    -  data[:compression] = compression if compression
    -  data[:request_headers] = request_headers if request_headers
    -  data[:response_headers] = response_headers if response_headers
    -  data[:ip_policy] = ip_policy if ip_policy
    -  data[:mutual_tls] = mutual_tls if mutual_tls
    -  data[:tls_termination] = tls_termination if tls_termination
    -  data[:webhook_validation] = webhook_validation if webhook_validation
    -  data[:oauth] = oauth if oauth
    -  data[:logging] = logging if logging
    -  data[:saml] = saml if saml
    -  data[:oidc] = oidc if oidc
    +  data = build_data(
    +    description: description,
    +    metadata: ,
    +    circuit_breaker: circuit_breaker,
    +    compression: compression,
    +    request_headers: request_headers,
    +    response_headers: response_headers,
    +    ip_policy: ip_policy,
    +    mutual_tls: mutual_tls,
    +    tls_termination: tls_termination,
    +    webhook_validation: webhook_validation,
    +    oauth: oauth,
    +    logging: logging,
    +    saml: saml,
    +    oidc: oidc
    +  )
       result = @client.patch("#{PATH}/#{id}", data: data)
       NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result)
     end
    + + +
    +

    + + #update!(id: nil, description: nil, metadata: nil, circuit_breaker: nil, compression: nil, request_headers: nil, response_headers: nil, ip_policy: nil, mutual_tls: nil, tls_termination: nil, webhook_validation: nil, oauth: nil, logging: nil, saml: nil, oidc: nil) ⇒ NgrokAPI::Models::EndpointConfiguration + + + + + +

    +
    + +

    Updates an endpoint configuration. If a module is not specified in the update, it will not be modified. However, each module configuration that is specified will completely replace the existing value. There is no way to delete an existing module via this API, instead use the delete module API. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-endpoint-configurations-update

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      unique identifier of this endpoint configuration

      +
      + +
    • + +
    • + + description + + + (string) + + + (defaults to: nil) + + + — +
      +

      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

      +
      + +
    • + +
    • + + metadata + + + (string) + + + (defaults to: nil) + + + — +
      +

      arbitrary user-defined machine-readable data of this endpoint configuration. Optional, max 4096 bytes.

      +
      + +
    • + +
    • + + circuit_breaker + + + (string) + + + (defaults to: nil) + + + — +
      +

      circuit breaker module configuration

      +
      + +
    • + +
    • + + compression + + + (string) + + + (defaults to: nil) + + + — +
      +

      compression module configuration

      +
      + +
    • + +
    • + + request_headers + + + (string) + + + (defaults to: nil) + + + — +
      +

      request headers module configuration

      +
      + +
    • + +
    • + + response_headers + + + (string) + + + (defaults to: nil) + + + — +
      +

      response headers module configuration

      +
      + +
    • + +
    • + + ip_policy + + + (string) + + + (defaults to: nil) + + + — +
      +

      ip policy module configuration

      +
      + +
    • + +
    • + + mutual_tls + + + (string) + + + (defaults to: nil) + + + — +
      +

      mutual TLS module configuration

      +
      + +
    • + +
    • + + tls_termination + + + (string) + + + (defaults to: nil) + + + — +
      +

      TLS termination module configuration

      +
      + +
    • + +
    • + + webhook_validation + + + (string) + + + (defaults to: nil) + + + — +
      +

      webhook validation module configuration

      +
      + +
    • + +
    • + + oauth + + + (string) + + + (defaults to: nil) + + + — +
      +

      oauth module configuration

      +
      + +
    • + +
    • + + logging + + + (string) + + + (defaults to: nil) + + + — +
      +

      logging module configuration

      +
      + +
    • + +
    • + + saml + + + (string) + + + (defaults to: nil) + + + — +
      +

      saml module configuration

      +
      + +
    • + +
    • + + oidc + + + (string) + + + (defaults to: nil) + + + — +
      +

      oidc module configuration

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +238
    +239
    +240
    +241
    +242
    +243
    +244
    +245
    +246
    +247
    +248
    +249
    +250
    +251
    +252
    +253
    +254
    +255
    +256
    +257
    +258
    +259
    +260
    +261
    +262
    +263
    +264
    +265
    +266
    +267
    +268
    +269
    +270
    +271
    +272
    +273
    +
    +
    # File 'lib/ngrokapi/services/endpoint_configurations_client.rb', line 238
    +
    +def update!(
    +  id: nil,
    +  description: nil,
    +  metadata: nil,
    +  circuit_breaker: nil,
    +  compression: nil,
    +  request_headers: nil,
    +  response_headers: nil,
    +  ip_policy: nil,
    +  mutual_tls: nil,
    +  tls_termination: nil,
    +  webhook_validation: nil,
    +  oauth: nil,
    +  logging: nil,
    +  saml: nil,
    +  oidc: nil
    +)
    +  data = build_data(
    +    description: description,
    +    metadata: ,
    +    circuit_breaker: circuit_breaker,
    +    compression: compression,
    +    request_headers: request_headers,
    +    response_headers: response_headers,
    +    ip_policy: ip_policy,
    +    mutual_tls: mutual_tls,
    +    tls_termination: tls_termination,
    +    webhook_validation: webhook_validation,
    +    oauth: oauth,
    +    logging: logging,
    +    saml: saml,
    +    oidc: oidc
    +  )
    +  result = @client.patch("#{PATH}/#{id}", danger: true, data: data)
    +  NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result)
    +end
    +
    @@ -1548,7 +2191,7 @@ diff --git a/doc/NgrokAPI/Services/ReservedDomainsClient.html b/doc/NgrokAPI/Services/ReservedDomainsClient.html index 091ea37..b9240fe 100644 --- a/doc/NgrokAPI/Services/ReservedDomainsClient.html +++ b/doc/NgrokAPI/Services/ReservedDomainsClient.html @@ -245,6 +245,30 @@ +
    +

    Delete a reserved domain.

    +
    + + + + +
  • + + + #delete!(id: nil) ⇒ nil + + + + + + + + + + + + +

    Delete a reserved domain.

    @@ -269,6 +293,30 @@ +
    +

    Detach the certificate attached from a reserved domain.

    +
    + +
  • + + +
  • + + + #delete_certificate!(id: nil) ⇒ nil + + + + + + + + + + + + +

    Detach the certificate attached from a reserved domain.

    @@ -293,6 +341,30 @@ +
    +

    Detach the certificate management policy attached from a reserved domain.

    +
    + +
  • + + +
  • + + + #delete_certificate_management_policy!(id: nil) ⇒ nil + + + + + + + + + + + + +

    Detach the certificate management policy attached from a reserved domain.

    @@ -317,6 +389,30 @@ +
    +

    Detach the http endpoint configuration attached from a reserved domain.

    +
    + +
  • + + +
  • + + + #delete_http_endpoint_config!(id: nil) ⇒ nil + + + + + + + + + + + + +

    Detach the http endpoint configuration attached from a reserved domain.

    @@ -341,6 +437,30 @@ +
    +

    Detach the https endpoint configuration attached from a reserved domain.

    +
    + +
  • + + +
  • + + + #delete_https_endpoint_config!(id: nil) ⇒ nil + + + + + + + + + + + + +

    Detach the https endpoint configuration attached from a reserved domain.

    @@ -365,6 +485,30 @@ +
    +

    Get the details of a reserved domain.

    +
    + +
  • + + +
  • + + + #get!(id: nil) ⇒ NgrokAPI::Models::ReservedDomain + + + + + + + + + + + + +

    Get the details of a reserved domain.

    @@ -439,6 +583,30 @@ +
    +

    Update the attributes of a reserved domain.

    +
    + +
  • + + +
  • + + + #update!(id: nil, certificate_id: nil, certificate_management_policy: nil, description: nil, http_endpoint_configuration_id: nil, https_endpoint_configuration_id: nil, metadata: nil) ⇒ NgrokAPI::Models::ReservedDomain + + + + + + + + + + + + +

    Update the attributes of a reserved domain.

    @@ -878,6 +1046,89 @@ + + +
    +

    + + #delete!(id: nil) ⇒ nil + + + + + +

    +
    + +

    Delete a reserved domain. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-reserved-domains-delete

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (nil) + + + + — +
      +

      result from delete request

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +80
    +81
    +82
    +
    +
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 80
    +
    +def delete!(id: nil)
    +  @client.delete("#{PATH}/#{id}", danger: true)
    +end
    +
    @@ -948,12 +1199,12 @@
     
     
    -153
    -154
    -155
    +205 +206 +207
  • -
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 153
    +      
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 205
     
     def delete_certificate(id: nil)
       @client.delete("#{PATH}/#{id}/certificate")
    @@ -961,6 +1212,89 @@
         
       
     
    +
    +    
    +      
    +

    + + #delete_certificate!(id: nil) ⇒ nil + + + + + +

    +
    + +

    Detach the certificate attached from a reserved domain. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-reserved-domains-delete-certificate

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (nil) + + + + — +
      +

      result from delete request

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +216
    +217
    +218
    +
    +
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 216
    +
    +def delete_certificate!(id: nil)
    +  @client.delete("#{PATH}/#{id}/certificate", danger: true)
    +end
    +
    @@ -1031,12 +1365,12 @@
     
     
    -164
    -165
    -166
    +227 +228 +229
    -
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 164
    +      
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 227
     
     def delete_certificate_management_policy(id: nil)
       @client.delete("#{PATH}/#{id}/certificate_management_policy")
    @@ -1044,6 +1378,89 @@
         
       
     
    +
    +    
    +      
    +

    + + #delete_certificate_management_policy!(id: nil) ⇒ nil + + + + + +

    +
    + +

    Detach the certificate management policy attached from a reserved domain.

    + +

    ngrok.com/docs/api#api-reserved-domains-delete-certificate-management-policy

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (nil) + + + + — +
      +

      result from delete request

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +238
    +239
    +240
    +
    +
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 238
    +
    +def delete_certificate_management_policy!(id: nil)
    +  @client.delete("#{PATH}/#{id}/certificate_management_policy", danger: true)
    +end
    +
    @@ -1114,12 +1531,12 @@
     
     
    -175
    -176
    -177
    +249 +250 +251
    -
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 175
    +      
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 249
     
     def delete_http_endpoint_config(id: nil)
       @client.delete("#{PATH}/#{id}/http_endpoint_configuration")
    @@ -1127,6 +1544,89 @@
         
       
     
    +
    +    
    +      
    +

    + + #delete_http_endpoint_config!(id: nil) ⇒ nil + + + + + +

    +
    + +

    Detach the http endpoint configuration attached from a reserved domain. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-reserved-domains-delete-http-endpoint-config

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (nil) + + + + — +
      +

      result from delete request

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +260
    +261
    +262
    +
    +
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 260
    +
    +def delete_http_endpoint_config!(id: nil)
    +  @client.delete("#{PATH}/#{id}/http_endpoint_configuration", danger: true)
    +end
    +
    @@ -1197,12 +1697,12 @@
     
     
    -186
    -187
    -188
    +271 +272 +273
    -
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 186
    +      
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 271
     
     def delete_https_endpoint_config(id: nil)
       @client.delete("#{PATH}/#{id}/https_endpoint_configuration")
    @@ -1210,6 +1710,89 @@
         
       
     
    +
    +    
    +      
    +

    + + #delete_https_endpoint_config!(id: nil) ⇒ nil + + + + + +

    +
    + +

    Detach the https endpoint configuration attached from a reserved domain. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-reserved-domains-delete-https-endpoint-config

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (nil) + + + + — +
      +

      result from delete request

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +282
    +283
    +284
    +
    +
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 282
    +
    +def delete_https_endpoint_config!(id: nil)
    +  @client.delete("#{PATH}/#{id}/https_endpoint_configuration", danger: true)
    +end
    +
    @@ -1280,13 +1863,13 @@
     
     
    -80
    -81
    -82
    -83
    +91 +92 +93 +94
    -
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 80
    +      
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 91
     
     def get(id: nil)
       result = @client.get("#{PATH}/#{id}")
    @@ -1295,6 +1878,91 @@
         
       
     
    +
    +    
    +      
    +

    + + #get!(id: nil) ⇒ NgrokAPI::Models::ReservedDomain + + + + + +

    +
    + +

    Get the details of a reserved domain. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-reserved-domains-get

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +103
    +104
    +105
    +106
    +
    +
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 103
    +
    +def get!(id: nil)
    +  result = @client.get!("#{PATH}/#{id}")
    +  NgrokAPI::Models::ReservedDomain.new(client: self, result: result)
    +end
    +
    @@ -1391,18 +2059,18 @@
     
     
    -94
    -95
    -96
    -97
    -98
    -99
    -100
    -101
    -102
    +117 +118 +119 +120 +121 +122 +123 +124 +125
    -
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 94
    +      
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 117
     
     def list(before_id: nil, limit: nil, url: nil)
       result = @client.list(before_id: before_id, limit: limit, url: url, path: PATH)
    @@ -1589,34 +2257,29 @@
           
     
     
    -119
    -120
    -121
    -122
    -123
    -124
    -125
    -126
    -127
    -128
    -129
    -130
    -131
    -132
    -133
    -134
    -135
    -136
    -137
    -138
    -139
    -140
    -141
     142
    -143
    +143 +144 +145 +146 +147 +148 +149 +150 +151 +152 +153 +154 +155 +156 +157 +158 +159 +160 +161
    -
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 119
    +      
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 142
     
     def update(
       id: nil,
    @@ -1627,25 +2290,240 @@
       https_endpoint_configuration_id: nil,
       metadata: nil
     )
    -  data = {}
    -  data[:certificate_id] = certificate_id if certificate_id
    -  if certificate_management_policy
    -    data[:certificate_management_policy] = certificate_management_policy
    -  end
    -  data[:description] = description if description
    -  if http_endpoint_configuration_id
    -    data[:http_endpoint_configuration_id] = http_endpoint_configuration_id
    -  end
    -  if https_endpoint_configuration_id
    -    data[:https_endpoint_configuration_id] = https_endpoint_configuration_id
    -  end
    -  data[:metadata] =  if 
    +  data = build_data(
    +    description: description,
    +    metadata: ,
    +    http_endpoint_configuration_id: http_endpoint_configuration_id,
    +    https_endpoint_configuration_id: https_endpoint_configuration_id,
    +    certificate_id: certificate_id,
    +    certificate_management_policy: certificate_management_policy
    +  )
       result = @client.patch("#{PATH}/#{id}", data: data)
       NgrokAPI::Models::ReservedDomain.new(client: self, result: result)
     end
    + + +
    +

    + + #update!(id: nil, certificate_id: nil, certificate_management_policy: nil, description: nil, http_endpoint_configuration_id: nil, https_endpoint_configuration_id: nil, metadata: nil) ⇒ NgrokAPI::Models::ReservedDomain + + + + + +

    +
    + +

    Update the attributes of a reserved domain. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-reserved-domains-update

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + +
    • + +
    • + + description + + + (string) + + + (defaults to: nil) + + + — +
      +

      human-readable description of what this reserved domain will be used for

      +
      + +
    • + +
    • + + metadata + + + (string) + + + (defaults to: nil) + + + — +
      +

      arbitrary user-defined machine-readable data of this reserved domain. Optional, max 4096 bytes.

      +
      + +
    • + +
    • + + http_endpoint_configuration_id + + + (string) + + + (defaults to: nil) + + + — +
      +

      ID of an endpoint configuration of type http that will be used to handle inbound http traffic to this domain

      +
      + +
    • + +
    • + + https_endpoint_configuration_id + + + (string) + + + (defaults to: nil) + + + — +
      +

      ID of an endpoint configuration of type https that will be used to handle inbound https traffic to this domain

      +
      + +
    • + +
    • + + certificate_id + + + (string) + + + (defaults to: nil) + + + — +
      +

      ID of a user-uploaded TLS certificate to use for connections to targeting this domain. Optional, mutually exclusive with “certificate_management_policy“.

      +
      + +
    • + +
    • + + certificate_management_policy + + + (string) + + + (defaults to: nil) + + + — +
      +

      configuration for automatic management of TLS certificates for this domain, or null if automatic management is disabled. Optional, mutually exclusive with “certificate_id“.

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +176
    +177
    +178
    +179
    +180
    +181
    +182
    +183
    +184
    +185
    +186
    +187
    +188
    +189
    +190
    +191
    +192
    +193
    +194
    +195
    +
    +
    # File 'lib/ngrokapi/services/reserved_domains_client.rb', line 176
    +
    +def update!(
    +  id: nil,
    +  certificate_id: nil,
    +  certificate_management_policy: nil,
    +  description: nil,
    +  http_endpoint_configuration_id: nil,
    +  https_endpoint_configuration_id: nil,
    +  metadata: nil
    +)
    +  data = build_data(
    +    description: description,
    +    metadata: ,
    +    http_endpoint_configuration_id: http_endpoint_configuration_id,
    +    https_endpoint_configuration_id: https_endpoint_configuration_id,
    +    certificate_id: certificate_id,
    +    certificate_management_policy: certificate_management_policy
    +  )
    +  result = @client.patch("#{PATH}/#{id}", danger: true, data: data)
    +  NgrokAPI::Models::ReservedDomain.new(client: self, result: result)
    +end
    +
    @@ -1653,7 +2531,7 @@ diff --git a/doc/NgrokAPI/Services/TlsCertificatesClient.html b/doc/NgrokAPI/Services/TlsCertificatesClient.html index 7189776..ee410c3 100644 --- a/doc/NgrokAPI/Services/TlsCertificatesClient.html +++ b/doc/NgrokAPI/Services/TlsCertificatesClient.html @@ -245,6 +245,30 @@ +
    +

    Delete a TLS certificate by ID.

    +
    + + + + +
  • + + + #delete!(id: nil) ⇒ nil + + + + + + + + + + + + +

    Delete a TLS certificate by ID.

    @@ -269,6 +293,30 @@ +
    +

    Get detailed information about a TLS certificate by ID.

    +
    + +
  • + + +
  • + + + #get!(id: nil) ⇒ NgrokAPI::Models::TlsCertificate + + + + + + + + + + + + +

    Get detailed information about a TLS certificate by ID.

    @@ -343,6 +391,30 @@ +
    +

    Update attributes of a TLS Certificate by ID.

    +
    + +
  • + + +
  • + + + #update!(id: nil, description: nil, metadata: nil) ⇒ NgrokAPI::Models::TlsCertificate + + + + + + + + + + + + +

    Update attributes of a TLS Certificate by ID.

    @@ -694,6 +766,89 @@ + + +
    +

    + + #delete!(id: nil) ⇒ nil + + + + + +

    +
    + +

    Delete a TLS certificate by ID. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-tls-certificates-delete

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (nil) + + + + — +
      +

      result from delete request

      +
      + +
    • + +
    + +
    + + + + +
    +
    +
    +
    +68
    +69
    +70
    +
    +
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 68
    +
    +def delete!(id: nil)
    +  @client.delete("#{PATH}/#{id}", danger: true)
    +end
    +
    @@ -764,13 +919,13 @@
     
     
    -68
    -69
    -70
    -71
    +79 +80 +81 +82
  • -
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 68
    +      
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 79
     
     def get(id: nil)
       result = @client.get("#{PATH}/#{id}")
    @@ -779,6 +934,91 @@
         
       
     
    +
    +    
    +      
    +

    + + #get!(id: nil) ⇒ NgrokAPI::Models::TlsCertificate + + + + + +

    +
    + +

    Get detailed information about a TLS certificate by ID. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-tls-certificates-get

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + + — +
      +

      a resource identifier

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +91
    +92
    +93
    +94
    +
    +
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 91
    +
    +def get!(id: nil)
    +  result = @client.get("#{PATH}/#{id}", danger: true)
    +  NgrokAPI::Models::TlsCertificate.new(client: self, result: result)
    +end
    +
    @@ -875,18 +1115,18 @@
     
     
    -82
    -83
    -84
    -85
    -86
    -87
    -88
    -89
    -90
    +105 +106 +107 +108 +109 +110 +111 +112 +113
    -
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 82
    +      
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 105
     
     def list(before_id: nil, limit: nil, url: nil)
       result = @client.list(before_id: before_id, limit: limit, url: url, path: PATH)
    @@ -1001,20 +1241,20 @@
           
     
     
    -103
    -104
    -105
    -106
    -107
    -108
    -109
    -110
    -111
    -112
    -113
    +126 +127 +128 +129 +130 +131 +132 +133 +134 +135 +136
    -
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 103
    +      
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 126
     
     def update(
       id: nil,
    @@ -1030,6 +1270,136 @@
         
       
     
    +
    +    
    +      
    +

    + + #update!(id: nil, description: nil, metadata: nil) ⇒ NgrokAPI::Models::TlsCertificate + + + + + +

    +
    + +

    Update attributes of a TLS Certificate by ID. Throw an exception if 404.

    + +

    ngrok.com/docs/api#api-tls-certificates-update

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + id + + + (string) + + + (defaults to: nil) + + +
    • + +
    • + + description + + + (string) + + + (defaults to: nil) + + + — +
      +

      human-readable description of this TLS certificate. optional, max 255 bytes.

      +
      + +
    • + +
    • + + metadata + + + (string) + + + (defaults to: nil) + + + — +
      +

      arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes.

      +
      + +
    • + +
    + +

    Returns:

    + + +
    + + + + +
    +
    +
    +
    +147
    +148
    +149
    +150
    +151
    +152
    +153
    +154
    +155
    +156
    +157
    +
    +
    # File 'lib/ngrokapi/services/tls_certificates_client.rb', line 147
    +
    +def update!(
    +  id: nil,
    +  description: nil,
    +  metadata: nil
    +)
    +  data = {}
    +  data[:description] = description if description
    +  data[:metadata] =  if 
    +  result = @client.patch("#{PATH}/#{id}", danger: true, data: data)
    +  NgrokAPI::Models::TlsCertificate.new(client: self, result: result)
    +end
    +
    @@ -1037,7 +1407,7 @@ diff --git a/doc/_index.html b/doc/_index.html index 5fed389..528c017 100644 --- a/doc/_index.html +++ b/doc/_index.html @@ -131,6 +131,13 @@ +
  • + Errors + + (NgrokAPI) + +
  • + @@ -189,6 +196,13 @@ +
  • + NotFoundError + + (NgrokAPI::Errors) + +
  • + @@ -278,7 +292,7 @@ diff --git a/doc/class_list.html b/doc/class_list.html index 5d4515e..113c9ec 100644 --- a/doc/class_list.html +++ b/doc/class_list.html @@ -43,7 +43,7 @@ diff --git a/doc/file.README.html b/doc/file.README.html index 074c9f0..aabef92 100644 --- a/doc/file.README.html +++ b/doc/file.README.html @@ -116,7 +116,7 @@ diff --git a/doc/index.html b/doc/index.html index 335a06b..d206e4b 100644 --- a/doc/index.html +++ b/doc/index.html @@ -116,7 +116,7 @@ diff --git a/doc/method_list.html b/doc/method_list.html index 0a84742..288e251 100644 --- a/doc/method_list.html +++ b/doc/method_list.html @@ -356,6 +356,38 @@ +
  • +
    + #delete! + NgrokAPI::Services::ApiKeysClient +
    +
  • + + +
  • +
    + #delete! + NgrokAPI::Services::ReservedDomainsClient +
    +
  • + + +
  • +
    + #delete! + NgrokAPI::Services::TlsCertificatesClient +
    +
  • + + +
  • +
    + #delete! + NgrokAPI::Services::EndpointConfigurationsClient +
    +
  • + +
  • #delete_certificate @@ -374,13 +406,21 @@
  • - #delete_certificate_management_policy - NgrokAPI::Models::ReservedDomain + #delete_certificate! + NgrokAPI::Services::ReservedDomainsClient
  • +
    + #delete_certificate_management_policy + NgrokAPI::Models::ReservedDomain +
    +
  • + + +
  • #delete_certificate_management_policy NgrokAPI::Services::ReservedDomainsClient @@ -388,6 +428,14 @@
  • +
  • +
    + #delete_certificate_management_policy! + NgrokAPI::Services::ReservedDomainsClient +
    +
  • + +
  • #delete_http_endpoint_config @@ -406,13 +454,21 @@
  • - #delete_https_endpoint_config - NgrokAPI::Models::ReservedDomain + #delete_http_endpoint_config! + NgrokAPI::Services::ReservedDomainsClient
  • +
    + #delete_https_endpoint_config + NgrokAPI::Models::ReservedDomain +
    +
  • + + +
  • #delete_https_endpoint_config NgrokAPI::Services::ReservedDomainsClient @@ -420,6 +476,14 @@
  • +
  • +
    + #delete_https_endpoint_config! + NgrokAPI::Services::ReservedDomainsClient +
    +
  • + +
  • #description @@ -508,6 +572,38 @@
  • +
  • +
    + #get! + NgrokAPI::Services::ApiKeysClient +
    +
  • + + +
  • +
    + #get! + NgrokAPI::Services::ReservedDomainsClient +
    +
  • + + +
  • +
    + #get! + NgrokAPI::Services::TlsCertificatesClient +
    +
  • + + +
  • +
    + #get! + NgrokAPI::Services::EndpointConfigurationsClient +
    +
  • + +
  • #get_next @@ -605,6 +701,14 @@
  • +
    + #initialize + NgrokAPI::Errors::NotFoundError +
    +
  • + + +
  • #initialize NgrokAPI::Models::ReservedDomain @@ -612,7 +716,7 @@
  • -
  • +
  • #initialize NgrokAPI::Models::TlsCertificate @@ -620,7 +724,7 @@
  • -
  • +
  • #initialize NgrokAPI::Services::ApiKeysClient @@ -628,7 +732,7 @@
  • -
  • +
  • #initialize NgrokAPI::Models::EndpointConfiguration @@ -636,7 +740,7 @@
  • -
  • +
  • #initialize NgrokAPI::Services::ReservedDomainsClient @@ -644,7 +748,7 @@
  • -
  • +
  • #initialize NgrokAPI::Services::TlsCertificatesClient @@ -652,7 +756,7 @@
  • -
  • +
  • #initialize NgrokAPI::Services::EndpointConfigurationsClient @@ -660,7 +764,7 @@
  • -
  • +
  • #items NgrokAPI::Models::Listable @@ -668,7 +772,7 @@
  • -
  • +
  • #iter NgrokAPI::Models::Listable @@ -676,7 +780,7 @@
  • -
  • +
  • #klass NgrokAPI::Models::Listable @@ -684,7 +788,7 @@
  • -
  • +
  • #list NgrokAPI::HttpClient @@ -692,7 +796,7 @@
  • -
  • +
  • #list NgrokAPI::Services::ApiKeysClient @@ -700,7 +804,7 @@
  • -
  • +
  • #list NgrokAPI::Services::ReservedDomainsClient @@ -708,7 +812,7 @@
  • -
  • +
  • #list NgrokAPI::Services::TlsCertificatesClient @@ -716,7 +820,7 @@
  • -
  • +
  • #list NgrokAPI::Services::EndpointConfigurationsClient @@ -724,7 +828,7 @@
  • -
  • +
  • #list_property NgrokAPI::PagedIterator @@ -732,7 +836,7 @@
  • -
  • +
  • #list_property NgrokAPI::Models::Listable @@ -740,7 +844,7 @@
  • -
  • +
  • #metadata NgrokAPI::Models::ApiKey @@ -748,7 +852,7 @@
  • -
  • +
  • #metadata NgrokAPI::Models::ReservedDomain @@ -756,7 +860,7 @@
  • -
  • +
  • #metadata NgrokAPI::Models::TlsCertificate @@ -764,7 +868,7 @@
  • -
  • +
  • #metadata NgrokAPI::Models::EndpointConfiguration @@ -772,7 +876,7 @@
  • -
  • +
  • #n NgrokAPI::PagedIterator @@ -780,7 +884,7 @@
  • -
  • +
  • #next_page_uri NgrokAPI::Models::Listable @@ -788,7 +892,7 @@
  • -
  • +
  • #page NgrokAPI::PagedIterator @@ -796,7 +900,7 @@
  • -
  • +
  • #patch NgrokAPI::HttpClient @@ -804,7 +908,7 @@
  • -
  • +
  • #post NgrokAPI::HttpClient @@ -812,7 +916,7 @@
  • -
  • +
  • #region NgrokAPI::Models::ReservedDomain @@ -820,7 +924,7 @@
  • -
  • +
  • #reserved_domains NgrokAPI::Client @@ -828,6 +932,14 @@
  • +
  • +
    + #response + NgrokAPI::Errors::NotFoundError +
    +
  • + +
  • #restore_certificate @@ -1020,6 +1132,38 @@
  • +
  • +
    + #update! + NgrokAPI::Services::ApiKeysClient +
    +
  • + + +
  • +
    + #update! + NgrokAPI::Services::ReservedDomainsClient +
    +
  • + + +
  • +
    + #update! + NgrokAPI::Services::TlsCertificatesClient +
    +
  • + + +
  • +
    + #update! + NgrokAPI::Services::EndpointConfigurationsClient +
    +
  • + +
  • #uri diff --git a/doc/top-level-namespace.html b/doc/top-level-namespace.html index d346446..f054d0b 100644 --- a/doc/top-level-namespace.html +++ b/doc/top-level-namespace.html @@ -100,7 +100,7 @@
    diff --git a/lib/ngrokapi/errors/not_found_error.rb b/lib/ngrokapi/errors/not_found_error.rb new file mode 100644 index 0000000..b35d1ef --- /dev/null +++ b/lib/ngrokapi/errors/not_found_error.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module NgrokAPI + module Errors + ## + # Error representing a 404 not found + class NotFoundError < StandardError + attr_reader :response + + def initialize(msg: "Resource not found", response: nil) + @response = response + super(msg) + end + end + end +end diff --git a/lib/ngrokapi/http_client.rb b/lib/ngrokapi/http_client.rb index d07f9ae..6af660c 100644 --- a/lib/ngrokapi/http_client.rb +++ b/lib/ngrokapi/http_client.rb @@ -19,24 +19,26 @@ module NgrokAPI ## # Make a DELETE request to a given URI # - # @param [string] path URL resource path + # @param [string] path URL resource path. + # @param [boolean] danger determine if we should throw an exception on 404 or not # @return [nil] - def delete(path) + def delete(path, danger: false) uri = get_uri(path) req = Net::HTTP::Delete.new(uri, headers) - json_do(uri, req) + json_do(uri, req, danger: danger) end ## # Make a GET request to a given URI with optional data # # @param [string] path URL resource path + # @param [boolean] danger determine if we should throw an exception on 404 or not # @param [hash] data hash which will be converted to query parameters or form data # @return [json] response body - def get(path, data: {}) + def get(path, danger: false, data: {}) uri = get_uri(path, data: data) req = Net::HTTP::Get.new(uri, headers) - json_do(uri, req) + json_do(uri, req, danger: danger) end ## @@ -62,24 +64,26 @@ module NgrokAPI # Make a PATCH request to a given URI with optional data # # @param [string] path URL resource path + # @param [boolean] danger determine if we should throw an exception on 404 or not # @param [hash] data hash which will be converted to query parameters or form data # @return [json] response body - def patch(path, data: {}) + def patch(path, danger: false, data: {}) uri = get_uri(path) req = Net::HTTP::Patch.new(uri, headers_with_json) - json_do(uri, req, data: data.to_json) + json_do(uri, req, danger: danger, data: data.to_json) end ## # Make a POST request to a given URI with optional data # # @param [string] path URL resource path + # @param [boolean] danger determine if we should throw an exception on 404 or not # @param [hash] data hash which will be converted to query parameters or form data # @return [json] response body - def post(path, data: {}) + def post(path, danger: false, data: {}) uri = get_uri(path) req = Net::HTTP::Post.new(uri, headers_with_json) - json_do(uri, req, data: data.to_json) + json_do(uri, req, danger: danger, data: data.to_json) end private @@ -95,10 +99,13 @@ module NgrokAPI headers.merge({ 'Content-Type': 'application/json' }) end - def json_do(uri, req, data: nil) + def json_do(uri, req, danger: false, data: nil) resp = Net::HTTP.start(uri.hostname, uri.port, req_options(uri)) do |http| http.request(req, data) end + if danger && resp.code == "404" + raise NgrokAPI::Errors::NotFoundError.new(response: resp) + end if resp.body && resp.body != '' JSON.parse(resp.body) end diff --git a/lib/ngrokapi/services/api_keys_client.rb b/lib/ngrokapi/services/api_keys_client.rb index 2b74f84..cfc5824 100644 --- a/lib/ngrokapi/services/api_keys_client.rb +++ b/lib/ngrokapi/services/api_keys_client.rb @@ -29,10 +29,7 @@ module NgrokAPI # # https://ngrok.com/docs/api#api-api-keys-create def create(description: nil, metadata: nil) - data = {} - data[:description] = description if description - data[:metadata] = metadata if metadata - result = @client.post(PATH, data: data) + result = @client.post(PATH, data: build_data(description: description, metadata: metadata)) NgrokAPI::Models::ApiKey.new(client: self, result: result) end # rubocop:enable LineLength @@ -48,6 +45,17 @@ module NgrokAPI @client.delete("#{PATH}/#{id}") end + ## + # Delete an API key by ID. Throw an exception if 404. + # + # @param [string] id a resource identifier + # @return [nil] result from delete request + # + # https://ngrok.com/docs/api#api-api-keys-delete + def delete!(id: nil) + @client.delete("#{PATH}/#{id}", danger: true) + end + ## # Get the details of an API key by ID. # @@ -60,6 +68,18 @@ module NgrokAPI NgrokAPI::Models::ApiKey.new(client: self, result: result) end + ## + # Get the details of an API key by ID. Throw an exception if 404. + # + # @param [string] id a resource identifier + # @return [NgrokAPI::Models::ApiKey] result from get request + # + # https://ngrok.com/docs/api#api-api-keys-get + def get!(id: nil) + result = @client.get("#{PATH}/#{id}", danger: true) + NgrokAPI::Models::ApiKey.new(client: self, result: result) + end + ## # List all API keys owned by this account. # @@ -91,13 +111,34 @@ module NgrokAPI # # https://ngrok.com/docs/api#api-api-keys-update def update(id: nil, description: nil, metadata: nil) - data = {} - data[:description] = description if description - data[:metadata] = metadata if metadata - result = @client.patch("#{PATH}/#{id}", data: data) + result = @client.patch("#{PATH}/#{id}", data: build_data(description: description, metadata: metadata)) + NgrokAPI::Models::ApiKey.new(client: self, result: result) + end + + ## + # Update attributes of an API key by ID. + # + # @param [string] id + # @param [string] description human-readable description of what uses the API key to authenticate. optional, max 255 bytes. + # @param [string] metadata arbitrary user-defined data of this API key. optional, max 4096 bytes + # @return [NgrokAPI::Models::ApiKey] result from update request + # + # https://ngrok.com/docs/api#api-api-keys-update + def update!(id: nil, description: nil, metadata: nil) + data = build_data(description: description, metadata: metadata) + result = @client.patch("#{PATH}/#{id}", danger: true, data: data) NgrokAPI::Models::ApiKey.new(client: self, result: result) end # rubocop:enable LineLength + + private + + def build_data(description: nil, metadata: nil) + data = {} + data[:description] = description if description + data[:metadata] = metadata if metadata + data + end end end end diff --git a/lib/ngrokapi/services/endpoint_configurations_client.rb b/lib/ngrokapi/services/endpoint_configurations_client.rb index 2129473..1fd08e3 100644 --- a/lib/ngrokapi/services/endpoint_configurations_client.rb +++ b/lib/ngrokapi/services/endpoint_configurations_client.rb @@ -93,6 +93,19 @@ module NgrokAPI @client.delete("#{PATH}/#{id}") end + ## + # Delete an endpoint configuration. Throw an exception if 404. + # This operation will fail if the endpoint configuration is still referenced by + # any reserved domain or reserved address. + # + # @param [string] id a resource identifier + # @return [nil] result from delete request + # + # https://ngrok.com/docs/api#api-endpoint-configurations-delete + def delete!(id: nil) + @client.delete("#{PATH}/#{id}", danger: true) + end + ## # Returns detailed information about an endpoint configuration by ID. # @@ -105,6 +118,18 @@ module NgrokAPI NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result) end + ## + # Returns detailed information about an endpoint configuration by ID. Throw an execption if 404. + # + # @param [string] id a resource identifier + # @return [NgrokAPI::Models::EndpointConfiguration] result from get request + # + # https://ngrok.com/docs/api#api-endpoint-configurations-get + def get!(id: nil) + result = @client.get("#{PATH}/#{id}", danger: true) + NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result) + end + ## # Returns a list of all endpoint configurations on this account. # @@ -165,6 +190,106 @@ module NgrokAPI logging: nil, saml: nil, oidc: nil + ) + data = build_data( + description: description, + metadata: metadata, + circuit_breaker: circuit_breaker, + compression: compression, + request_headers: request_headers, + response_headers: response_headers, + ip_policy: ip_policy, + mutual_tls: mutual_tls, + tls_termination: tls_termination, + webhook_validation: webhook_validation, + oauth: oauth, + logging: logging, + saml: saml, + oidc: oidc + ) + result = @client.patch("#{PATH}/#{id}", data: data) + NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result) + end + + ## + # Updates an endpoint configuration. If a module is not specified in the update, it will not be modified. + # However, each module configuration that is specified will completely replace the existing value. + # There is no way to delete an existing module via this API, instead use the delete module API. + # Throw an exception if 404. + # + # @param [string] id unique identifier of this endpoint configuration + # @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 + # @param [string] metadata arbitrary user-defined machine-readable data of this endpoint configuration. Optional, max 4096 bytes. + # @param [string] circuit_breaker circuit breaker module configuration + # @param [string] compression compression module configuration + # @param [string] request_headers request headers module configuration + # @param [string] response_headers response headers module configuration + # @param [string] ip_policy ip policy module configuration + # @param [string] mutual_tls mutual TLS module configuration + # @param [string] tls_termination TLS termination module configuration + # @param [string] webhook_validation webhook validation module configuration + # @param [string] oauth oauth module configuration + # @param [string] logging logging module configuration + # @param [string] saml saml module configuration + # @param [string] oidc oidc module configuration + # @return [NgrokAPI::Models::EndpointConfiguration] result from update request + # + # https://ngrok.com/docs/api#api-endpoint-configurations-update + def update!( + id: nil, + description: nil, + metadata: nil, + circuit_breaker: nil, + compression: nil, + request_headers: nil, + response_headers: nil, + ip_policy: nil, + mutual_tls: nil, + tls_termination: nil, + webhook_validation: nil, + oauth: nil, + logging: nil, + saml: nil, + oidc: nil + ) + data = build_data( + description: description, + metadata: metadata, + circuit_breaker: circuit_breaker, + compression: compression, + request_headers: request_headers, + response_headers: response_headers, + ip_policy: ip_policy, + mutual_tls: mutual_tls, + tls_termination: tls_termination, + webhook_validation: webhook_validation, + oauth: oauth, + logging: logging, + saml: saml, + oidc: oidc + ) + result = @client.patch("#{PATH}/#{id}", danger: true, data: data) + NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result) + end + # rubocop:enable LineLength + + private + + def build_data( + description: nil, + metadata: nil, + circuit_breaker: nil, + compression: nil, + request_headers: nil, + response_headers: nil, + ip_policy: nil, + mutual_tls: nil, + tls_termination: nil, + webhook_validation: nil, + oauth: nil, + logging: nil, + saml: nil, + oidc: nil ) data = {} data[:description] = description if description @@ -181,10 +306,8 @@ module NgrokAPI data[:logging] = logging if logging data[:saml] = saml if saml data[:oidc] = oidc if oidc - result = @client.patch("#{PATH}/#{id}", data: data) - NgrokAPI::Models::EndpointConfiguration.new(client: self, result: result) + data end - # rubocop:enable LineLength end end end diff --git a/lib/ngrokapi/services/reserved_domains_client.rb b/lib/ngrokapi/services/reserved_domains_client.rb index 90a83f6..ebcac83 100644 --- a/lib/ngrokapi/services/reserved_domains_client.rb +++ b/lib/ngrokapi/services/reserved_domains_client.rb @@ -70,6 +70,17 @@ module NgrokAPI @client.delete("#{PATH}/#{id}") end + ## + # Delete a reserved domain. Throw an exception if 404. + # + # @param [string] id a resource identifier + # @return [nil] result from delete request + # + # https://ngrok.com/docs/api#api-reserved-domains-delete + def delete!(id: nil) + @client.delete("#{PATH}/#{id}", danger: true) + end + ## # Get the details of a reserved domain. # @@ -82,6 +93,18 @@ module NgrokAPI NgrokAPI::Models::ReservedDomain.new(client: self, result: result) end + ## + # Get the details of a reserved domain. Throw an exception if 404. + # + # @param [string] id a resource identifier + # @return [NgrokAPI::Models::ReservedDomain] result from get request + # + # https://ngrok.com/docs/api#api-reserved-domains-get + def get!(id: nil) + result = @client.get!("#{PATH}/#{id}") + NgrokAPI::Models::ReservedDomain.new(client: self, result: result) + end + ## # List all reserved domains on this account. # @@ -125,22 +148,51 @@ module NgrokAPI https_endpoint_configuration_id: nil, metadata: nil ) - data = {} - data[:certificate_id] = certificate_id if certificate_id - if certificate_management_policy - data[:certificate_management_policy] = certificate_management_policy - end - data[:description] = description if description - if http_endpoint_configuration_id - data[:http_endpoint_configuration_id] = http_endpoint_configuration_id - end - if https_endpoint_configuration_id - data[:https_endpoint_configuration_id] = https_endpoint_configuration_id - end - data[:metadata] = metadata if metadata + data = build_data( + description: description, + metadata: metadata, + http_endpoint_configuration_id: http_endpoint_configuration_id, + https_endpoint_configuration_id: https_endpoint_configuration_id, + certificate_id: certificate_id, + certificate_management_policy: certificate_management_policy + ) result = @client.patch("#{PATH}/#{id}", data: data) NgrokAPI::Models::ReservedDomain.new(client: self, result: result) end + + ## + # Update the attributes of a reserved domain. Throw an exception if 404. + # + # @param [string] id + # @param [string] description human-readable description of what this reserved domain will be used for + # @param [string] metadata arbitrary user-defined machine-readable data of this reserved domain. Optional, max 4096 bytes. + # @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 + # @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 + # @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``. + # @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``. + # @return [NgrokAPI::Models::ReservedDomain] result from update request + # + # https://ngrok.com/docs/api#api-reserved-domains-update + def update!( + id: nil, + certificate_id: nil, + certificate_management_policy: nil, + description: nil, + http_endpoint_configuration_id: nil, + https_endpoint_configuration_id: nil, + metadata: nil + ) + data = build_data( + description: description, + metadata: metadata, + http_endpoint_configuration_id: http_endpoint_configuration_id, + https_endpoint_configuration_id: https_endpoint_configuration_id, + certificate_id: certificate_id, + certificate_management_policy: certificate_management_policy + ) + result = @client.patch("#{PATH}/#{id}", danger: true, data: data) + NgrokAPI::Models::ReservedDomain.new(client: self, result: result) + end # rubocop:enable LineLength ## @@ -154,6 +206,17 @@ module NgrokAPI @client.delete("#{PATH}/#{id}/certificate") end + ## + # Detach the certificate attached from a reserved domain. Throw an exception if 404. + # + # @param [string] id a resource identifier + # @return [nil] result from delete request + # + # https://ngrok.com/docs/api#api-reserved-domains-delete-certificate + def delete_certificate!(id: nil) + @client.delete("#{PATH}/#{id}/certificate", danger: true) + end + ## # Detach the certificate management policy attached from a reserved domain. # @@ -165,6 +228,17 @@ module NgrokAPI @client.delete("#{PATH}/#{id}/certificate_management_policy") end + ## + # Detach the certificate management policy attached from a reserved domain. + # + # @param [string] id a resource identifier + # @return [nil] result from delete request + # + # https://ngrok.com/docs/api#api-reserved-domains-delete-certificate-management-policy + def delete_certificate_management_policy!(id: nil) + @client.delete("#{PATH}/#{id}/certificate_management_policy", danger: true) + end + ## # Detach the http endpoint configuration attached from a reserved domain. # @@ -176,6 +250,17 @@ module NgrokAPI @client.delete("#{PATH}/#{id}/http_endpoint_configuration") end + ## + # Detach the http endpoint configuration attached from a reserved domain. Throw an exception if 404. + # + # @param [string] id a resource identifier + # @return [nil] result from delete request + # + # https://ngrok.com/docs/api#api-reserved-domains-delete-http-endpoint-config + def delete_http_endpoint_config!(id: nil) + @client.delete("#{PATH}/#{id}/http_endpoint_configuration", danger: true) + end + ## # Detach the https endpoint configuration attached from a reserved domain. # @@ -186,6 +271,43 @@ module NgrokAPI def delete_https_endpoint_config(id: nil) @client.delete("#{PATH}/#{id}/https_endpoint_configuration") end + + ## + # Detach the https endpoint configuration attached from a reserved domain. Throw an exception if 404. + # + # @param [string] id a resource identifier + # @return [nil] result from delete request + # + # https://ngrok.com/docs/api#api-reserved-domains-delete-https-endpoint-config + def delete_https_endpoint_config!(id: nil) + @client.delete("#{PATH}/#{id}/https_endpoint_configuration", danger: true) + end + + private + + def build_data( + description: nil, + metadata: nil, + http_endpoint_configuration_id: nil, + https_endpoint_configuration_id: nil, + certificate_id: nil, + certificate_management_policy: nily + ) + data = {} + data[:certificate_id] = certificate_id if certificate_id + if certificate_management_policy + data[:certificate_management_policy] = certificate_management_policy + end + data[:description] = description if description + if http_endpoint_configuration_id + data[:http_endpoint_configuration_id] = http_endpoint_configuration_id + end + if https_endpoint_configuration_id + data[:https_endpoint_configuration_id] = https_endpoint_configuration_id + end + data[:metadata] = metadata if metadata + data + end end end end diff --git a/lib/ngrokapi/services/tls_certificates_client.rb b/lib/ngrokapi/services/tls_certificates_client.rb index 3dda77e..bbba7da 100644 --- a/lib/ngrokapi/services/tls_certificates_client.rb +++ b/lib/ngrokapi/services/tls_certificates_client.rb @@ -58,6 +58,17 @@ module NgrokAPI @client.delete("#{PATH}/#{id}") end + ## + # Delete a TLS certificate by ID. Throw an exception if 404. + # + # @param [string] id a resource identifier + # @return [nil] result from delete request + # + # https://ngrok.com/docs/api#api-tls-certificates-delete + def delete!(id: nil) + @client.delete("#{PATH}/#{id}", danger: true) + end + ## # Get detailed information about a TLS certificate by ID. # @@ -70,6 +81,18 @@ module NgrokAPI NgrokAPI::Models::TlsCertificate.new(client: self, result: result) end + ## + # Get detailed information about a TLS certificate by ID. Throw an exception if 404. + # + # @param [string] id a resource identifier + # @return [NgrokAPI::Models::TlsCertificate] result from get request + # + # https://ngrok.com/docs/api#api-tls-certificates-get + def get!(id: nil) + result = @client.get("#{PATH}/#{id}", danger: true) + NgrokAPI::Models::TlsCertificate.new(client: self, result: result) + end + ## # List all TLS certificates on this account. # @@ -111,6 +134,27 @@ module NgrokAPI result = @client.patch("#{PATH}/#{id}", data: data) NgrokAPI::Models::TlsCertificate.new(client: self, result: result) end + + ## + # Update attributes of a TLS Certificate by ID. Throw an exception if 404. + # + # @param [string] id + # @param [string] description human-readable description of this TLS certificate. optional, max 255 bytes. + # @param [string] metadata arbitrary user-defined machine-readable data of this TLS certificate. optional, max 4096 bytes. + # @return [NgrokAPI::Models::TlsCertificate] result from update request + # + # https://ngrok.com/docs/api#api-tls-certificates-update + def update!( + id: nil, + description: nil, + metadata: nil + ) + data = {} + data[:description] = description if description + data[:metadata] = metadata if metadata + result = @client.patch("#{PATH}/#{id}", danger: true, data: data) + NgrokAPI::Models::TlsCertificate.new(client: self, result: result) + end # rubocop:enable LineLength end end diff --git a/spec/ngrokapi/http_client_spec.rb b/spec/ngrokapi/http_client_spec.rb index f88e2ff..feb6437 100644 --- a/spec/ngrokapi/http_client_spec.rb +++ b/spec/ngrokapi/http_client_spec.rb @@ -45,6 +45,14 @@ RSpec.describe NgrokAPI::HttpClient do stub_request(:get, url).to_return(body: result.to_json) expect(@client.get(url)).to eq(result) end + + it "will raise a NotFoundError if 404" do + url = "#{base_url}#{path}/#{result["id"]}" + stub_request(:get, url).to_return(body: nil, status: 404) + expect do + @client.get(url, danger: true) + end.to raise_error(NgrokAPI::Errors::NotFoundError) + end end describe "#list" do diff --git a/spec/ngrokapi/services/api_keys_client_spec.rb b/spec/ngrokapi/services/api_keys_client_spec.rb index 3a320f3..27d5163 100644 --- a/spec/ngrokapi/services/api_keys_client_spec.rb +++ b/spec/ngrokapi/services/api_keys_client_spec.rb @@ -25,38 +25,78 @@ RSpec.describe NgrokAPI::Services::ApiKeysClient do }], } end + let(:not_found) do + NgrokAPI::Errors::NotFoundError.new(response: result) + end before(:each) do @client = class_double("HttpClient") @api_keys_client = NgrokAPI::Services::ApiKeysClient.new(client: @client) end - it "will make a POST request and return a newly created instance of NgrokAPI::Models::ApiKey" do - merged = result - merged['metadata'] = 'data' - expect(@client).to receive(:post).with(path, data: { metadata: 'data' }).and_return(merged) - result2 = @api_keys_client.create(metadata: 'data') - expect(result2.class).to eq(NgrokAPI::Models::ApiKey) - expect(result2.id).to eq(result["id"]) - expect(result2.metadata).to eq('data') + describe "#create" do + it "will make a POST request and return a newly created instance of NgrokAPI::Models::ApiKey" do + merged = result + merged['metadata'] = 'data' + expect(@client).to receive(:post).with(path, data: { metadata: 'data' }).and_return(merged) + result2 = @api_keys_client.create(metadata: 'data') + expect(result2.class).to eq(NgrokAPI::Models::ApiKey) + expect(result2.id).to eq(result["id"]) + expect(result2.metadata).to eq('data') + end end describe "#delete" do it "will make a DELETE request" do - expect(@client).to receive(:delete) + expect(@client).to receive(:delete).with("#{path}/#{result["id"]}").and_return(nil) @api_keys_client.delete(id: result["id"]) end end + describe "#delete!" do + it "will make a DELETE request" do + expect(@client).to receive(:delete).with("#{path}/#{result["id"]}", danger: true). + and_return(nil) + @api_keys_client.delete!(id: result["id"]) + end + + it "will make a DELETE request and return NotFoundError if 404" do + expect do + expect(@client).to receive(:delete).with("#{path}/#{result["id"]}", danger: true). + and_raise(NgrokAPI::Errors::NotFoundError) + result2 = @api_keys_client.delete!(id: result["id"]) + expect(result2).to be nil + end.to raise_error(NgrokAPI::Errors::NotFoundError) + end + end + describe "#get" do it "will make a GET request and return a NgrokAPI::Models::ApiKey" do - expect(@client).to receive(:get).and_return(result) + expect(@client).to receive(:get).with("#{path}/#{result["id"]}").and_return(result) result2 = @api_keys_client.get(id: result["id"]) expect(result2.class).to eq(NgrokAPI::Models::ApiKey) expect(result2.id).to eq(result["id"]) end end + describe "#get!" do + it "will make a GET request and return a NgrokAPI::Models::ApiKey" do + expect(@client).to receive(:get).with("#{path}/#{result["id"]}", danger: true).and_return(result) + result2 = @api_keys_client.get!(id: result["id"]) + expect(result2.class).to eq(NgrokAPI::Models::ApiKey) + expect(result2.id).to eq(result["id"]) + end + + it "will make a GET request and return NotFoundError if 404" do + expect do + expect(@client).to receive(:get).with("#{path}/#{result["id"]}", danger: true). + and_raise(NgrokAPI::Errors::NotFoundError) + result2 = @api_keys_client.get!(id: result["id"]) + expect(result2).to be nil + end.to raise_error(NgrokAPI::Errors::NotFoundError) + end + end + describe "#list" do it "will make a call to list (a GET request) and return a NgrokAPI::Models::Listable" do expect(@client).to receive(:list).and_return(results) @@ -80,4 +120,30 @@ RSpec.describe NgrokAPI::Services::ApiKeysClient do expect(result2.metadata).to eq('data') end end + + describe "#update!" do + it "will make a PATCH request and return an updated instance of NgrokAPI::Models::ApiKey" do + merged = result + merged['metadata'] = 'data' + expect(@client).to receive(:patch). + with("#{path}/#{result["id"]}", danger: true, data: { metadata: 'data' }). + and_return(merged) + result2 = @api_keys_client.update!(id: result["id"], metadata: 'data') + expect(result2.class).to eq(NgrokAPI::Models::ApiKey) + expect(result2.id).to eq(result["id"]) + expect(result2.metadata).to eq('data') + end + + it "will make a PATCH request and return NotFoundError if 404" do + expect do + merged = result + merged['metadata'] = 'data' + expect(@client).to receive(:patch). + with("#{path}/#{result["id"]}", danger: true, data: { metadata: 'data' }). + and_raise(NgrokAPI::Errors::NotFoundError) + result2 = @api_keys_client.update!(id: result["id"], metadata: 'data') + expect(result2).to be nil + end.to raise_error(NgrokAPI::Errors::NotFoundError) + end + end end