sfrest 0.0.25 → 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: 454094d1aed9e441d633a8f69733518952f014a1aefa8246f5bf00cc659d4a34
4
- data.tar.gz: 0de73fa9d7a32b350d78237e95b90630544952695b189d74576f6ef2c5f52107
3
+ metadata.gz: e5d935fa06aa4609da0f2a5216400ebc8b88ca7e5d973962f5834b83390ff516
4
+ data.tar.gz: 2d532f771e96c443e41c0184ff03d2af957a1759ce8207eb99c75fa90cf9e99c
5
5
  SHA512:
6
- metadata.gz: 7bbc97856c5e30f44327d8c1cda39ed695e015b67afe5fcce668100c04b0ac9adb75f2a5c7254c978341d03342e298df039c4d2d4446cbebaa377e993b9981d4
7
- data.tar.gz: 7dd69e1115edda16ec71d2a0954fc807364e4359c7f834a6c0cf8aae1709f41f31e24c57ba0f103a8dccf669c4fa51730fe6f82a07ea501636dc9528d354d43a
6
+ metadata.gz: 0ced957ae4b74d3e968794cc4f7aebd061f278fe30f240fb04dc0fd2c4d3c90d23591972433c17005e923dddbaa2e9e690bf2c164225c60e203718c4b2f47a83
7
+ data.tar.gz: 3bc8c3d799abbae1467c404b4cab407e7e23fec78fdc4d4651e91e73bedafd335cedc8c9b6a052e4bdf5daf2905f490e274b963bfb67e130d464abccb0a1449f
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  # Simple wrappper around RestClient.Resource
2
4
  $LOAD_PATH.unshift(__dir__) unless
3
5
  $LOAD_PATH.include?(__dir__) ||
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Get all the audit devents.
3
5
  class Audit
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Backup a site or restore onto that site
3
5
  class Backup
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # List codebases on the factory.
3
5
  class Codebase
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Find colletions, return their data.
3
5
  class Collection
@@ -12,14 +14,14 @@ module SFRest
12
14
  # @return [Integer] the id of sitename
13
15
  def get_collection_id(name)
14
16
  pglimit = 100
15
- res = @conn.get('/api/v1/collections&limit=' + pglimit.to_s)
17
+ res = @conn.get("/api/v1/collections&limit=#{pglimit}")
16
18
  count = res['count'].to_i
17
19
  id = collection_data_from_results(res, name, 'id')
18
20
  return id if id
19
21
 
20
22
  pages = (count / pglimit) + 1
21
23
  2.upto(pages) do |i|
22
- 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}")
23
25
  id = collection_data_from_results(res, name, 'id')
24
26
  return id if id
25
27
  end
@@ -43,7 +45,7 @@ module SFRest
43
45
  # @param [Integer] id the site id
44
46
  # @return [Hash]
45
47
  def get_collection_data(id)
46
- @conn.get('/api/v1/collections/' + id.to_s)
48
+ @conn.get("/api/v1/collections/#{id}")
47
49
  end
48
50
 
49
51
  # gets the site id of the 1st one found using the api
@@ -61,7 +63,7 @@ module SFRest
61
63
  not_done = true
62
64
  count = 0
63
65
  while not_done
64
- current_path = '/api/v1/collections?page=' << page.to_s
66
+ current_path = '/api/v1/collections?page='.dup << page.to_s
65
67
  res = @conn.get(current_path)
66
68
  if res['collections'] == []
67
69
  not_done = false
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Generic http methods
3
5
  # accessors for all the sub classes.
@@ -40,7 +42,7 @@ module SFRest
40
42
  user: username,
41
43
  password: password,
42
44
  ssl_verify_peer: false)
43
- api_response res, true
45
+ api_response res, return_status: true
44
46
  end
45
47
 
46
48
  # http request via post
@@ -98,7 +100,7 @@ module SFRest
98
100
  # with the reponse
