class Bandwidth::Domain

The Domain resource allows you create domains, add endpoints to it.

Public Class Methods

create(client, data) click to toggle source

Create a domain. @param client [Client] optional client instance to make requests @param data [Hash] data to create a domain @return [Domain] created domain @example

domain = Domain.create(client, :name => "domain1")
# File lib/bandwidth/domain.rb, line 26
def self.create(client, data)
  headers = client.make_request(:post, client.concat_user_path(DOMAIN_PATH), data)[1]
  id = Client.get_id_from_location_header(headers[:location])
  Domain.new(:id => id, :name => data[:name], :description => data[:description])
end
list(client) click to toggle source

Get created domains @param client [Client] optional client instance to make requests @return [Array] list of domains @example

domains = Domain.list(client)
# File lib/bandwidth/domain.rb, line 13
def self.list(client)
  client.make_request(:get, client.concat_user_path(DOMAIN_PATH))[0].map do |item|
    Domain.new(item, client)
  end
end

Public Instance Methods

create_endpoint(data) click to toggle source

Add a endpoint to a domain. @param data [Hash] data to add endpoint to a domain @return [EndPoint] created endpoint @example

endpoint = domain.create_endpoint(:name=>"name", :application_id => "id")
# File lib/bandwidth/domain.rb, line 47
def create_endpoint(data)
  headers = @client.make_request(:post, @client.concat_user_path("#{DOMAIN_PATH}/#{id}/endpoints"), data)[1]
  id = Client.get_id_from_location_header(headers[:location])
  get_endpoint(id)
end
delete() click to toggle source

Delete a domain @example

domain.delete()
# File lib/bandwidth/domain.rb, line 36
def delete()
  @client.make_request(:delete, @client.concat_user_path("#{DOMAIN_PATH}/#{id}"))[0]
end
Also aliased as: destroy
delete_endpoint(endpoint_id) click to toggle source

Delete an endpoint @example

domain.delete_endpoint("id")
# File lib/bandwidth/domain.rb, line 80
def delete_endpoint(endpoint_id)
  endpoint = EndPoint.new({:id => endpoint_id}, @client)
  endpoint.domain_id = id
  endpoint.delete()
end
Also aliased as: destroy_endpoint
destroy()
Alias for: delete
destroy_endpoint(endpoint_id)
Alias for: delete_endpoint
get_endpoint(endpoint_id) click to toggle source

Retrieve information about an endpoint @param endpoint_id [String] id of endpoint @return [EndPoint] endpoint information @example

endpoint = domain.get_endpoint("id")
# File lib/bandwidth/domain.rb, line 58
def get_endpoint(endpoint_id)
  endpoint = EndPoint.new(@client.make_request(:get, @client.concat_user_path("#{DOMAIN_PATH}/#{id}/endpoints/#{endpoint_id}"))[0],
                       @client)
  endpoint.domain_id = id
  endpoint
end
get_endpoints(query = nil) click to toggle source

List all endpoints from a domain @return [Array] array of EndPoint instances @example

endpoints = domain.get_endpoints()
# File lib/bandwidth/domain.rb, line 69
def get_endpoints(query = nil)
  @client.make_request(:get, @client.concat_user_path("#{DOMAIN_PATH}/#{id}/endpoints"), query)[0].map do |i|
    endpoint = EndPoint.new(i, @client)
    endpoint.domain_id = id
    endpoint
  end
end