sfrest 0.0.29 → 0.0.30

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: 2c294e5ab1ba9e6a0a6be84b0c222ca5beae8326438db8c16dbee4a68d189599
4
- data.tar.gz: ce5a155559c66f8b7831a7cb14964fc2ca4ca2465492bdfa479fdd22defc5bb9
3
+ metadata.gz: e5d935fa06aa4609da0f2a5216400ebc8b88ca7e5d973962f5834b83390ff516
4
+ data.tar.gz: 2d532f771e96c443e41c0184ff03d2af957a1759ce8207eb99c75fa90cf9e99c
5
5
  SHA512:
6
- metadata.gz: edbdd8905bcc0ce249042f77e0e04a797ca852933adb4c9c546e83ad329f67711ce3ba2311650e44ea9a08b891f82b6f2e01e2052b3b9c1b65458f14e74d2d8a
7
- data.tar.gz: 03e34c3a38581414209a546cdd0da6f6b9ee17c64f65539f6984f92e5ee7b4ae8d44dbe5552db5fbdce9a741607fdb4eec51c6f49c4bbad2a788246decdb70d1
6
+ metadata.gz: 0ced957ae4b74d3e968794cc4f7aebd061f278fe30f240fb04dc0fd2c4d3c90d23591972433c17005e923dddbaa2e9e690bf2c164225c60e203718c4b2f47a83
7
+ data.tar.gz: 3bc8c3d799abbae1467c404b4cab407e7e23fec78fdc4d4651e91e73bedafd335cedc8c9b6a052e4bdf5daf2905f490e274b963bfb67e130d464abccb0a1449f
@@ -14,14 +14,14 @@ module SFRest
14
14
  # @return [Integer] the id of sitename
15
15
  def get_collection_id(name)
16
16
  pglimit = 100
17
- res = @conn.get('/api/v1/collections&limit=' + pglimit.to_s)
17
+ res = @conn.get("/api/v1/collections&limit=#{pglimit}")
18
18
  count = res['count'].to_i
19
19
  id = collection_data_from_results(res, name, 'id')
20
20
  return id if id
21
21
 
22
22
  pages = (count / pglimit) + 1
23
23
  2.upto(pages) do |i|
24
- res = @conn.get('/api/v1/collections&limit=' + pglimit.to_s + '?page=' + i.to_s)
24
+ res = @conn.get("/api/v1/collections&limit=#{pglimit}?page=#{i}")
25
25
  id = collection_data_from_results(res, name, 'id')
26
26
  return id if id
27
27
  end
@@ -45,7 +45,7 @@ module SFRest
45
45
  # @param [Integer] id the site id
46
46
  # @return [Hash]
47
47
  def get_collection_data(id)
48
- @conn.get('/api/v1/collections/' + id.to_s)
48
+ @conn.get("/api/v1/collections/#{id}")
49
49
  end
50
50
 
51
51
  # gets the site id of the 1st one found using the api
@@ -42,7 +42,7 @@ module SFRest
42
42
  user: username,
43
43
  password: password,
44
44
  ssl_verify_peer: false)
45
- api_response res, true
45
+ api_response res, return_status: true
46
46
  end
47
47
 
48
48
  # http request via post
@@ -100,7 +100,7 @@ module SFRest
100
100
  # with the reponse
101
101
  # @return [Array|Object] if return_status then [int, Object]
102
102
  # else Object
103
- def api_response(res, return_status = false)
103
+ def api_response(res, return_status: false)
104
104
  data = access_check JSON(res.body), res.status
105
105
  return_status ? [res.status, data] : data
106
106
  rescue JSON::ParserError
@@ -20,7 +20,7 @@ module SFRest
20
20
  # Deletes the group with the specified id
21
21
  # @param [Integer] group_id Id of the group to fetch
22
22
  def delete_group(group_id)
23
- current_path = '/api/v1/groups/' + group_id.to_s
23
+ current_path = "/api/v1/groups/#{group_id}"
24
24
  @conn.delete(current_path)
25
25
  end
26
26
 
@@ -28,7 +28,7 @@ module SFRest
28
28
  # @param [Integer] group_id Id of the group to rename.
29
29
  # @param [String] groupname New name for the group.