99
101
  # @return [Array|Object] if return_status then [int, Object]
100
102
  # else Object
101
- def api_response(res, return_status = false)
103
+ def api_response(res, return_status: false)
102
104
  data = access_check JSON(res.body), res.status
103
105
  return_status ? [res.status, data] : data
104
106
  rescue JSON::ParserError
@@ -179,8 +181,8 @@ module SFRest
179
181
 
180
182
  REST_METHODS.each do |m|
181
183
  define_method(m) do
182
- m.capitalize!
183
- sfrest_klass = "SFRest::#{m}"
184
+ klazz = m.dup.capitalize!
185
+ sfrest_klass = "SFRest::#{klazz}"
184
186
  Object.const_get(sfrest_klass).new(self)
185
187
  end
186
188
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Find Staging envs and stage a set of sites
3
5
  class Domains
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Error classes for SFRest
3
5
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # SF Group management
3
5
  class Group
@@ -18,7 +20,7 @@ module SFRest
18
20
  # Deletes the group with the specified id
19
21
  # @param [Integer] group_id Id of the group to fetch
20
22
  def delete_group(group_id)
21
- current_path = '/api/v1/groups/' << group_id.to_s
23
+ current_path = "/api/v1/groups/#{group_id}"
22
24
  @conn.delete(current_path)
23
25
  end
24
26
 
@@ -26,7 +28,7 @@ module SFRest
26
28
  # @param [Integer] group_id Id of the group to rename.
27
29
  # @param [String] groupname New name for the group.
28
30
  def rename_group(group_id, groupname)
29
- current_path = '/api/v1/groups/' + group_id.to_s + '/update'
31
+ current_path = "/api/v1/groups/#{group_id}/update"
30
32
  payload = { 'group_name' => groupname }.to_json
31
33
  @conn.put(current_path, payload)
32
34
  end
@@ -35,7 +37,7 @@ module SFRest
35
37
  # @param [Integer] group_id Id of the group to fetch
36
38
  # @return [Hash] group object from the SF Api
37
39
  def get_group(group_id = 0)
38
- current_path = '/api/v1/groups/' << group_id.to_s
40
+ current_path = "/api/v1/groups/#{group_id}"
39
41
  @conn.get(current_path)
40
42
  end
41
43
 
@@ -43,7 +45,7 @@ module SFRest
43
45
  # @param [Integer] group_id Id of the group to fetch
44
46
  # @return [Hash] {'count' => count, 'members' => Hash }
45
47
  def get_members(group_id = 0)
46
- current_path = '/api/v1/groups/' + group_id.to_s + '/members'
48
+ current_path = "/api/v1/groups/#{group_id}/members"
47
49
  @conn.get(current_path)
48
50
  end
49
51
 
@@ -52,7 +54,7 @@ module SFRest
52
54
  # @param [Array] uids of the users that need to be added
53
55
  # @return [Hash] {'count' => count, 'uids_added' => Hash }
54
56
  def add_members(group_id, uids)
55
- current_path = '/api/v1/groups/' + group_id.to_s + '/members'
57
+ current_path = "/api/v1/groups/#{group_id}/members"
56
58
  payload = { 'uids' => uids.map(&:to_i) }.to_json
57
59
  @conn.post(current_path, payload)
58
60
  end
@@ -62,7 +64,7 @@ module SFRest
62
64
  # @param [Array] uids of the users that need to be removed
63
65
  # @return [Hash] {'group_id' => 123, 'uids_removed' => [1, 2, ...]}
64
66
  def remove_members(group_id, uids)
65
- current_path = '/api/v1/groups/' + group_id.to_s + '/members'
67
+ current_path = "/api/v1/groups/#{group_id}/members"
66
68
  payload = { 'uids' => uids.map(&:to_i) }.to_json
67
69
  @conn.delete(current_path, payload)
68
70
  end
