delphix_rb 0.1.0 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 7350c64cf8d446bda6529be6aa7385bd399fce50
4
- data.tar.gz: 2a8d077c2ee44e55bfca06da8714b795afd36ec7
3
+ metadata.gz: 916878dc92aeeb06d919257efd28d2d3a9de5161
4
+ data.tar.gz: e0513a8bff89d459b872a0d5d76f8c35e4cd10f0
5
5
  SHA512:
6
- metadata.gz: ce887be1591ee007c0be1b187e34648a2519f9ad0cd1d94526d7b46807dda4c49c524f4b8ff883e0a2cfc948271a3fda36414173fd8ef01f259ba4822b1ff378
7
- data.tar.gz: d5527ab922eb63d2c5b62b62d98a29ad7a49ca925a3fdf67af0020540681753c0ccd290966a0c903f802f026110ec5d4b15ba6572db2aee56b772048c29575c6
6
+ metadata.gz: b812e7c6099b206a8e23101037b53d61fb0ca97ffd1689299ea7952d01a1edcf71efcb78908bc08967b0fdeea99ea62c591062db5457204257fd1f6390258987
7
+ data.tar.gz: a329c59718488e81a3146082631d13018c65349b4e3a00d9c6f64403e5296e1fabeb95de005c0a42c6df4e99208b5a21e9b454a7d4f57526090b904f8cd9d214
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.0
1
+ 0.2.0
data/delphix_rb.gemspec CHANGED
@@ -2,11 +2,11 @@
2
2
  # DO NOT EDIT THIS FILE DIRECTLY
3
3
  # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
4
  # -*- encoding: utf-8 -*-
5
- # stub: delphix_rb 0.1.0 ruby lib
5
+ # stub: delphix_rb 0.2.0 ruby lib
6
6
 
7
7
  Gem::Specification.new do |s|
8
8
  s.name = "delphix_rb"
9
- s.version = "0.1.0"
9
+ s.version = "0.2.0"
10
10
 
11
11
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
12
  s.require_paths = ["lib"]
data/lib/delphix/base.rb CHANGED
@@ -2,33 +2,31 @@
2
2
  module Delphix::Base
3
3
  include Delphix::Error
4
4
 
5
- attr_accessor :connection, :info, :details
5
+ attr_accessor :details
6
6
 
7
7
  # The private new method accepts a connection and a hash
8
- def initialize(connection, info={})
9
- unless connection.is_a?(Delphix::Connection)
10
- raise ArgumentError, "Expected a Delphix::Connection, got: #{connection}."
8
+ def initialize(reference=nil, details=nil)
9
+ if details == nil
10
+ @details = { 'reference' => reference }
11
+ else
12
+ @details = details
11
13
  end
12
-
13
- @connection, @info = connection, info
14
- @details = nil
15
14
  end
16
15
 
17
16
  def type
18
- @info['type'] || 'unknown'
17
+ @details['type'] || 'unknown'
19
18
  end
20
19
 
21
20
  def name
22
- @info['name'] || ''
21
+ @details['name'] || ''
23
22
  end
24
23
 
25
24
  def reference
26
- @info['reference'] || ''
25
+ @details['reference'] || ''
27
26
  end
28
27
 
29
28
  def details
30
29
  @details ||= refresh_details
31
- @info = @details
32
30
  @details
33
31
  end
34
32
 
@@ -42,12 +40,12 @@ module Delphix::Base
42
40
 
43
41
  # a generic get method, used when there is not specialized method to invoke an API call
44
42
  def get(endpoint, payload)
45
- @connection.get( endpoint, {}, :body => payload)
43
+ Delphix.get( endpoint, payload)
46
44
  end
47
45
 
48
46
  # a generic get method, used when there is not specialized method to invoke an API call
49
47
  def post(endpoint, payload)
50
- @connection.post( endpoint, {}, :body => payload)
48
+ Delphix.post( endpoint, payload)
51
49
  end
52
50
 
53
51
  end
@@ -1,5 +1,7 @@
1
+
1
2
  # This class represents a Connection to a Delphix Engine. The Connection is
2
3
  # immutable in that once the url and options is set they cannot be changed.
4
+
3
5
  class Delphix::Connection
4
6
  include Delphix::Error
5
7
 
@@ -20,13 +22,6 @@ class Delphix::Connection
20
22
  end
21
23
  end
22
24
 
23
- # The actual client that sends HTTP methods to the Delphix Engine.
24
- def session
25
- @session
26
- end
27
-
28
- private :session
29
-
30
25
  # Send a request to the server
31
26
  def request(*args, &block)
32
27
 
@@ -35,7 +30,7 @@ class Delphix::Connection
35
30
  log_request(request) if Delphix.debug
36
31
 
