sfrest 0.0.33 → 0.0.37

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: a2f5b00dc3ae474b41cdc244d98db5f26a8cd87cfa4aca2ee342a1d0795c7c42
4
- data.tar.gz: d33afbcae39304d25a89ecc3d23795d897373b8ef7e4c5b6b80c00f2b67f49da
3
+ metadata.gz: 573ae6cb7e5e7436c17d556e135ae412e91aececfdbe2b85a1dfa2ff813302df
4
+ data.tar.gz: 7ca7acc2ef22b1bf02bccb4ad19ea548d1d66756379d0882c488f9ac8bb3c2e7
5
5
  SHA512:
6
- metadata.gz: a1d699a698c779fc0a2ac85652817bd5b25ffa356f091a4c48bf758ab24375df175a84c1bd0b88120bc7bbd2e2e5bc4495bab887cdbd23fd50e4cfe8085343a5
7
- data.tar.gz: ed71ff4599ff3f459b5e0bde66c31bd0d54a6b0ee57edc83654eac666e72c13c405d9093b9000e6da32cbdfc4df8fb8807d3242bab1c0c9279620804df40b37a
6
+ metadata.gz: 886b5c70829c51516e3812c062188a52883541d922ad1bf9c952bb05093aa0b890616b5a6a5b3f4ed24604fd5d4b2551c803922773d826a1fd3a82e7e4583d6f
7
+ data.tar.gz: aaa80a02745ecc266300b76f37c6e0874adb2e9e2ca640ca94419f6fa48d23b64bb6eeab915a2dc4a6c2d8d21f6957014ed6c45c92e68bb0d919ddf17f57a8dc
@@ -0,0 +1,42 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SFRest
4
+ # We need to keep this naming due to the way connection.rb autoloads things.
5
+ # rubocop: disable Naming/ClassAndModuleCamelCase
6
+ # Manage the centralized role management feature.
7
+ class Centralized_role_management
8
+ # rubocop: enable Naming/ClassAndModuleCamelCase
9
+
10
+ # @param [SFRest::Connection] conn
11
+ def initialize(conn)
12
+ @conn = conn
13
+ end
14
+
15
+ # Get current centralized role management settings
16
+ #
17
+ # @return [Array] an array of roles with their associated settings.
18
+ def centralized_role_mapping
19
+ @conn.get('/api/v1/centralized-role-management')
20
+ end
21
+
22
+ # Enable the centralized role management settings for a given role.
23
+ # @param [String] factory_role the site factory role.
24
+ # @param [String] site_role the corresponding role on the site.
25
+ #
26
+ # @return [Array] an array of roles with their associated settings.
27
+ def enable_role_mapping(factory_role, site_role = '')
28
+ payload = {
29
+ 'site_role' => site_role
30
+ }.to_json
31
+ @conn.put("/api/v1/centralized-role-management/#{factory_role}", payload)
32
+ end
33
+
34
+ # Disable the centralized role management settings for a given role.
35
+ # @param [String] factory_role the site factory role.
36
+ #
37
+ # @return [Array] an array of roles with their associated settings.
38
+ def disable_role_mapping(factory_role)
39
+ @conn.delete("/api/v1/centralized-role-management/#{factory_role}")
40
+ end
41
+ end
42
+ end
@@ -164,13 +164,16 @@ module SFRest
164
164
  # NOTE: accessor == Class_name.to_lower