@@ -72,7 +74,7 @@ module SFRest
72
74
  # @param [Array] uids of the users that need to be promoted
73
75
  # @return [Hash] {'count' => count, 'uids_promoted' => [1, 2, ...] }
74
76
  def promote_to_admins(group_id, uids)
75
- current_path = '/api/v1/groups/' + group_id.to_s + '/admins'
77
+ current_path = "/api/v1/groups/#{group_id}/admins"
76
78
  payload = { 'uids' => uids.map(&:to_i) }.to_json
77
79
  @conn.post(current_path, payload)
78
80
  end
@@ -82,7 +84,7 @@ module SFRest
82
84
  # @param [Array] uids of the users that need to be demoted
83
85
  # @return [Hash] {'count' => count, 'uids_demoted' => Hash }
84
86
  def demote_from_admins(group_id, uids)
85
- current_path = '/api/v1/groups/' + group_id.to_s + '/admins'
87
+ current_path = "/api/v1/groups/#{group_id}/admins"
86
88
  payload = { 'uids' => uids.map(&:to_i) }.to_json
87
89
  @conn.delete(current_path, payload)
88
90
  end
@@ -92,7 +94,7 @@ module SFRest
92
94
  # @param [Array] site_ids Ids of the sites that need to be added
93
95
  # @return [Hash] {'group_id' => 123, 'site_ids_added' => [1, 2, ...]}
94
96
  def add_sites(group_id, site_ids)
95
- current_path = '/api/v1/groups/' + group_id.to_s + '/sites'
97
+ current_path = "/api/v1/groups/#{group_id}/sites"
96
98
  payload = { 'site_ids' => site_ids }.to_json
97
99
  @conn.post(current_path, payload)
98
100
  end
@@ -102,7 +104,7 @@ module SFRest
102
104
  # @param [Array] site_ids Ids of the sites that need to be removed.
103
105
  # @return [Hash] {'group_id' => 123, 'site_ids_removed' => [1, 2, ...], 'site_ids_failed' => [3, 4, ...]}
104
106
  def remove_sites(group_id, site_ids)
105
- current_path = '/api/v1/groups/' + group_id.to_s + '/sites'
107
+ current_path = "/api/v1/groups/#{group_id}/sites"
106
108
  payload = { 'site_ids' => site_ids }.to_json
107
109
  @conn.delete(current_path, payload)
108
110
  end
@@ -116,7 +118,7 @@ module SFRest
116
118
  not_done = true
117
119
  count = 0
118
120
  while not_done
119
- current_path = '/api/v1/groups?page=' << page.to_s
121
+ current_path = '/api/v1/groups?page='.dup << page.to_s
120
122
  res = @conn.get(current_path)
121
123
  if res['groups'] == []
122
124
  not_done = false
@@ -134,5 +136,28 @@ module SFRest
134
136
  end
135
137
  { 'count' => count, 'groups' => groups }
136
138
  end
139
+
140
+ # gets the group ID for the group named groupname
141
+ # will page through all the groups available searching for the group
142
+ # @param [String] group the name of the group
143
+ # @return [Integer] the id of groupname
144
+ def get_group_id(groupname)
145
+ res = group_list
146
+ id = group_data_from_results(res, groupname, 'group_id')
147
+ return id if id
148
+ end
149
+
150
+ # Extract the group data for 'key' based on the site result object
151
+ # @param [Hash] res result from a request to /sites
152
+ # @param [String] groupname
153
+ # @param [String] key one of the user data returned (id, site, domain...)
154
+ # @return [Object] Integer, String, Array, Hash depending on the site data
155
+ def group_data_from_results(res, groupname, key)
156
+ groups = res['groups']
157
+ groups.each do |group|
158
+ return group[key] if group['group_name'] == groupname
159
+ end
160
+ nil
161
+ end
137
162
  end