30
30
  def rename_group(group_id, groupname)
31
- current_path = '/api/v1/groups/' + group_id.to_s + '/update'
31
+ current_path = "/api/v1/groups/#{group_id}/update"
32
32
  payload = { 'group_name' => groupname }.to_json
33
33
  @conn.put(current_path, payload)
34
34
  end
@@ -37,7 +37,7 @@ module SFRest
37
37
  # @param [Integer] group_id Id of the group to fetch
38
38
  # @return [Hash] group object from the SF Api
39
39
  def get_group(group_id = 0)
40
- current_path = '/api/v1/groups/' + group_id.to_s
40
+ current_path = "/api/v1/groups/#{group_id}"
41
41
  @conn.get(current_path)
42
42
  end
43
43
 
@@ -45,7 +45,7 @@ module SFRest
45
45
  # @param [Integer] group_id Id of the group to fetch
46
46
  # @return [Hash] {'count' => count, 'members' => Hash }
47
47
  def get_members(group_id = 0)
48
- current_path = '/api/v1/groups/' + group_id.to_s + '/members'
48
+ current_path = "/api/v1/groups/#{group_id}/members"
49
49
  @conn.get(current_path)
50
50
  end
51
51
 
@@ -54,7 +54,7 @@ module SFRest
54
54
  # @param [Array] uids of the users that need to be added
55
55
  # @return [Hash] {'count' => count, 'uids_added' => Hash }
56
56
  def add_members(group_id, uids)
57
- current_path = '/api/v1/groups/' + group_id.to_s + '/members'
57
+ current_path = "/api/v1/groups/#{group_id}/members"
58
58
  payload = { 'uids' => uids.map(&:to_i) }.to_json
59
59
  @conn.post(current_path, payload)
60
60
  end
@@ -64,7 +64,7 @@ module SFRest
64
64
  # @param [Array] uids of the users that need to be removed
65
65
  # @return [Hash] {'group_id' => 123, 'uids_removed' => [1, 2, ...]}
66
66
  def remove_members(group_id, uids)
67
- current_path = '/api/v1/groups/' + group_id.to_s + '/members'
67
+ current_path = "/api/v1/groups/#{group_id}/members"
68
68
  payload = { 'uids' => uids.map(&:to_i) }.to_json
69
69
  @conn.delete(current_path, payload)
70
70
  end
@@ -74,7 +74,7 @@ module SFRest
74
74
  # @param [Array] uids of the users that need to be promoted
75
75
  # @return [Hash] {'count' => count, 'uids_promoted' => [1, 2, ...] }
76
76
  def promote_to_admins(group_id, uids)
77
- current_path = '/api/v1/groups/' + group_id.to_s + '/admins'
77
+ current_path = "/api/v1/groups/#{group_id}/admins"
78
78
  payload = { 'uids' => uids.map(&:to_i) }.to_json
79
79
  @conn.post(current_path, payload)
80
80
  end
@@ -84,7 +84,7 @@ module SFRest
84
84
  # @param [Array] uids of the users that need to be demoted
85
85
  # @return [Hash] {'count' => count, 'uids_demoted' => Hash }
86
86
  def demote_from_admins(group_id, uids)
87
- current_path = '/api/v1/groups/' + group_id.to_s + '/admins'
87
+ current_path = "/api/v1/groups/#{group_id}/admins"
88
88
  payload = { 'uids' => uids.map(&:to_i) }.to_json
89
89
  @conn.delete(current_path, payload)
90
90
  end
@@ -94,7 +94,7 @@ module SFRest
94
94
  # @param [Array] site_ids Ids of the sites that need to be added
95
95
  # @return [Hash] {'group_id' => 123, 'site_ids_added' => [1, 2, ...]}
96
96
  def add_sites(group_id, site_ids)
97
- current_path = '/api/v1/groups/' + group_id.to_s + '/sites'
97
+ current_path = "/api/v1/groups/#{group_id}/sites"
98
98
  payload = { 'site_ids' => site_ids }.to_json
99
99
  @conn.post(current_path, payload)
100
100
  end
@@ -104,7 +104,7 @@ module SFRest
104
104
  # @param [Array] site_ids Ids of the sites that need to be removed.
