class Iterable::MetadataTable

Interact with /metadata/{table} API endpoints

@example Creating metadata table endpoint object

# With default config
templates = Iterable::MetadataTable.new "table-name"
templates.get

# With custom config
conf = Iterable::Config.new(token: 'new-token')
templates = Iterable::MetadataTable.new("table-name", config)

Attributes

name[R]

Public Class Methods

new(name, conf = nil) click to toggle source

Initialize a MetadataTable with a table name

@param name [String] The name of the table to interact with @param conf [Iterable::Config] A config to optionally pass for requests

@return [Iterable::MetadataTable]

Calls superclass method Iterable::ApiResource::new
# File lib/iterable/metadata_table.rb, line 24
def initialize(name, conf = nil)
  @name = name
  super conf
end

Public Instance Methods

add(key, value = {}) click to toggle source

Add metadata for table

@param key [String] Key of metadata to add @param value [Hash] Value of metadata key as a hash of key/value data

@return [Iterable::Response] A response object

# File lib/iterable/metadata_table.rb, line 59
def add(key, value = {})
  Iterable.request(conf, base_path(key)).put(value: value)
end
delete() click to toggle source

Delete metadata table

@return [Iterable::Response] A response object

# File lib/iterable/metadata_table.rb, line 47
def delete
  Iterable.request(conf, base_path).delete
end
get(key) click to toggle source

Get metadata key for table

@param key [String] Key of metadata to get

@return [Iterable::Response] A response object

# File lib/iterable/metadata_table.rb, line 70
def get(key)
  Iterable.request(conf, base_path(key)).get
end
list_keys(next_marker = nil) click to toggle source

Get metadata table keys

@params next_marker [String] next result set id if more hits exist

@return [Iterable::Response] A response object

# File lib/iterable/metadata_table.rb, line 36
def list_keys(next_marker = nil)
  params = {}
  params['nextMarker'] = next_marker if next_marker
  Iterable.request(conf, base_path, params).get
end
remove(key) click to toggle source

Remove metadata key for table

@param key [String] Key of metadata to delete

@return [Iterable::Response] A response object

# File lib/iterable/metadata_table.rb, line 81
def remove(key)
  Iterable.request(conf, base_path(key)).delete
end

Private Instance Methods

base_path(key = nil) click to toggle source
# File lib/iterable/metadata_table.rb, line 87
def base_path(key = nil)
  path = "/metadata/#{@name}"
  path += "/#{key}" if key
  path
end