138
163
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Retrieve Site Factory info.
3
5
  class Info
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # make a url querypath
3
5
  # so that if the are multiple items in a get request
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # create, delete, update, roles
3
5
  class Role
@@ -16,7 +18,7 @@ module SFRest
16
18
  not_done = true
17
19
  count = 0
18
20
  while not_done
19
- current_path = '/api/v1/roles?page=' << page.to_s
21
+ current_path = '/api/v1/roles?page='.dup << page.to_s
20
22
  res = @conn.get(current_path)
21
23
  if res['roles'] == []
22
24
  not_done = false
@@ -42,14 +44,14 @@ module SFRest
42
44
  # this will iterate through the roles pages
43
45
  def get_role_id(rolename)
44
46
  pglimit = 100
45
- res = @conn.get('/api/v1/roles&limit=' + pglimit.to_s)
47
+ res = @conn.get("/api/v1/roles&limit=#{pglimit}")
46
48
  rolecount = res['count'].to_i
47
49
  id = role_data_from_results(res, rolename)
48
50
  return id if id
49
51
 
50
52
  pages = (rolecount / pglimit) + 1
51
53
  2.upto(pages) do |i|
52
- 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}")
53
55
  id = role_data_from_results(res, rolename)
54
56
  return id if id
55
57
  end
@@ -72,7 +74,7 @@ module SFRest
72
74
  # @param [Integer] id the role id
73
75
  # @return [Hash] the role
74
76
  def role_data(id)
75
- @conn.get('/api/v1/roles/' + id.to_s)
77
+ @conn.get("/api/v1/roles/#{id}")
76
78
  end
77
79
 
78
80
  # Creates a role.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Find sites, create a site,
3
5
  class Site
@@ -12,14 +14,14 @@ module SFRest
12
14
  # @return [Integer] the id of sitename
13
15
  def get_site_id(sitename)
14
16
  pglimit = 100
15
- res = @conn.get('/api/v1/sites&limit=' + pglimit.to_s)
17
+ res = @conn.get("/api/v1/sites&limit=#{pglimit}")
16
18
  sitecount = res['count'].to_i
17
19
  id = site_data_from_results(res, sitename, 'id')
18
20
  return id if id
19
21
 
20
22
  pages = (sitecount / pglimit) + 1
21
23
  2.upto(pages) do |i|
22
- 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}")
23
25
  id = site_data_from_results(res, sitename, 'id')
24
26
  return id if id
25
27
  end
@@ -43,7 +45,7 @@ module SFRest
43
45
  # @param [Integer] site_id the site id
44
46
  # @return [Hash]
45
47
  def get_site_data(site_id)
46
- @conn.get('/api/v1/sites/' + site_id.to_s)
48
+ @conn.get("/api/v1/sites/#{site_id}")
47
49
  end
48
50
 
49
51
  # gets the site id of the 1st one found using the api
@@ -58,13 +60,14 @@ module SFRest
58
60
  # @param [Boolean] show_incomplete whether to include incomplete sites in
59
61
  # the list. The default differs from UI/SF to maintain backward compatibility.
60
62
  # @return [Hash{'count' => Integer, 'sites' => Hash}]
63
+ # rubocop: disable Style/OptionalBooleanParameter
61
64
  def site_list(show_incomplete = true)
62
65
  page = 1
63
66
  not_done = true
64
67
  count = 0
65
68
  sites = []
66
69
  while not_done
67
- current_path = '/api/v1/sites?page=' << page.to_s
70
+ current_path = '/api/v1/sites?page='.dup << page.to_s
68
71
  current_path <<= '&show_incomplete=true' if show_incomplete
69
72
  res = @conn.get(current_path)
70
73
  if res['sites'] == []
@@ -83,6 +86,7 @@ module SFRest
83
86
  end
84
87
  { 'count' => count, 'sites' => sites }
85
88
  end
89
+ # rubocop: enable Style/OptionalBooleanParameter
86
90
 
87
91
  # Creates a site.