105
105
  # @return [Hash] {'group_id' => 123, 'site_ids_removed' => [1, 2, ...], 'site_ids_failed' => [3, 4, ...]}
106
106
  def remove_sites(group_id, site_ids)
107
- current_path = '/api/v1/groups/' + group_id.to_s + '/sites'
107
+ current_path = "/api/v1/groups/#{group_id}/sites"
108
108
  payload = { 'site_ids' => site_ids }.to_json
109
109
  @conn.delete(current_path, payload)
110
110
  end
@@ -44,14 +44,14 @@ module SFRest
44
44
  # this will iterate through the roles pages
45
45
  def get_role_id(rolename)
46
46
  pglimit = 100
47
- res = @conn.get('/api/v1/roles&limit=' + pglimit.to_s)
47
+ res = @conn.get("/api/v1/roles&limit=#{pglimit}")
48
48
  rolecount = res['count'].to_i
49
49
  id = role_data_from_results(res, rolename)
50
50
  return id if id
51
51
 
52
52
  pages = (rolecount / pglimit) + 1
53
53
  2.upto(pages) do |i|
54
- res = @conn.get('/api/v1/roles&limit=' + pglimit.to_s + '?page=' + i.to_s)
54
+ res = @conn.get("/api/v1/roles&limit=#{pglimit}?page=#{i}")
55
55
  id = role_data_from_results(res, rolename)
56
56
  return id if id
57
57
  end
@@ -74,7 +74,7 @@ module SFRest
74
74
  # @param [Integer] id the role id
75
75
  # @return [Hash] the role
76
76
  def role_data(id)
77
- @conn.get('/api/v1/roles/' + id.to_s)
77
+ @conn.get("/api/v1/roles/#{id}")
78
78
  end
79
79
 
80
80
  # Creates a role.
@@ -14,14 +14,14 @@ module SFRest
14
14
  # @return [Integer] the id of sitename
15
15
  def get_site_id(sitename)
16
16
  pglimit = 100
17
- res = @conn.get('/api/v1/sites&limit=' + pglimit.to_s)
17
+ res = @conn.get("/api/v1/sites&limit=#{pglimit}")
18
18
  sitecount = res['count'].to_i
19
19
  id = site_data_from_results(res, sitename, 'id')
20
20
  return id if id
21
21
 
22
22
  pages = (sitecount / pglimit) + 1
23
23
  2.upto(pages) do |i|
24
- res = @conn.get('/api/v1/sites&limit=' + pglimit.to_s + '?page=' + i.to_s)
24
+ res = @conn.get("/api/v1/sites&limit=#{pglimit}?page=#{i}")
25
25
  id = site_data_from_results(res, sitename, 'id')
26
26
  return id if id
27
27
  end
@@ -45,7 +45,7 @@ module SFRest
45
45
  # @param [Integer] site_id the site id
46
46
  # @return [Hash]
47
47
  def get_site_data(site_id)
48
- @conn.get('/api/v1/sites/' + site_id.to_s)
48
+ @conn.get("/api/v1/sites/#{site_id}")
49
49
  end
50
50
 
51
51
  # gets the site id of the 1st one found using the api
@@ -60,6 +60,7 @@ module SFRest
60
60
  # @param [Boolean] show_incomplete whether to include incomplete sites in
61
61
  # the list. The default differs from UI/SF to maintain backward compatibility.
62
62
  # @return [Hash{'count' => Integer, 'sites' => Hash}]
63
+ # rubocop: disable Style/OptionalBooleanParameter
63
64
  def site_list(show_incomplete = true)
64
65
  page = 1
65
66
  not_done = true
@@ -85,6 +86,7 @@ module SFRest
85
86
  end
86
87
  { 'count' => count, 'sites' => sites }
87
88
  end
89
+ # rubocop: enable Style/OptionalBooleanParameter
88
90
 
89
91
  # Creates a site.
90
92
  # @param [String] sitename The name of the site to create.
@@ -110,7 +112,7 @@ module SFRest
110
112
  # @param [Integer] site_id The id of the stie to be deleted
111
113
  # @return [Hash]
112
114
  def delete(site_id)
113
- current_path = '/api/v1/sites/' + site_id.to_s
115
+ current_path = "/api/v1/sites/#{site_id}"
114
116
  @conn.delete current_path
