Module: OneAndOne

Defined in:
lib/oneandone.rb,
lib/1and1/dvd.rb,
lib/1and1/log.rb,
lib/1and1/vpn.rb,
lib/1and1/ping.rb,
lib/1and1/role.rb,
lib/1and1/user.rb,
lib/1and1/image.rb,
lib/1and1/usage.rb,
lib/1and1/server.rb,
lib/1and1/pricing.rb,
lib/1and1/firewall.rb,
lib/1and1/ssh_keys.rb,
lib/1and1/oneandone.rb,
lib/1and1/ping_auth.rb,
lib/1and1/public_ip.rb,
lib/1and1/datacenter.rb,
lib/1and1/block_storage.rb,
lib/1and1/load_balancer.rb,
lib/1and1/shared_storage.rb,
lib/1and1/private_network.rb,
lib/1and1/server_appliance.rb,
lib/1and1/monitoring_center.rb,
lib/1and1/monitoring_policy.rb,
lib/1and1/recovery_appliance.rb

Overview

Top-Level Module

Defined Under Namespace

Classes: BlockStorage, Datacenter, Dvd, Firewall, Image, LoadBalancer, Log, MonitoringCenter, MonitoringPolicy, Ping, PingAuth, Pricing, PrivateNetwork, PublicIP, RecoveryAppliance, Role, Server, ServerAppliance, SharedStorage, SshKey, Usage, User, Vpn

Class Method Summary collapse

Class Method Details

.build_url(endpoint) ⇒ Object



33
34
35
36
37
# File 'lib/1and1/oneandone.rb', line 33

def OneAndOne.build_url(endpoint)

  $version + endpoint

end

.check_response(message, status) ⇒ Object



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/1and1/oneandone.rb', line 40

def OneAndOne.check_response(message, status)
  
  # Check for server error
  if status == 500
    raise "Internal Server Error.  Please try again."
  end

  # Raise exception if a bad status code is received
  unless $success_codes.include? status
    raise message
  end

  true

end

.clean_hash(hash) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/1and1/oneandone.rb', line 22

def OneAndOne.clean_hash(hash)

  hash.each do |key, value|
    if value == nil
      hash.delete(key)
    end
  end

end

.start(api_token) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/1and1/oneandone.rb', line 4

def OneAndOne.start(api_token)
  
  # Set core values to be used across the module
  $api_token = api_token
  $base_url = 'https://cloudpanel-api.1and1.com'
  $version = '/v1'
  $header = {
    'X-TOKEN' => $api_token,
    'Content-Type' => 'application/json'
  }
  $success_codes = [200, 201, 202]
  $good_states = ['ACTIVE', 'ENABLED', 'POWERED_ON', 'POWERED_OFF']

  true

end