Module: Kongkit::Client::ApiObject

Included in:
Kongkit::Client
Defined in:
lib/kongkit/client/api_object.rb

Instance Method Summary collapse

Instance Method Details

#add_api(attributes) ⇒ Kongkit::Client::Resource

Note:

At least request_host or request_path or both should be specified.

Add API

Parameters:

  • attributes (Hash)

    a customizable set of options

Options Hash (attributes):

  • :name (String)

    The API name (optional)

  • :request_host (String)

    The public DNS address that points to your API (semi-optional)

  • :request_path (String)

    The public path that points to your API (semi-optional)

  • :strip_request_path (String)

    Strip the request_path value before proxying the request to the final API (optional)

  • :preserve_host (String)

    Preserves the original Host header sent by the client, instead of replacing it with the hostname of the upstream_url (optional)

  • :upstream_url (String)

    The base target URL that points to your API server, this URL will be used for proxying requests

Returns:

See Also:


40
41
42
# File 'lib/kongkit/client/api_object.rb', line 40

def add_api(attributes)
  post('/apis', body: attributes)
end

#api(identifier) ⇒ Kongkit::Client::Resource

Retrieve API

Parameters:

  • identifier (String)

    The unique identifier or the name of the API to retrieve

Returns:

See Also:


24
25
26
# File 'lib/kongkit/client/api_object.rb', line 24

def api(identifier)
  get(api_path(identifier))
end

#apis(options = {}) ⇒ Kongkit::Client::Resource

List APIs

Parameters:

  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :id (String)

    A filter on the list based on the apis `id` field

  • :name (String)

    A filter on the list based on the apis `name` field

  • :request_host (String)

    A filter on the list based on the apis `request_host` field

  • :request_path (String)

    A filter on the list based on the apis `request_path` field

  • :upstream_url (String)

    A filter on the list based on the apis `upstream_url` field

  • :size (Integer)

    A limit on the number of objects to be returned, default: 100

  • :offset (String)

    A cursor used for pagination. Offset is an object identifier that defines a place in the list.

Returns:

See Also:


15
16
17
# File 'lib/kongkit/client/api_object.rb', line 15

def apis(options = {})
  get('/apis', query: options)
end

#delete_api(identifier) ⇒ Boolean

Delete API

Parameters:

  • identifier (String)

    The unique identifier or the name of the API to delete

Returns:

  • (Boolean)

    `true` if successfully deleted

See Also:


66
67
68
# File 'lib/kongkit/client/api_object.rb', line 66

def delete_api(identifier)
  delete(api_path(identifier))
end

#edit_api(identifier, attributes) ⇒ Kongkit::Client::Resource

Note:

At least request_host or request_path or both should be specified.

Edit API

Parameters:

  • identifier (String)

    The unique identifier or the name of the API to update

  • attributes (Hash)

    a customizable set of options

Options Hash (attributes):

  • :name (String)

    The API name (optional)

  • :request_host (String)

    The public DNS address that points to your API (semi-optional)

  • :request_path (String)

    The public path that points to your API (semi-optional)

  • :strip_request_path (String)

    Strip the request_path value before proxying the request to the final API (optional)

  • :preserve_host (String)

    Preserves the original Host header sent by the client, instead of replacing it with the hostname of the upstream_url (optional)

  • :upstream_url (String)

    The base target URL that points to your API server, this URL will be used for proxying requests

Returns:

See Also:


57
58
59
# File 'lib/kongkit/client/api_object.rb', line 57

def edit_api(identifier, attributes)
  patch(api_path(identifier), body: attributes)
end