Class: SFRest::Domains

Inherits:
Object
  • Object
show all
Defined in:
lib/sfrest/domains.rb

Overview

Find Staging envs and stage a set of sites

Instance Method Summary collapse

Constructor Details

#initialize(conn) ⇒ Domains

Returns a new instance of Domains.

Parameters:



5
6
7
# File 'lib/sfrest/domains.rb', line 5

def initialize(conn)
  @conn = conn
end

Instance Method Details

#add(node_id, domain_name) ⇒ Hash

Add a domain

Parameters:

  • node_id (Integer)

    The id of the node to which add a domain

  • domain_name (String)

    domain to add. e.g. www.example.com

Returns:

  • (Hash)

    { “node_type”: “site_collection”, “domain”: “www.example.com”, “added”: true, “messages”: [ “Your domain name was successfully added to the site collection.”] }



45
46
47
48
# File 'lib/sfrest/domains.rb', line 45

def add(node_id, domain_name)
  payload = { 'domain_name' => domain_name }.to_json
  @conn.post("/api/v1/domains/#{node_id}/add", payload)
end

#custom_domains(node_id) ⇒ Array

Get the custom domains on a node

Parameters:

  • node_id (Integer)

    The id of the node.

Returns:

  • (Array)

    custom(removable) domains on a node



25
26
27
# File 'lib/sfrest/domains.rb', line 25

def custom_domains(node_id)
  get(node_id)['domains']['custom_domains']
end

#get(node_id) ⇒ Hash

Get the domains information on a node

Parameters:

  • node_id (Integer)

    The id of the node.

Returns:

  • (Hash)

    { “node_id” => 4966, “node_type” => “site”, “time” => “2016-11-18T20:09:55+00:00”, “domains” => { “protected_domains” =>[ “it252garden4.utest.sfdev.acquia-test.co” ], “custom_domains” => [ “it252coll3.utest.sfdev.acquia-test.co”, “sc1.nikgregory.us” ] } }



16
17
18
19
# File 'lib/sfrest/domains.rb', line 16

def get(node_id)
  current_path = "/api/v1/domains/#{node_id}"
  @conn.get(current_path)
end

#protected_domains(node_id) ⇒ Array

Get the protetect domains on a node

Parameters:

  • node_id (Integer)

    The id of the node.

Returns:

  • (Array)

    protected (non-removable) domains on a node



33
34
35
# File 'lib/sfrest/domains.rb', line 33

def protected_domains(node_id)
  get(node_id)['domains']['protected_domains']
end

#remove(node_id, domain_name) ⇒ Hash

Remove a domain

Parameters:

  • node_id (Integer)

    The id of the node to which remove a domain

  • domain_name (String)

    domain to remove. e.g. www.example.com

Returns:

  • (Hash)

    { “node_type”: “site_collection”, “domain”: “www.example.com”, “removed”: true, “messages”: [ “Your domain name was successfully removed from the site collection.” ] }



58
59
60
61
# File 'lib/sfrest/domains.rb', line 58

def remove(node_id, domain_name)
  payload = { 'domain_name' => domain_name }.to_json
  @conn.post("/api/v1/domains/#{node_id}/remove", payload)
end