Module: Kongkit::Client::Consumer

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

Instance Method Summary collapse

Instance Method Details

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

Retrieve consumer

Parameters:

  • identifier (String)

    The unique identifier or the username of the consumer to retrieve

Returns:

See Also:


22
23
24
# File 'lib/kongkit/client/consumer.rb', line 22

def consumer(identifier)
  get(consumer_path(identifier))
end

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

List consumers

Parameters:

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

    a customizable set of options

Options Hash (options):

  • :id (String)

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

  • :custom_id (String)

    A filter on the list based on the consumer `custom_id` field

  • :username (String)

    A filter on the list based on the consumer `username` 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:


13
14
15
# File 'lib/kongkit/client/consumer.rb', line 13

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

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

Note:

At least username or custom_id should be specified.

Create consumer

Parameters:

  • attributes (Hash)

    a customizable set of options

Options Hash (attributes):

  • :username (String)

    The username of the consumer (semi-optional)

  • :custom_id (String)

    Field for storing an existing ID for the consumer, useful for mapping Kong with users in your existing database (semi-optional)

Returns:

See Also:


34
35
36
# File 'lib/kongkit/client/consumer.rb', line 34

def create_consumer(attributes)
  post('/consumers', body: attributes)
end

#delete_consumer(identifier) ⇒ Boolean

Delete Consumer

Parameters:

  • identifier (String)

    The unique identifier or the name of the consumer to delete

Returns:

  • (Boolean)

    `true` if successfully deleted

See Also:


56
57
58
# File 'lib/kongkit/client/consumer.rb', line 56

def delete_consumer(identifier)
  delete(consumer_path(identifier))
end

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

Note:

At least username or custom_id should be specified.

Edit consumer

Parameters:

  • identifier (String)

    The unique identifier or the name of the consumer to update

  • attributes (Hash)

    a customizable set of options

Options Hash (attributes):

  • :username (String)

    The username of the consumer (semi-optional)

  • :custom_id (String)

    Field for storing an existing ID for the consumer, useful for mapping Kong with users in your existing database (semi-optional)

Returns:

See Also:


47
48
49
# File 'lib/kongkit/client/consumer.rb', line 47

def edit_consumer(identifier, attributes)
  patch(consumer_path(identifier), body: attributes)
end