Class: Seiso::Connector
- Inherits:
-
Object
- Object
- Seiso::Connector
- Defined in:
- lib/seiso/connector.rb,
lib/seiso/connector/connector_v1.rb,
lib/seiso/connector/connector_v2.rb,
lib/seiso/connector/rest_connector.rb,
lib/seiso/connector/uri_factory_v1.rb,
lib/seiso/connector/uri_factory_v2.rb,
lib/seiso/connector/request_failed_error.rb
Overview
Seiso connector.
- Author
-
Willie Wheeler
- Copyright
-
Copyright © 2014-2015 Expedia, Inc.
- License
-
Apache 2.0
Defined Under Namespace
Classes: ConnectorV1, ConnectorV2, RequestFailedError, RestConnector, UriFactoryV1, UriFactoryV2
Instance Method Summary collapse
-
#connector_v1 ⇒ Object
Tests can override this.
-
#connector_v2 ⇒ Object
Tests can override this.
-
#get_items(type) ⇒ Object
GET item list.
-
#initialize(settings) ⇒ Connector
constructor
-
settings: a hash containing the following entries: - host - port - use_ssl (default false) - ignore_cert (default false) - username - password.
-
-
#post_items(type, items) ⇒ Object
POST items to Seiso.
-
#put_item(type, item, key) ⇒ Object
PUT a single item to Seiso.
Constructor Details
#initialize(settings) ⇒ Connector
-
settings: a hash containing the following entries:
-
host
-
port
-
use_ssl (default false)
-
ignore_cert (default false)
-
username
-
password
-
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/seiso/connector.rb', line 29 def initialize(settings) host = settings['host'] port = settings['port'] use_ssl = settings['use_ssl'] || false ignore_cert = settings['ignore_cert'] || false username = settings['username'] password = settings['password'] http = create_http(host, port, use_ssl, ignore_cert) @connector_v1 = Seiso::Connector::ConnectorV1.new(http, username, password) @connector_v2 = Seiso::Connector::ConnectorV2.new(http, username, password) end |
Instance Method Details
#connector_v1 ⇒ Object
Tests can override this
44 45 46 |
# File 'lib/seiso/connector.rb', line 44 def connector_v1 @connector_v1 end |
#connector_v2 ⇒ Object
Tests can override this
49 50 51 |
# File 'lib/seiso/connector.rb', line 49 def connector_v2 @connector_v2 end |
#get_items(type) ⇒ Object
GET item list
54 55 56 |
# File 'lib/seiso/connector.rb', line 54 def get_items(type) connector_v1.do_get("/v1/#{type}") end |
#post_items(type, items) ⇒ Object
POST items to Seiso
67 68 69 70 71 72 73 74 75 76 77 |
# File 'lib/seiso/connector.rb', line 67 def post_items(type, items) if type == 'ip-address-roles' do_put_ip_address_roles items elsif type == 'node-ip-addresses' do_put_node_ip_addresses items elsif type == 'service-instance-ports' do_put_service_instance_ports items else connector_v1.do_post("/v1/#{type}?mode=batch", items) end end |
#put_item(type, item, key) ⇒ Object
PUT a single item to Seiso.
-
type: Item type
-
item: Item
-
key: Item key
83 84 85 |
# File 'lib/seiso/connector.rb', line 83 def put_item(type, item, key) connector_v1.do_put("/v1/#{type}/#{key}", item) end |