165
165
  REST_METHODS = %w[audit
166
166
  backup
167
+ centralized_role_management
167
168
  codebase
168
169
  collection
169
170
  domains
170
171
  group
171
172
  info
173
+ profile
172
174
  role
173
175
  site
176
+ site_ownership
174
177
  stage
175
178
  task
176
179
  theme
@@ -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
data/lib/sfrest/site.rb CHANGED
@@ -55,20 +55,21 @@ module SFRest
55
55
  res['sites'].first['id']
56
56
  end
57
57
 
58
- # Gets the complete list of sites
59
- # Makes multiple requests to the factory to get all the sites on the factory
60
- # @param [Boolean] show_incomplete whether to include incomplete sites in
61
- # the list. The default differs from UI/SF to maintain backward compatibility.
58
+ # Gets the complete list of sites.
59
+ #
60
+ # Makes multiple requests to the factory to get all the sites on the
61
+ # factory.
62
+ #
63
+ # @param [Hash] opts query parameters to be used in this request.
62
64
  # @return [Hash{'count' => Integer, 'sites' => Hash}]
63
- # rubocop: disable Style/OptionalBooleanParameter
64
- def site_list(show_incomplete = true)
65
+ def site_list(**opts)
65
66
  page = 1
66
67
  not_done = true
67
68
  count = 0
68
69
  sites = []
69
70
  while not_done
70
- current_path = '/api/v1/sites?page='.dup << page.to_s
71
- current_path <<= '&show_incomplete=true' if show_incomplete
71
+ opts['page'] = page
72
+ current_path = "/api/v1/sites?#{URI.encode_www_form(opts)}"
72
73
  res = @conn.get(current_path)
73
74
  if res['sites'] == []
74
75
  not_done = false
@@ -86,7 +87,6 @@ module SFRest
86
87
  end
87
88
  { 'count' => count, 'sites' => sites }
88
89
  end
89
- # rubocop: enable Style/OptionalBooleanParameter
90
90
 
91
91
  # Creates a site.
92
92
  # @param [String] sitename The name of the site to create.
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ module SFRest
4
+ # We need to keep this naming due to the way connection.rb autoloads things.
5
+ # rubocop: disable Naming/ClassAndModuleCamelCase
6
+ # Manage the site default ownership feature.
7
+ class Site_ownership
8
+ # rubocop: enable Naming/ClassAndModuleCamelCase
9
+
10
+ # @param [SFRest::Connection] conn
11
+ def initialize(conn)
12
+ @conn = conn
13
+ end
14
+
15
+ # Get current site ownership settings.
16
+ #
17
+ # @return [Array] an array containing current settings.
18
+ def default_ownership
19
+ @conn.get('/api/v1/site-ownership')
20
+ end
21
+
22
+ # Set the site ownership settings.
23
+ # @param [String] The default owner username. The user has to have the "Platform admin" role.
24
+ #
25
+ # @return [Array] an array containing the message given by the server.
26
+ def make_default_owner(username)
27
+ payload = {
28
+ 'username' => username
29
+ }
30
+
31
+ @conn.put('/api/v1/site-ownership', payload.to_json)
32
+ end
33
+
34
+ # Removes the default site owner.
35
+ #
36
+ # @return [Array] an array containing the message given by the server.
37
+ def remove_default_owner
38
+ @conn.delete('/api/v1/site-ownership')
39
+ end
40
+ end
41
+ end
data/lib/sfrest/stage.rb CHANGED
@@ -33,6 +33,7 @@ module SFRest
33
33
  # @param [Boolean] wipe_target_environment recreate the target stage wiping all data
34
34
  # @param [synchronize_all_users] only stage the user accounts required for the related collections and groups
35
35
  # @param [Array] Stacks Array of stack ids to wipe
36
+ # @param [Boolean] skip_site_files site skip file transfer during staging
36
37
  #
37
38
  # @return [Integer] Id of the staging task created.
38
39
  # rubocop:disable Metrics/ParameterLists
@@ -41,14 +42,16 @@ module SFRest
41
42
  email_site_status: false,
42
43
  wipe_target_environment: false,
43
44
  synchronize_all_users: true,
44
- wipe_stacks: [])
45
+ wipe_stacks: [],
46
+ skip_site_files: false)
45
47
  raise InvalidApiVersion, staging_versions unless staging_versions.include? 2
46
48
 
47
49
  payload = { 'to_env' => env, 'sites' => sites,
48
50
  'detailed_status' => email_site_status,
49
51
  'wipe_target_environment' => wipe_target_environment,
50
52
  'synchronize_all_users' => synchronize_all_users,
51
- 'wipe_stacks' => wipe_stacks }.to_json
53
+ 'wipe_stacks' => wipe_stacks,
54
+ 'skip_site_files' => skip_site_files }.to_json
52
55
  @conn.post('/api/v2/stage', payload)
53
56
  end
54
57
  # rubocop:enable Metrics/ParameterLists
@@ -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.37'
6
6
  end
data/lib/sfrest.rb CHANGED
@@ -10,6 +10,7 @@ require 'json'
10
10
 
11
11
  require 'sfrest/audit'
12
12
  require 'sfrest/backup'
13
+ require 'sfrest/centralized_role_management'
13
14
  require 'sfrest/codebase'
14
15
  require 'sfrest/collection'
15
16
  require 'sfrest/connection'
@@ -17,9 +18,11 @@ require 'sfrest/domains'
17
18
  require 'sfrest/error'
18
19
  require 'sfrest/group'
19
20
  require 'sfrest/info'
21
+ require 'sfrest/profile'
20
22
  require 'sfrest/pathbuilder'
21
23
  require 'sfrest/role'
22
24
  require 'sfrest/site'
25
+ require 'sfrest/site_ownership'
23
26
  require 'sfrest/stage'
24
27
  require 'sfrest/task'
25
28
  require 'sfrest/theme'
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.37
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: 2022-01-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -103,6 +103,7 @@ files:
103
103
  - lib/sfrest.rb
104
104
  - lib/sfrest/audit.rb
105
105
  - lib/sfrest/backup.rb
106
+ - lib/sfrest/centralized_role_management.rb
106
107
  - lib/sfrest/codebase.rb
107
108
  - lib/sfrest/collection.rb
108
109
  - lib/sfrest/connection.rb
@@ -111,8 +112,10 @@ files:
111
112
  - lib/sfrest/group.rb
112
113
  - lib/sfrest/info.rb
113
114
  - lib/sfrest/pathbuilder.rb
115
+ - lib/sfrest/profile.rb
114
116
  - lib/sfrest/role.rb
115
117
  - lib/sfrest/site.rb
118
+ - lib/sfrest/site_ownership.rb
116
119
  - lib/sfrest/stage.rb
117
120
  - lib/sfrest/task.rb
118
121
  - lib/sfrest/theme.rb
@@ -140,7 +143,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
143
  - !ruby/object:Gem::Version
141
144
  version: '0'
142
145
  requirements: []
143
- rubygems_version: 3.0.3
146
+ rubygems_version: 3.2.17
144
147
  signing_key:
145
148
  specification_version: 4
146
149
  summary: Acquia Site Factory Rest API.