37
32
  # execute the request and grao the session cookie if not already set
38
- response = session.request(request)
33
+ response = @session.request(request)
39
34
  @session_cookie ||= cookie?(response)
40
35
 
41
36
  log_response(response) if Delphix.debug
@@ -5,10 +5,8 @@ require 'delphix/repository'
5
5
  class Delphix::Environment
6
6
  include Delphix::Base
7
7
 
8
- def initialize(reference)
9
- @connection = Delphix.connection
10
- @info = { 'reference' => reference }
11
- @details = nil
8
+ def initialize(reference, details=nil)
9
+ super(reference, details)
12
10
  end
13
11
 
14
12
  def repositories
@@ -58,7 +56,7 @@ class Delphix::Environment
58
56
  env = Delphix::Environment.new ref
59
57
 
60
58
  # refresh the object from the DE
61
- env.details
59
+ env.refresh_details
62
60
 
63
61
  env
64
62
  end
data/lib/delphix/group.rb CHANGED
@@ -2,10 +2,8 @@
2
2
  class Delphix::Group
3
3
  include Delphix::Base
4
4
 
5
- def initialize(reference)
6
- @connection = Delphix.connection
7
- @info = { 'reference' => reference }
8
- @details = nil
5
+ def initialize(reference, details=nil)
6
+ super(reference, details)
9
7
  end
10
8
 
11
9
  def refresh_details
@@ -23,7 +21,7 @@ class Delphix::Group
23
21
  group = Delphix::Group.new ref
24
22
 
25
23
  # refresh the object from the DE
26
- group.details
24
+ group.refresh_details
27
25
 
28
26
  group
29
27
  end
@@ -2,6 +2,10 @@
2
2
  class Delphix::Repository
3
3
  include Delphix::Base
4
4
 
5
+ def initialize(reference, details=nil)
6
+ super(reference, details)
7
+ end
8
+
5
9
  def refresh_details
6
10
  @details = get("/resources/json/delphix/repository/#{reference}", nil)['result']
7
11
  end
data/lib/delphix.rb CHANGED
@@ -14,13 +14,12 @@ module Delphix
14
14
  require 'delphix/repository'
15
15
 
16
16
  def authenticate!(username,password)
17
+
17
18
  case
18
- when !username.is_a?(String)
19
- raise ArgumentError, "Expected a String, got: '#{username}'"
20
- when !password.is_a?(String)
21
- raise ArgumentError, "Expected a String, got: '#{password}'"
22
- else
23
- @username, @password = username, password
19
+ when !username.is_a?(String)
20
+ raise ArgumentError, "Expected a String, got: '#{username}'"
21
+ when !password.is_a?(String)
22
+ raise ArgumentError, "Expected a String, got: '#{password}'"
24
23
  end
25
24
 
26
25
  reset_connection!
@@ -50,8 +49,8 @@ module Delphix
50
49
  def environments
51
50
  envs = BaseArray.new
52
51
  result = get('/resources/json/delphix/environment', nil)['result']
53
- result.each do |o|
54
- envs << Environment.new(connection, o)
52
+ result.each do |env|
53
+ envs << Environment.new(env['reference'],env)
55
54
  end
56
55
  envs
57
56
  end
@@ -59,8 +58,8 @@ module Delphix
59
58
  def groups
60
59
  groups = BaseArray.new
61
60
  result = get('/resources/json/delphix/group', nil)['result']
62
- result.each do |o|
63
- groups << Group.new(connection, o)
61
+ result.each do |group|
62
+ groups << Group.new(group['reference'],group)
64
63
  end
65
64
  groups
66
65
  end
@@ -68,8 +67,8 @@ module Delphix
68
67
  def repositories
69
68
  repos = BaseArray.new
70
69
  result = get('/resources/json/delphix/repository', nil)['result']
71
- result.each do |o|
72
- repos << Repository.new(connection, o)
70
+ result.each do |repo|
71
+ repos << Repository.new(repo['reference'],repo)
73
72
  end
74
73
  repos
75
74
  end
@@ -109,14 +108,6 @@ module Delphix
109
108
  reset_connection!
110
109
  end
111
110
 
112
- def connection
113
- @connection ||= Connection.new(url, options)
114
- end
115
-
116
- def reset_connection!
117
- @connection = nil
118
- end
119
-
120
111
  def debug
121
112
  @debug || false
122
113
  end
@@ -127,6 +118,14 @@ module Delphix
127
118
 
128
119
  private
129
120
 
121
+ def connection
122
+ @connection ||= Connection.new(url, options)
123
+ end
124
+
125
+ def reset_connection!
126
+ @connection = nil
127
+ end
128
+
130
129
  def env_url
131
130
  ENV['DELPHIX_URL'] || default_url
132
131
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delphix_rb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Kuehl