88
92
  # @param [String] sitename The name of the site to create.
@@ -108,7 +112,7 @@ module SFRest
108
112
  # @param [Integer] site_id The id of the stie to be deleted
109
113
  # @return [Hash]
110
114
  def delete(site_id)
111
- current_path = '/api/v1/sites/' + site_id.to_s
115
+ current_path = "/api/v1/sites/#{site_id}"
112
116
  @conn.delete current_path
113
117
  end
114
118
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Find Staging envs and stage a set of sites
3
5
  class Stage
@@ -13,6 +15,7 @@ module SFRest
13
15
  # @param [Boolean] skip_gardener skip staging the gardener and only stage the sites
14
16
  #
15
17
  # @return [Integer] Id of the staging task created.
18
+ # rubocop: disable Style/OptionalBooleanParameter
16
19
  def stage(to_env = 'test', sites = nil, email_site_status = false, skip_gardener = false)
17
20
  raise InvalidApiVersion, staging_versions unless staging_versions.include? 1
18
21
 
@@ -21,6 +24,7 @@ module SFRest
21
24
  'skip_gardener' => skip_gardener }.to_json
22
25
  @conn.post('/api/v1/stage', payload)
23
26
  end
27
+ # rubocop: enable Style/OptionalBooleanParameter
24
28
 
25
29
  # Stage a site using the new method
26
30
  # @param [String] to_env the name of of target env. defaults to test
@@ -28,21 +32,26 @@ module SFRest
28
32
  # @param [Boolean] email_site_status send an email about the staging status of each site
29
33
  # @param [Boolean] wipe_target_environment recreate the target stage wiping all data
30
34
  # @param [synchronize_all_users] only stage the user accounts required for the related collections and groups
35
+ # @param [Array] Stacks Array of stack ids to wipe
31
36
  #
32
37
  # @return [Integer] Id of the staging task created.
38
+ # rubocop:disable Metrics/ParameterLists
33
39
  def enhanced_stage(env: 'test',
34
40
  sites: nil,
35
41
  email_site_status: false,
36
42
  wipe_target_environment: false,
37
- synchronize_all_users: true)
43
+ synchronize_all_users: true,
44
+ wipe_stacks: nil)
38
45
  raise InvalidApiVersion, staging_versions unless staging_versions.include? 2
39
46
 
40
47
  payload = { 'to_env' => env, 'sites' => sites,
41
48
  'detailed_status' => email_site_status,
42
49
  'wipe_target_environment' => wipe_target_environment,
43
- 'synchronize_all_users' => synchronize_all_users }.to_json
50
+ 'synchronize_all_users' => synchronize_all_users,
51
+ 'wipe_stacks' => wipe_stacks }.to_json
44
52
  @conn.post('/api/v2/stage', payload)
45
53
  end
54
+ # rubocop:enable Metrics/ParameterLists
46
55
 
47
56
  # Query for available staging environments
48
57
  #
@@ -58,12 +67,10 @@ module SFRest
58
67
  possible_versions = [1, 2]
59
68
  @versions ||= []
60
69
  possible_versions.each do |version|
61
- begin
62
- @conn.get "/api/v#{version}/stage"
63
- @versions.push version
64
- rescue SFRest::InvalidResponse
65
- nil
66
- end
70
+ @conn.get "/api/v#{version}/stage"
71
+ @versions.push version
72
+ rescue SFRest::InvalidResponse
73
+ nil
67
74
  end
68
75
  @versions
69
76
  end
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Deal with tasks, find them, pause them...
3
5
  class Task
@@ -23,7 +25,7 @@ module SFRest
23
25
  # @param [Integer] status
24
26
  # @return [Boolean]
25
27
  def status_not_started?(status)
26
- return true if (status.to_i & STATUS_TO_BE_RUN) > 0
28
+ return true if (status.to_i & STATUS_TO_BE_RUN).positive?
27
29
 