115
117
  end
116
118
 
@@ -15,6 +15,7 @@ module SFRest
15
15
  # @param [Boolean] skip_gardener skip staging the gardener and only stage the sites
16
16
  #
17
17
  # @return [Integer] Id of the staging task created.
18
+ # rubocop: disable Style/OptionalBooleanParameter
18
19
  def stage(to_env = 'test', sites = nil, email_site_status = false, skip_gardener = false)
19
20
  raise InvalidApiVersion, staging_versions unless staging_versions.include? 1
20
21
 
@@ -23,6 +24,7 @@ module SFRest
23
24
  'skip_gardener' => skip_gardener }.to_json
24
25
  @conn.post('/api/v1/stage', payload)
25
26
  end
27
+ # rubocop: enable Style/OptionalBooleanParameter
26
28
 
27
29
  # Stage a site using the new method
28
30
  # @param [String] to_env the name of of target env. defaults to test
@@ -65,12 +67,10 @@ module SFRest
65
67
  possible_versions = [1, 2]
66
68
  @versions ||= []
67
69
  possible_versions.each do |version|
68
- begin
69
- @conn.get "/api/v#{version}/stage"
70
- @versions.push version
71
- rescue SFRest::InvalidResponse
72
- nil
73
- end
70
+ @conn.get "/api/v#{version}/stage"
71
+ @versions.push version
72
+ rescue SFRest::InvalidResponse
73
+ nil
74
74
  end
75
75
  @versions
76
76
  end
@@ -209,7 +209,7 @@ module SFRest
209
209
  # Get a specific task's logs
210
210
  # @param [Integer] task_id
211
211
  def get_task_logs(task_id)
212
- current_path = '/api/v1/tasks/' + task_id.to_s + '/logs'
212
+ current_path = "/api/v1/tasks/#{task_id}/logs"
213
213
  @conn.get(current_path)
214
214
  end
215
215
 
@@ -233,7 +233,7 @@ module SFRest
233
233
  # @param [Integer] task_id
234
234
  # @param [String] level family|task
235
235
  def pause_task(task_id, level = 'family')
236
- current_path = '/api/v1/pause/' + task_id.to_s
236
+ current_path = "/api/v1/pause/#{task_id}"
237
237
  payload = { 'paused' => true, 'level' => level }.to_json
238
238
  @conn.post(current_path, payload)
239
239
  end
@@ -243,7 +243,7 @@ module SFRest
243
243
  # @param [Integer] task_id
244
244
  # @param [String] level family|task
245
245
  def resume_task(task_id, level = 'family')
246
- current_path = '/api/v1/pause/' + task_id.to_s
246
+ current_path = "/api/v1/pause/#{task_id}"
247
247
  payload = { 'paused' => false, 'level' => level }.to_json
248
248
  @conn.post(current_path, payload)
249
249
  end
@@ -261,7 +261,7 @@ module SFRest
261
261
  # This will delete the task and its children
262
262
  # @param [Integer] task_id
263
263
  def delete_task(task_id)
264
- current_path = '/api/v1/tasks/' + task_id.to_s
264
+ current_path = "/api/v1/tasks/#{task_id}"
265
265
  @conn.delete(current_path)
266
266
  end
267
267
 
@@ -269,7 +269,7 @@ module SFRest
269
269
  # @param [String] type softpaused | softpause-for-update
270
270
  # @return [Array] Array of wip classes
271
271
  def get_task_class_info(type = '')
272
- current_path = '/api/v1/classes/' + type
272
+ current_path = "/api/v1/classes/#{type}"
273
273
  @conn.get(current_path)
274
274
  end
275
275
 
@@ -26,7 +26,7 @@ module SFRest
26
26
 
27
27
  # Lists vcs refs.
28
28
  def list_vcs_refs(type = 'sites', stack_id = 1)
29
- current_path = '/api/v1/vcs?type=' + type + '&stack_id=' + stack_id.to_s
29
+ current_path = "/api/v1/vcs?type=#{type}&stack_id=#{stack_id}"
30
30
  @conn.get(current_path)
31
31
  end
32
32
 
@@ -71,7 +71,7 @@ module SFRest
71
71
 
