Class: Bandwidth::Domain
- Inherits:
-
Object
- Object
- Bandwidth::Domain
- Extended by:
- ClientWrapper
- Includes:
- ApiItem
- Defined in:
- lib/bandwidth/domain.rb
Overview
The Domain resource allows you create domains, add endpoints to it.
Class Method Summary collapse
-
.create(client, data) ⇒ Domain
Create a domain.
-
.list(client) ⇒ Array
Get created domains.
Instance Method Summary collapse
-
#create_endpoint(data) ⇒ EndPoint
Add a endpoint to a domain.
-
#delete ⇒ Object
(also: #destroy)
Delete a domain.
-
#delete_endpoint(endpoint_id) ⇒ Object
(also: #destroy_endpoint)
Delete an endpoint.
-
#get_endpoint(endpoint_id) ⇒ EndPoint
Retrieve information about an endpoint.
-
#get_endpoints ⇒ Array
List all endpoints from a domain.
Methods included from ClientWrapper
Methods included from ApiItem
#[], #[]=, #initialize, #to_data
Class Method Details
.create(client, data) ⇒ Domain
Create a domain.
26 27 28 29 30 |
# 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) ⇒ Array
Get created domains
13 14 15 16 17 |
# 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 |
Instance Method Details
#create_endpoint(data) ⇒ EndPoint
Add a endpoint to a domain.
47 48 49 50 51 |
# 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 ⇒ Object Also known as: destroy
Delete a domain
36 37 38 |
# File 'lib/bandwidth/domain.rb', line 36 def delete() @client.make_request(:delete, @client.concat_user_path("#{DOMAIN_PATH}/#{id}"))[0] end |
#delete_endpoint(endpoint_id) ⇒ Object Also known as: destroy_endpoint
Delete an endpoint
80 81 82 83 84 |
# 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 |
#get_endpoint(endpoint_id) ⇒ EndPoint
Retrieve information about an endpoint
58 59 60 61 62 63 |
# 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 ⇒ Array
List all endpoints from a domain
69 70 71 72 73 74 75 |
# File 'lib/bandwidth/domain.rb', line 69 def get_endpoints() @client.make_request(:get, @client.concat_user_path("#{DOMAIN_PATH}/#{id}/endpoints"))[0].map do |i| endpoint = EndPoint.new(i, @client) endpoint.domain_id = id endpoint end end |