sfrest 0.0.33 → 0.0.34

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
  SHA256:
3
- metadata.gz: a2f5b00dc3ae474b41cdc244d98db5f26a8cd87cfa4aca2ee342a1d0795c7c42
4
- data.tar.gz: d33afbcae39304d25a89ecc3d23795d897373b8ef7e4c5b6b80c00f2b67f49da
3
+ metadata.gz: 4c59bfb1dd3ab6cde61f5db37e267d97824ceeea04f8306d25b083eadf394988
4
+ data.tar.gz: 6546e19cee41d06a5f44b2c09b6d8c3fb090730b78e8f712388dd05b039f6966
5
5
  SHA512:
6
- metadata.gz: a1d699a698c779fc0a2ac85652817bd5b25ffa356f091a4c48bf758ab24375df175a84c1bd0b88120bc7bbd2e2e5bc4495bab887cdbd23fd50e4cfe8085343a5
7
- data.tar.gz: ed71ff4599ff3f459b5e0bde66c31bd0d54a6b0ee57edc83654eac666e72c13c405d9093b9000e6da32cbdfc4df8fb8807d3242bab1c0c9279620804df40b37a
6
+ metadata.gz: 8eb3c3b56c037e6ab162d8ba7dfa939be6d8a5d5fe62124acbc1eae30259eb3a5fb5db5d129248870f91983b8badd8b0e5f0d4be8d62eec1126fcbc2588fbda3
7
+ data.tar.gz: d96ed66389ea837e2b293f041d68b4751ebeedd08f69e582921afac2d85b07c7c95fb1055e5fdcaa10e6c23a9e2a0951ef0ae347127d8704b0fb9fa91106f188
data/lib/sfrest.rb CHANGED
@@ -17,6 +17,7 @@ require 'sfrest/domains'
17
17
  require 'sfrest/error'
18
18
  require 'sfrest/group'
19
19
  require 'sfrest/info'
20
+ require 'sfrest/profile'
20
21
  require 'sfrest/pathbuilder'
21
22
  require 'sfrest/role'
22
23
  require 'sfrest/site'
@@ -169,6 +169,7 @@ module SFRest
169
169
  domains
170
170
  group
171
171
  info
172
+ profile
172
173
  role
173
174
  site
174
175
  stage
@@ -0,0 +1,68 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SFRest
4
+ # Work with installation profiles.
5
+ class Profile
6
+ # @param [SFRest::Connection] conn
7
+ def initialize(conn)
8
+ @conn = conn
9
+ end
10
+
11
+ # Gets a list of installation profiles.
12
+ #
13
+ # @param [Hash] params Given as URL parameters.
14
+ # @option params [Integer] :stack_id A stack id to filter by.
15
+ # @option params [Boolean] :is_enabled True to filter by enabled profiles. False
16
+ # to filter by disabled profiles.
17
+ # @return [Hash] Profile info formatted like so: {
18
+ # 'profiles' => [{
19
+ # 'name' => 'testing',
20
+ # 'description' => 'Some description',
21
+ # 'stack_id' => 1,
22
+ # 'rest_api_default' => false,
23
+ # 'enabled' => true
24
+ # }],
25
+ # 'count' => 1,
26
+ # 'time' => '2021-03-12T02:26:34+00:00'
27
+ # }
28
+ def profile_list(**params)
29
+ target_url = '/api/v1/profiles'
30
+ # Generate a string like "stack_id=3&is_enabled=true"
31
+ url_params = params.each.map { |k, v| "#{k}=#{v}" }.join('&')
32
+ target_url += "?#{url_params}" unless url_params.empty?
33
+
34
+ # Output is already well-formed, so return it.
35
+ @conn.get(target_url)
36
+ end
37
+
38
+ # Enables an installation profile.
39
+ #
40
+ # @param [String] name
41
+ # @param [Integer] stack_id Required if the factory is multistack.
42
+ def enable(name, stack_id: nil)
43
+ target_url = "/api/v1/profiles/#{name}/enable"
44
+ target_url += "?stack_id=#{stack_id}" unless stack_id.nil?
45
+ @conn.post(target_url, '{}')
46
+ end
47
+
48
+ # Disables an installation profile.
49
+ #
50
+ # @param [String] name
51
+ # @param [Integer] stack_id Required if the factory is multistack.
52
+ def disable(name, stack_id: nil)
53
+ target_url = "/api/v1/profiles/#{name}/disable"
54
+ target_url += "?stack_id=#{stack_id}" unless stack_id.nil?
55
+ @conn.post(target_url, '{}')
56
+ end
57
+
58
+ # Sets the default installation profile for use with other REST endpoints.
59
+ #
60
+ # @param [String] name
61
+ # @param [Integer] stack_id Required if the factory is multistack.
62
+ def set_default(name, stack_id: nil)
63
+ target_url = "/api/v1/profiles/#{name}/set_default"
64
+ target_url += "?stack_id=#{stack_id}" unless stack_id.nil?
65
+ @conn.post(target_url, '{}')
66
+ end
67
+ end
68
+ end
@@ -2,5 +2,5 @@
2
2
 
3
3
  module SFRest
4
4
  # Just tracks the version of sfrest.
5
- VERSION = '0.0.33'
5
+ VERSION = '0.0.34'
6
6
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sfrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.33
4
+ version: 0.0.34
5
5
  platform: ruby
6
6
  authors:
7
7
  - ACSF Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-02-26 00:00:00.000000000 Z
11
+ date: 2021-03-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -111,6 +111,7 @@ files:
111
111
  - lib/sfrest/group.rb
112
112
  - lib/sfrest/info.rb
113
113
  - lib/sfrest/pathbuilder.rb
114
+ - lib/sfrest/profile.rb
114
115
  - lib/sfrest/role.rb
115
116
  - lib/sfrest/site.rb
116
117
  - lib/sfrest/stage.rb