28
30
  false
29
31
  end
@@ -42,7 +44,7 @@ module SFRest
42
44
  # @param [Integer] status
43
45
  # @return [Boolean]
44
46
  def status_running?(status)
45
- return true if (status.to_i & STATUS_RUNNING) > 0
47
+ return true if (status.to_i & STATUS_RUNNING).positive?
46
48
 
47
49
  false
48
50
  end
@@ -70,7 +72,7 @@ module SFRest
70
72
  # @param [Integer] status
71
73
  # @return [Boolean]
72
74
  def status_done?(status)
73
- return true if (status.to_i & STATUS_DONE) > 0
75
+ return true if (status.to_i & STATUS_DONE).positive?
74
76
 
75
77
  false
76
78
  end
@@ -207,7 +209,7 @@ module SFRest
207
209
  # Get a specific task's logs
208
210
  # @param [Integer] task_id
209
211
  def get_task_logs(task_id)
210
- current_path = '/api/v1/tasks/' << task_id.to_s << '/logs'
212
+ current_path = "/api/v1/tasks/#{task_id}/logs"
211
213
  @conn.get(current_path)
212
214
  end
213
215
 
@@ -220,8 +222,8 @@ module SFRest
220
222
  begin
221
223
  res = @conn.get(current_path)
222
224
  paused = res['wip_pause_global']
223
- rescue SFRest::SFError => error
224
- paused = false if error.message =~ /Variable not found/
225
+ rescue SFRest::SFError => e
226
+ paused = false if e.message =~ /Variable not found/
225
227
  end
226
228
  paused
227
229
  end
@@ -231,7 +233,7 @@ module SFRest
231
233
  # @param [Integer] task_id
232
234
  # @param [String] level family|task
233
235
  def pause_task(task_id, level = 'family')
234
- current_path = '/api/v1/pause/' << task_id.to_s
236
+ current_path = "/api/v1/pause/#{task_id}"
235
237
  payload = { 'paused' => true, 'level' => level }.to_json
236
238
  @conn.post(current_path, payload)
237
239
  end
@@ -241,7 +243,7 @@ module SFRest
241
243
  # @param [Integer] task_id
242
244
  # @param [String] level family|task
243
245
  def resume_task(task_id, level = 'family')
244
- current_path = '/api/v1/pause/' << task_id.to_s
246
+ current_path = "/api/v1/pause/#{task_id}"
245
247
  payload = { 'paused' => false, 'level' => level }.to_json
246
248
  @conn.post(current_path, payload)
247
249
  end
@@ -259,7 +261,7 @@ module SFRest
259
261
  # This will delete the task and its children
260
262
  # @param [Integer] task_id
261
263
  def delete_task(task_id)
262
- current_path = '/api/v1/tasks/' << task_id.to_s
264
+ current_path = "/api/v1/tasks/#{task_id}"
263
265
  @conn.delete(current_path)
264
266
  end
265
267
 
@@ -267,7 +269,7 @@ module SFRest
267
269
  # @param [String] type softpaused | softpause-for-update
268
270
  # @return [Array] Array of wip classes
269
271
  def get_task_class_info(type = '')
270
- current_path = '/api/v1/classes/' << type
272
+ current_path = "/api/v1/classes/#{type}"
271
273
  @conn.get(current_path)
272
274
  end
273
275
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Tell the Factory that there is theme work to do
3
5
  class Theme
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Drive updates on the Site Factory
3
5
  class Update
@@ -24,7 +26,7 @@ module SFRest
24
26
 
25
27
  # Lists vcs refs.
26
28
  def list_vcs_refs(type = 'sites', stack_id = 1)
27
- 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}"
28
30
  @conn.get(current_path)
29
31
  end
30
32
 
@@ -69,7 +71,7 @@ module SFRest
69
71
 
70
72
  # Gets the progress of an update by id.
71
73
  def update_progress(update_id)
