diff --git a/README.md b/README.md index 6887299..9112be0 100644 --- a/README.md +++ b/README.md @@ -20,12 +20,39 @@ A quickstart guide and a full API reference are included in the [ngrok Ruby API Please consult the [documentation](https://ruby-api.docs.ngrok.com) for additional examples. ```ruby -require 'ngrokapi/client' +require 'ngrokapi' client = NgrokAPI::Client.new(api_key: '') # Get an instance of the api_keys client and list all API keys keys_client = client.api_keys keys_client.list + +# Or set up an edge and backend with the ability to change your configuration later +edge = client.edges.https.create!( + description: "A Ruby Created Edge", + metadata: '{"client": "ruby"}', + hostports: ["your-subdomain.ngrok.io:443"] +) + +backend = client.backends.tunnel_group.create!( + description: "A Ruby Created Backend", + labels: {"client_example": "ruby"} +) + +route = client.edges.https_routes.create!( + edge_id: edge.id, + match_type: "path_prefix", + match: "/", + description: "Root", + backend: NgrokAPI::Models::EndpointBackendMutate.new(attrs: {"enabled": true, "backend_id": backend.id}), + compression: NgrokAPI::Models::EndpointCompression.new(attrs: {"enabled": true}) +) + +client.edge_modules.https_edge_route_compression.replace!( + edge_id: edge.id, + id: route.id, + a_module: NgrokAPI::Models::EndpointCompression.new(attrs: {"enabled": false}) +) ``` ## Local Documentation diff --git a/doc/NgrokAPI.html b/doc/NgrokAPI.html index 0d571ed..ae57b2d 100644 --- a/doc/NgrokAPI.html +++ b/doc/NgrokAPI.html @@ -147,7 +147,7 @@ diff --git a/doc/NgrokAPI/Client.html b/doc/NgrokAPI/Client.html index c819f5e..8c06260 100644 --- a/doc/NgrokAPI/Client.html +++ b/doc/NgrokAPI/Client.html @@ -1966,7 +1966,7 @@ diff --git a/doc/NgrokAPI/Error.html b/doc/NgrokAPI/Error.html index ef37232..31bde8f 100644 --- a/doc/NgrokAPI/Error.html +++ b/doc/NgrokAPI/Error.html @@ -295,7 +295,7 @@ diff --git a/doc/NgrokAPI/Errors.html b/doc/NgrokAPI/Errors.html index f4bc9d6..5f32c18 100644 --- a/doc/NgrokAPI/Errors.html +++ b/doc/NgrokAPI/Errors.html @@ -105,7 +105,7 @@ diff --git a/doc/NgrokAPI/Errors/NotFoundError.html b/doc/NgrokAPI/Errors/NotFoundError.html index e64b79c..78e7b7b 100644 --- a/doc/NgrokAPI/Errors/NotFoundError.html +++ b/doc/NgrokAPI/Errors/NotFoundError.html @@ -299,7 +299,7 @@ diff --git a/doc/NgrokAPI/HttpClient.html b/doc/NgrokAPI/HttpClient.html index e6bddaf..7be1696 100644 --- a/doc/NgrokAPI/HttpClient.html +++ b/doc/NgrokAPI/HttpClient.html @@ -331,6 +331,30 @@

Make a POST request to a given URI with optional data.

+ + + +
  • + + + #put(path, danger: false, data: {}) ⇒ json + + + + + + + + + + + + + +
    +

    Make a PUT request to a given URI with optional data.

    +
    +
  • @@ -993,7 +1017,7 @@ def patch(path, danger: false, data: {}) uri = get_uri(path) req = Net::HTTP::Patch.new(uri, headers_with_json) - json_do(uri, req, danger: danger, data: data.to_json) + json_do(uri, req, danger: danger, data: deep_to_h(data).to_json) end @@ -1112,7 +1136,126 @@ def post(path, danger: false, data: {}) uri = get_uri(path) req = Net::HTTP::Post.new(uri, headers_with_json) - json_do(uri, req, danger: danger, data: data.to_json) + json_do(uri, req, danger: danger, data: deep_to_h(data).to_json) +end + + + + + +
    +

    + + #put(path, danger: false, data: {}) ⇒ json + + + + + +

    +
    + +

    Make a PUT request to a given URI with optional data

    + + +
    +
    +
    +

    Parameters:

    +
      + +
    • + + path + + + (string) + + + + — +
      +

      URL resource path

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

      determine if we should throw an exception on 404 or not

      +
      + +
    • + +
    • + + data + + + (hash) + + + (defaults to: {}) + + + — +
      +

      hash which will be converted to query parameters or form data

      +
      + +
    • + +
    + +

    Returns:

    +
      + +
    • + + + (json) + + + + — +
      +

      response body

      +
      + +
    • + +
    + +
    + + + @@ -1124,7 +1267,7 @@ diff --git a/doc/NgrokAPI/Models.html b/doc/NgrokAPI/Models.html index 01a27e4..0f25ca3 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 d9d4570..a8f7ecb 100644 --- a/doc/NgrokAPI/Models/APIKey.html +++ b/doc/NgrokAPI/Models/APIKey.html @@ -106,6 +106,35 @@

    Instance Attribute Summary collapse

    @@ -538,7 +560,50 @@
    -

    +

    + + #attrsObject (readonly) + + + + + +

    +
    + +

    Returns the value of attribute attrs.

    + + +
    +
    +
    + + +
    +
    +
    +
    +95
    +96
    +97
    +98
    +99
    +
    +
    # File 'lib/ngrokapi/http_client.rb', line 95
    +
    +def put(path, danger: false, data: {})
    +  uri = get_uri(path)
    +  req = Net::HTTP::Put.new(uri, headers_with_json)
    +  json_do(uri, req, danger: danger, data: deep_to_h(data).to_json)
     end
    # File 'lib/ngrokapi/models/api_key.rb', line 15
     
    -def initialize(client:, result:)
    +def initialize(client: nil, attrs: {})
       @client = client
    -  @result = result
    -  @id = @result['id']
    -  @uri = @result['uri']
    -  @description = @result['description']
    -  @metadata = @result['metadata']
    -  @created_at = @result['created_at']
    -  @token = @result['token']
    +  @attrs = attrs
    +  @id = @attrs['id']
    +  @uri = @attrs['uri']
    +  @description = @attrs['description']
    +  @metadata = @attrs['metadata']
    +  @created_at = @attrs['created_at']
    +  @token = @attrs['token']
     end
    + + + + +
    +
    +
    +
    +6
    +7
    +8
    +
    +
    # File 'lib/ngrokapi/models/api_key.rb', line 6
    +
    +def attrs
    +  @attrs
    +end
    +
    +
    + + + +
    +

    #clientObject (readonly) @@ -751,49 +816,6 @@

    - -
    -

    - - #resultObject (readonly) - - - - - -

    -
    - -

    Returns the value of attribute result.

    - - -
    -
    -
    - - -
    - - - - -
    -
    -
    -
    -6
    -7
    -8
    -
    -
    # File 'lib/ngrokapi/models/api_key.rb', line 6
    -
    -def result
    -  @result
    -end
    -
    -
    - -

    @@ -909,7 +931,7 @@
    # File 'lib/ngrokapi/models/api_key.rb', line 26
     
     def ==(other)
    -  @result == other.result
    +  @attrs == other.attrs
     end
    @@ -944,14 +966,14 @@
     
     
    -38
    -39
    -40
    -41
    -42
    +42 +43 +44 +45 +46 -
    # File 'lib/ngrokapi/models/api_key.rb', line 38
    +      
    # File 'lib/ngrokapi/models/api_key.rb', line 42
     
     def delete
       @client.delete(
    @@ -961,6 +983,36 @@
         
       
     
    +

    + +
    +

    + + #to_hObject + + + + + +

    + + + + +
    +
    +
    +
    +34
    +35
    +36
    +
    +
    # File 'lib/ngrokapi/models/api_key.rb', line 34
    +
    +def to_h
    +  @attrs.to_h
    +end
    +
    @@ -986,7 +1038,7 @@
    # File 'lib/ngrokapi/models/api_key.rb', line 30
     
     def to_s
    -  @result.to_s
    +  @attrs.to_s
     end
    @@ -1021,10 +1073,6 @@
     
     
    -48
    -49
    -50
    -51
     52
     53
     54
    @@ -1032,10 +1080,14 @@
     56
     57
     58
    -59
    +59 +60 +61 +62 +63 -
    # File 'lib/ngrokapi/models/api_key.rb', line 48
    +      
    # File 'lib/ngrokapi/models/api_key.rb', line 52
     
     def update(
       description: nil,
    @@ -1059,7 +1111,7 @@
     
    diff --git a/doc/NgrokAPI/Models/AWSAuth.html b/doc/NgrokAPI/Models/AWSAuth.html index 956decd..2d306c9 100644 --- a/doc/NgrokAPI/Models/AWSAuth.html +++ b/doc/NgrokAPI/Models/AWSAuth.html @@ -106,6 +106,35 @@

    Instance Attribute Summary collapse