72
72
  # Gets the progress of an update by id.
73
73
  def update_progress(update_id)
74
- current_path = '/api/v1/update/' + update_id.to_s + '/status'
74
+ current_path = "/api/v1/update/#{update_id}/status"
75
75
  @conn.get(current_path)
76
76
  end
77
77
 
@@ -109,7 +109,7 @@ module SFRest
109
109
  begin
110
110
  @conn.post '/api/v2/update', '{}'
111
111
  rescue SFRest::BadRequestError
112
- return @has_v2_endpoint = true
112
+ @has_v2_endpoint = true
113
113
  rescue SFRest::InvalidResponse => e
114
114
  return @has_v2_endpoint = false if e.message =~ /Invalid data, status 404/
115
115
 
@@ -16,7 +16,7 @@ module SFRest
16
16
  not_done = true
17
17
  count = 0
18
18
  while not_done
19
- current_path = '/api/v1/users?page=' + page.to_s
19
+ current_path = "/api/v1/users?page=#{page}"
20
20
  res = @conn.get(current_path)
21
21
  if res['users'] == []
22
22
  not_done = false
@@ -41,14 +41,14 @@ module SFRest
41
41
  # @return [Integer] the uid of the drupal user
42
42
  def get_user_id(username)
43
43
  pglimit = 100
44
- res = @conn.get('/api/v1/users&limit=' + pglimit.to_s)
44
+ res = @conn.get("/api/v1/users&limit=#{pglimit}")
45
45
  usercount = res['count'].to_i
46
46
  id = user_data_from_results(res, username, 'uid')
47
47
  return id if id
48
48
 
49
49
  pages = (usercount / pglimit) + 1
50
50
  2.upto(pages) do |i|
51
- res = @conn.get('/api/v1/users&limit=' + pglimit.to_s + '?page=' + i.to_s)
51
+ res = @conn.get("/api/v1/users&limit=#{pglimit}?page=#{i}")
52
52
  id = user_data_from_results(res, username, 'uid')
53
53
  return id if id
54
54
  end
@@ -72,7 +72,7 @@ module SFRest
72
72
  # @param [int] uid site id
73
73
  # @return [Hash]
74
74
  def get_user_data(uid)
75
- @conn.get('/api/v1/users/' + uid.to_s)
75
+ @conn.get("/api/v1/users/#{uid}")
76
76
  end
77
77
 
78
78
  # Creates a user.
@@ -16,7 +16,7 @@ module SFRest
16
16
 
17
17
  # Gets the value of a specific variable.
18
18
  def get_variable(name)
19
- current_path = '/api/v1/variables?name=' + name
19
+ current_path = "/api/v1/variables?name=#{name}"
20
20
  @conn.get(current_path)
21
21
  end
22
22
 
@@ -2,5 +2,5 @@
2
2
 
3
3
  module SFRest
4
4
  # Just tracks the version of sfrest.
5
- VERSION = '0.0.29'
5
+ VERSION = '0.0.30'
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sfrest
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.29
4
+ version: 0.0.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - ACSF Engineering
@@ -70,30 +70,30 @@ dependencies:
70
70
  name: simplecov
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
- - - "~>"
73
+ - - ">="
74
74
  - !ruby/object:Gem::Version
75
- version: '0.11'
75
+ version: '0'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
- - - "~>"
80
+ - - ">="
81
81
  - !ruby/object:Gem::Version
82
- version: '0.11'
82
+ version: '0'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: webmock
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
- - - "~>"
87
+ - - ">="
88
88
  - !ruby/object:Gem::Version
89
- version: '1.24'
89
+ version: '0'
90
90
  type: :development
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
- - - "~>"
94
+ - - ">="
95
95
  - !ruby/object:Gem::Version
96
- version: '1.24'
96
+ version: '0'
97
97
  description: Wrapper methods around the ACSF Rest API.
98
98
  email:
99
99
  executables: []
@@ -140,7 +140,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
140
  - !ruby/object:Gem::Version
141
141
  version: '0'
142
142
  requirements: []
143
- rubygems_version: 3.0.3
143
+ rubygems_version: 3.0.8
144
144
  signing_key:
145
145
  specification_version: 4
146
146
  summary: Acquia Site Factory Rest API.