72
- current_path = '/api/v1/update/' + update_id.to_s + '/status'
74
+ current_path = "/api/v1/update/#{update_id}/status"
73
75
  @conn.get(current_path)
74
76
  end
75
77
 
@@ -107,7 +109,7 @@ module SFRest
107
109
  begin
108
110
  @conn.post '/api/v2/update', '{}'
109
111
  rescue SFRest::BadRequestError
110
- return @has_v2_endpoint = true
112
+ @has_v2_endpoint = true
111
113
  rescue SFRest::InvalidResponse => e
112
114
  return @has_v2_endpoint = false if e.message =~ /Invalid data, status 404/
113
115
 
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Get all the audit devents.
3
5
  class Usage
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Do User actions within the Site Factory
3
5
  class User
@@ -14,7 +16,7 @@ module SFRest
14
16
  not_done = true
15
17
  count = 0
16
18
  while not_done
17
- current_path = '/api/v1/users?page=' << page.to_s
19
+ current_path = "/api/v1/users?page=#{page}"
18
20
  res = @conn.get(current_path)
19
21
  if res['users'] == []
20
22
  not_done = false
@@ -39,14 +41,14 @@ module SFRest
39
41
  # @return [Integer] the uid of the drupal user
40
42
  def get_user_id(username)
41
43
  pglimit = 100
42
- res = @conn.get('/api/v1/users&limit=' + pglimit.to_s)
44
+ res = @conn.get("/api/v1/users&limit=#{pglimit}")
43
45
  usercount = res['count'].to_i
44
46
  id = user_data_from_results(res, username, 'uid')
45
47
  return id if id
46
48
 
47
49
  pages = (usercount / pglimit) + 1
48
50
  2.upto(pages) do |i|
49
- 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}")
50
52
  id = user_data_from_results(res, username, 'uid')
51
53
  return id if id
52
54
  end
@@ -70,7 +72,7 @@ module SFRest
70
72
  # @param [int] uid site id
71
73
  # @return [Hash]
72
74
  def get_user_data(uid)
73
- @conn.get('/api/v1/users/' + uid.to_s)
75
+ @conn.get("/api/v1/users/#{uid}")
74
76
  end
75
77
 
76
78
  # Creates a user.
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Perform actions against variables in the Factory
3
5
  class Variable
@@ -14,7 +16,7 @@ module SFRest
14
16
 
15
17
  # Gets the value of a specific variable.
16
18
  def get_variable(name)
17
- current_path = '/api/v1/variables?name=' << name
19
+ current_path = "/api/v1/variables?name=#{name}"
18
20
  @conn.get(current_path)
19
21
  end
20
22
 
@@ -1,4 +1,6 @@
1
+ # frozen_string_literal: true
2
+
1
3
  module SFRest
2
4
  # Just tracks the version of sfrest.
3
- VERSION = '0.0.25'.freeze
5
+ VERSION = '0.0.30'
4
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.25
4
+ version: 0.0.30
5
5
  platform: ruby
6
6
  authors:
7
7
  - ACSF Engineering
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-20 00:00:00.000000000 Z
11
+ date: 2019-08-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -70,32 +70,32 @@ 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
- email:
98
+ email:
99
99
  executables: []
100
100
  extensions: []
101
101
  extra_rdoc_files: []
@@ -125,7 +125,7 @@ homepage: http://github.com/acquia/sf-sdk-ruby
125
125
  licenses:
126
126
  - APACHE-2.0
127
127
  metadata: {}
128
- post_install_message:
128
+ post_install_message:
129
129
  rdoc_options: []
130
130
  require_paths:
131
131
  - lib
@@ -140,8 +140,8 @@ 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
144
- signing_key:
143
+ rubygems_version: 3.0.8
144
+ signing_key:
145
145
  specification_version: 4
146
146
  summary: Acquia Site Factory Rest API.
147
147
  test_files: []