Module: Luminati::Client::Zone

Included in:
Luminati::Client
Defined in:
lib/luminati/client/zone.rb,
lib/luminati/client/zone/ips.rb

Defined Under Namespace

Modules: Ips

Instance Method Summary collapse

Instance Method Details

#active_zonesObject

Returns active zones



135
136
137
# File 'lib/luminati/client/zone.rb', line 135

def active_zones
  request(:get, "/api/zone/get_active_zones")
end

#add_zone(zone_info, plan_info) ⇒ String

Adds a zone

Parameters:

  • zone_info (Hash)
  • plan_info (Hash)

Returns:

  • (String)

    The official API documentation says it returns the information of the added zone but currently it returns just ‘OK`.

See Also:



88
89
90
91
92
93
# File 'lib/luminati/client/zone.rb', line 88

def add_zone(zone_info, plan_info)
  data = {}
  data["zone"] = zone_info unless zone_info.empty?
  data["plan"] = plan_info unless plan_info.empty?
  request(:post, "/api/zone", Oj.dump(data, mode: :compat))
end

#remove_zone(zone_name) ⇒ String

Remove a zone

Parameters:

  • zone_name (String)

Returns:

  • (String)

    The official API documentation says it returns the information of the added zone but currently it returns just ‘OK`.

See Also:



99
100
101
102
103
# File 'lib/luminati/client/zone.rb', line 99

def remove_zone(zone_name)
  data = {}
  data["zone"] = zone_name
  request(:delete, "/api/zone", Oj.dump(data, mode: :compat))
end

#zone_available_ip_count(zone_name, plan = nil) ⇒ Hash

Returns the number of available IPs

Parameters:

  • zone_name (String)
  • plan (Hash) (defaults to: nil)

Returns:

  • (Hash)

See Also:



37
38
39
40
41
# File 'lib/luminati/client/zone.rb', line 37

def zone_available_ip_count(zone_name, plan = nil)
  parameters = "zone=#{zone_name}"
  parameters << "&plan=#{Oj.dump(plan, mode: :compat)}" if plan
  request(:get, "/api/zone/count_available_ips?#{parameters}")
end

#zone_available_ips(zone_name, country_code = nil, expand = false) ⇒ Hash

Returns avaialble IPs in a given zone and a given country

Parameters:

  • zone_name (String)
  • country_code (String) (defaults to: nil)

    A country code like ‘US`.

  • expand (Boolean) (defaults to: false)

    ‘true` when you want expanded IPs

Returns:

  • (Hash)

See Also:



58
59
60
61
62
63
# File 'lib/luminati/client/zone.rb', line 58

def zone_available_ips(zone_name, country_code = nil, expand = false)
  parameters = "zone=#{zone_name}"
  parameters << "&country=#{country_code}" if country_code
  parameters << "&expand=1" if expand
  request(:get, "/api/zone/route_ips?#{parameters}")
end

#zone_available_vips(zone_name) ⇒ Hash

Returns available VIPs in a given zone

Parameters:

  • zone_name (String)

Returns:

  • (Hash)

See Also:



69
70
71
72
# File 'lib/luminati/client/zone.rb', line 69

def zone_available_vips(zone_name)
  parameters = "zone=#{zone_name}"
  request(:get, "/api/zone/route_vips?#{parameters}")
end

#zone_bandwidth_stats(zone_name, from = nil, to = nil) ⇒ Hash

Returns the bandwidth stats for a given zone

Parameters:

  • zone_name (String)
  • from (String) (defaults to: nil)

    This should be in the format ‘2018-07-01T00:00:00`.

  • to (String) (defaults to: nil)

    This should be in the format ‘2018-07-02T00:00:00`.

Returns:

  • (Hash)

See Also:



12
13
14
15
16
17
# File 'lib/luminati/client/zone.rb', line 12

def zone_bandwidth_stats(zone_name, from = nil, to = nil)
  parameters = "zone=#{zone_name}&details=1"
  parameters << "&from=#{from}" if from
  parameters << "&to=#{to}" if to
  request(:get, "/api/zone/bw?#{parameters}")
end

#zone_cost_stats(zone_name, from = nil, to = nil) ⇒ Hash

Returns the cost and the bandwidth stats for a given zone

Parameters:

  • zone_name (String)
  • from (String) (defaults to: nil)

    This should be in the format ‘2018-07-01T00:00:00`.

  • to (String) (defaults to: nil)

    This should be in the format ‘2018-07-02T00:00:00`.

Returns:

  • (Hash)

See Also:



25
26
27
28
29
30
# File 'lib/luminati/client/zone.rb', line 25

def zone_cost_stats(zone_name, from = nil, to = nil)
  parameters = "zone=#{zone_name}"
  parameters << "&from=#{from}" if from
  parameters << "&to=#{to}" if to
  request(:get, "/api/zone/cost?#{parameters}")
end

#zone_info(zone_name) ⇒ Hash

Returns the information of a given zone

Parameters:

  • zone_name (String)

Returns:

  • (Hash)

See Also:



78
79
80
81
# File 'lib/luminati/client/zone.rb', line 78

def zone_info(zone_name)
  parameters = "zone=#{zone_name}"
  request(:get, "/api/zone?#{parameters}")
end

#zone_passwords(zone_name) ⇒ Object

Returns passwords of a given zone

Parameters:

  • zone_name (String)

See Also:



109
110
111
112
# File 'lib/luminati/client/zone.rb', line 109

def zone_passwords(zone_name)
  parameters = "zone=#{zone_name}"
  request(:get, "/api/zone/passwords?#{parameters}")
end

#zone_permissions(zone_name) ⇒ Object

Returns permissions of a given zone

Parameters:

  • zone_name (String)

See Also:



118
119
120
121
# File 'lib/luminati/client/zone.rb', line 118

def zone_permissions(zone_name)
  parameters = "zone=#{zone_name}"
  request(:get, "/api/zone/permissions?#{parameters}")
end

#zone_recent_ips(zone_names) ⇒ Hash

Returns recent IPs attempting to use a given zone

Parameters:

  • zone_names (String)

    ‘*` or zone names separated with `,`

Returns:

  • (Hash)

See Also:



47
48
49
50
# File 'lib/luminati/client/zone.rb', line 47

def zone_recent_ips(zone_names)
  parameters = "zones=#{zone_names}"
  request(:get, "/api/zone/recent_ips?#{parameters}")
end

#zone_status(zone_name) ⇒ Object

Returns the status of a given zone

Parameters:

  • zone_name (String)

See Also:



127
128
129
130
# File 'lib/luminati/client/zone.rb', line 127

def zone_status(zone_name)
  parameters = "zone=#{zone_name}"
  request(:get, "/api/zone/status?#{parameters}")
end