xclarity_client 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (27) hide show
  1. checksums.yaml +4 -4
  2. data/docs/apib/event.apib +11 -0
  3. data/docs/apib/update_repo.apib +56 -0
  4. data/lib/xclarity_client/configuration.rb +43 -19
  5. data/lib/xclarity_client/connection/connection.rb +45 -37
  6. data/lib/xclarity_client/endpoints/buildable_resource_mixin.rb +6 -1
  7. data/lib/xclarity_client/endpoints/globalsettings.rb +0 -5
  8. data/lib/xclarity_client/endpoints/hostplatform.rb +0 -4
  9. data/lib/xclarity_client/endpoints/osimage.rb +0 -4
  10. data/lib/xclarity_client/endpoints/remotefileserver.rb +0 -4
  11. data/lib/xclarity_client/mixins/event_mixin.rb +6 -0
  12. data/lib/xclarity_client/mixins/global_setting_mixin.rb +1 -1
  13. data/lib/xclarity_client/mixins/host_platform_mixin.rb +1 -1
  14. data/lib/xclarity_client/mixins/os_image_mixin.rb +1 -1
  15. data/lib/xclarity_client/mixins/remote_file_server_mixin.rb +1 -1
  16. data/lib/xclarity_client/mixins/update_repo_mixin.rb +23 -0
  17. data/lib/xclarity_client/schemas.rb +183 -194
  18. data/lib/xclarity_client/services/compliance_policy_management.rb +4 -6
  19. data/lib/xclarity_client/services/globalsettings_management.rb +8 -15
  20. data/lib/xclarity_client/services/hostplatform_management.rb +9 -18
  21. data/lib/xclarity_client/services/osimage_management.rb +12 -24
  22. data/lib/xclarity_client/services/remotefileserver_management.rb +13 -25
  23. data/lib/xclarity_client/services/update_repo_management.rb +58 -0
  24. data/lib/xclarity_client/services/xclarity_service.rb +27 -32
  25. data/lib/xclarity_client/version.rb +1 -1
  26. data/xclarity_client.gemspec +1 -0
  27. metadata +16 -2
@@ -18,14 +18,16 @@ module XClarityClient
18
18
  # @return [Array] containing all `managed_resource` from LXCA
19
19
  # @see EndpointManagerMixin#managed_resource
20
20
  #
21
- def fetch_all(opts = {})
21
+ def fetch_all(opts = {}, uri = {})
22
+ uri = managed_resource::BASE_URI if uri.empty? || uri.nil?
23
+
22
24
  $lxca_log.info "XclarityClient::Endpoints::XClarityService fetch_all",
23
25
  "Sending request to #{managed_resource} resource"
24
26
 
25
- response = @connection.do_get(managed_resource::BASE_URI, opts)
27
+ response = @connection.do_get(uri, :query => opts)
26
28
 
27
- $lxca_log.info "XclarityClient::Endpoints::XClarityService fetch_all",
28
- "Response received from #{managed_resource::BASE_URI}"
29
+ $lxca_log.info("XclarityClient::Endpoints::XClarityService fetch_all",
30
+ "Response received from #{uri}")
29
31
 
30
32
  build_response_with_resource_list(response, managed_resource)
31
33
  end
@@ -64,36 +66,32 @@ module XClarityClient
64
66
  build_response_with_resource_list(response, managed_resource)
65
67
  end
66
68
 
67
- def get_object_with_opts(opts, resource)
68
- raise "The opts cannot be empty" if opts.empty?
69
- filter = ""
70
-
71
- response = if not opts.empty?
72
- if not opts.has_key? "type"
73
- if opts.has_key? "filterWith"
74
- filter += "?filterWith="
75
- filter += "#{opts["filterWith"]}"
76
-
77
- elsif opts.has_key? "sort"
78
- filter += ",sort=" if filter != ""
79
- filter += "?sort=" if filter == ""
80
- filter += "#{opts["sort"]}"
81
- end
82
- else
83
- filter += "?type=#{opts["type"]}"
84
- end
85
- $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include", "Sending request to #{resource} resource using the following filter: #{filter}"
86
- @connection.do_get(resource::BASE_URI + filter)
87
- end
88
-
69
+ def get_object_with_opts(opts, resource, uri = '')
70
+ response = get_response_with_opts(opts, resource, uri)
89
71
  build_response_with_resource_list(response, managed_resource)
90
72
  end
91
73
 
74
+ def get_headers_with_opts(opts, resource)
75
+ get_response_with_opts(opts, resource).headers
76
+ end
77
+
92
78
  private
93
79
 
94
- #
95
- #
96
- #
80
+ def get_response_with_opts(opts, resource, uri = '')
81
+ raise "The opts cannot be empty" if opts.empty?
82
+ uri = resource::BASE_URI if uri.empty? || uri.nil?
83
+
84
+ response = do_request_with_opts(uri, opts)
85
+ end
86
+
87
+ def do_request_with_opts(uri, opts)
88
+ allowed_query_keys = %w(type sort)
89
+ query = opts.select { |key| allowed_query_keys.include?(key) }
90
+ headers = opts['headers'] || Hash.new(0)
91
+
92
+ @connection.do_get(uri, :query => query, :headers => headers)
93
+ end
94
+
97
95
  def get_object_with_include_attributes(uuids, attributes)
98
96
  $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include",
99
97
  "Sending request to #{managed_resource} resource including the following attributes: #{attributes.join(",")}"
@@ -106,9 +104,6 @@ module XClarityClient
106
104
 
107
105
  end
108
106
 
109
- #
110
- #
111
- #
112
107
  def get_object_with_exclude_attributes(uuids, attributes)
113
108
  $lxca_log.info "XclarityClient::ManagementMixin get_object_with_include",
114
109
  "Sending request to #{managed_resource} resource excluding the following attributes: #{attributes.join(",")}"
@@ -1,3 +1,3 @@
1
1
  module XClarityClient
2
- VERSION = "0.6.2"
2
+ VERSION = "0.6.3"
3
3
  end
@@ -24,6 +24,7 @@ Gem::Specification.new do |spec|
24
24
  spec.add_development_dependency "webmock", "~> 2.1.0"
25
25
  spec.add_dependency "faraday", "~> 0.9"
26
26
  spec.add_dependency "faraday-cookie_jar", "~> 0.0.6"
27
+ spec.add_dependency "httpclient", "~>2.8.3"
27
28
  spec.add_dependency "uuid", "~> 2.3.8"
28
29
  spec.add_dependency "faker", "~> 1.8.3"
29
30
  spec.add_dependency "json-schema", "~> 2.8.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: xclarity_client
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.6.2
4
+ version: 0.6.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Manasa Rao
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: exe
11
11
  cert_chain: []
12
- date: 2018-07-16 00:00:00.000000000 Z
12
+ date: 2018-09-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -109,6 +109,20 @@ dependencies:
109
109
  - - "~>"
110
110
  - !ruby/object:Gem::Version
111
111
  version: 0.0.6
112
+ - !ruby/object:Gem::Dependency
113
+ name: httpclient
114
+ requirement: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: 2.8.3
119
+ type: :runtime
120
+ prerelease: false
121
+ version_requirements: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: 2.8.3
112
126
  - !ruby/object:Gem::Dependency
113
127
  name: uuid
114
128
  requirement: !ruby/object:Gem::Requirement