sfrest 0.0.17 → 0.0.18

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: 94bd205352e9ec9465614828f2a5bb1b602217568ca5135b4c30223f0f16ec63
4
- data.tar.gz: 9fdbde3ff4ba1b1811625b2eb48a3aa22c1f54e652747dc6ab6adf2fb3875348
3
+ metadata.gz: a349a8e1263871b5dde41d43c20abaa63b5fdf1894e0e08ca88f8d3ac4a05a10
4
+ data.tar.gz: 225785f5a1d526dedc9f1a5ae42c00c5633a618406907f4553399578c628b001
5
5
  SHA512:
6
- metadata.gz: ce166dabdbc263441fc183a38f5b85700c0775a2b69249b2587c42950c441a6bf701814b786ebb1f307412dce7b9b357aaeda7b060c89bfea9259a0650bf2646
7
- data.tar.gz: 7f98365d4da5f5121040b63fc6db432e3f67b2b368e365fef6f477c76de811fc5c8f6ba985fbe38e38acb660268b5b5833868c26d258534e050177078d57168e
6
+ metadata.gz: 350236e48e8d08f2bef2a7bdfd39c88c75390f5ef14e75a403fe096d610d9ed3ae74cb510b7719bdd2c42ba511a1aeb63b11c5d6df50c1150ee75923d3afb80b
7
+ data.tar.gz: a2f39e36afffd783303c9fd10f69374778e8f51f4df32b2d3afc7405beef2c4a2c1e89ae91b1442c08e6105935293e01d9557a40b0c284382bbe0b496f707f48
data/lib/sfrest/error.rb CHANGED
@@ -25,4 +25,8 @@ module SFRest
25
25
 
26
26
  # If the return cannot be parsed into something useful
27
27
  class InvalidResponse < SFRest::SFError; end
28
+
29
+ # If you call an unsuported version
30
+ #
31
+ class InvalidApiVersion < SFRest::SFError; end
28
32
  end
data/lib/sfrest/site.rb CHANGED
@@ -112,5 +112,13 @@ module SFRest
112
112
  def backup
113
113
  @conn.backup
114
114
  end
115
+
116
+ # Clears the caches for a site.
117
+ # @param [Integer] site_id The id of the site to be cleared
118
+ # @return [Hash]
119
+ def cache_clear(site_id)
120
+ current_path = "/api/v1/sites/#{site_id}/cache-clear"
121
+ @conn.post current_path, nil
122
+ end
115
123
  end
116
124
  end
data/lib/sfrest/stage.rb CHANGED
@@ -14,18 +14,56 @@ module SFRest
14
14
  #
15
15
  # @return [Integer] Id of the staging task created.
16
16
  def stage(to_env = 'test', sites = nil, email_site_status = false, skip_gardener = false)
17
+ raise InvalidApiVersion, staging_versions unless staging_versions.include? 1
17
18
  payload = { 'to_env' => to_env, 'sites' => sites,
18
19
  'detailed_status' => email_site_status,
19
20
  'skip_gardener' => skip_gardener }.to_json
20
21
  @conn.post('/api/v1/stage', payload)
21
22
  end
22
23
 
24
+ # Stage a site using the new method
25
+ # @param [String] to_env the name of of target env. defaults to test
26
+ # @param [Array] sites Array of site nids to stage
27
+ # @param [Boolean] email_site_status send an email about the staging status of each site
28
+ # @param [Boolean] wipe_target_environment recreate the target stage wiping all data
29
+ # @param [synchronize_all_users] only stage the user accounts required for the related collections and groups
30
+ #
31
+ # @return [Integer] Id of the staging task created.
32
+ def enhanced_stage(env: 'test',
33
+ sites: nil,
34
+ email_site_status: false,
35
+ wipe_target_environment: false,
36
+ synchronize_all_users: true)
37
+ raise InvalidApiVersion, staging_versions unless staging_versions.include? 2
38
+ payload = { 'to_env' => env, 'sites' => sites,
39
+ 'detailed_status' => email_site_status,
40
+ 'wipe_target_environment' => wipe_target_environment,
41
+ 'synchronize_all_users' => synchronize_all_users }.to_json
42
+ @conn.post('/api/v2/stage', payload)
43
+ end
44
+
23
45
  # Query for available staging environments
24
46
  #
25
47
  # @return environments
26
48
  def list_staging_environments
27
- current_path = '/api/v1/stage'
49
+ current_path = "/api/v#{staging_versions.sample}/stage"
28
50
  @conn.get(current_path)
29
51
  end
52
+
53
+ # determine what version are available for staging
54
+ # @return [Array] Array of available api endpoints
55
+ def staging_versions
56
+ possible_versions = [1, 2]
57
+ @versions ||= []
58
+ possible_versions.each do |version|
59
+ begin
60
+ @conn.get "/api/v#{version}/stage"
61
+ @versions.push version
62
+ rescue SFRest::InvalidResponse
63
+ nil
64
+ end
65
+ end
66
+ @versions
67
+ end
30
68
  end
31
69
  end
data/lib/sfrest/task.rb CHANGED
@@ -18,6 +18,15 @@ module SFRest
18
18
  @conn = conn
19
19
  end
20
20
 
21
+ # Returns true only if the status evaluates to not started
22
+ # or restarted
23
+ # @param [Integer] status
24
+ # @return [Boolean]
25
+ def status_not_started?(status)
26
+ return true if (status.to_i & STATUS_TO_BE_RUN) > 0
27
+ false
28
+ end
29
+
21
30
  # Returns true only if the status evaluates to completed
22
31
  # @param [Integer] status
23
32
  # @return [Boolean]
@@ -71,6 +80,15 @@ module SFRest
71
80
  res['wip_task']['status']
72
81
  end
73
82
 
83
+ # Returns true only if WIP reports the status as not started
84
+ # or restarted
85
+ # @param [Integer] task_id
86
+ # @return [Boolean]
87
+ def task_not_started?(task_id)
88
+ status = task_status task_id
89
+ status_not_started?(status)
90
+ end
91
+
74
92
  # Returns true only if WIP reports the status as running
75
93
  # @param [Integer] task_id
76
94
  # @return [Boolean]
@@ -220,6 +238,23 @@ module SFRest
220
238
  @conn.post(current_path, payload)
221
239
  end
222
240
 
241
+ # Terminates a specific task identified by its task id.
242
+ # This will terminate the task and its children
243
+ # @param [Integer] task_id
244
+ def terminate_task(task_id)
245
+ current_path = "/api/v1/tasks/#{task_id}/terminate"
246
+ payload = nil
247
+ @conn.put(current_path, payload)
248
+ end
249
+
250
+ # Deletes a specific task identified by its task id.
251
+ # This will delete the task and its children
252
+ # @param [Integer] task_id
253
+ def delete_task(task_id)
254
+ current_path = '/api/v1/tasks/' << task_id.to_s
255
+ @conn.delete(current_path)
256
+ end
257
+
223
258
  # returns the classes that are either softpaused or softpause-for-update
224
259
  # @param [String] type softpaused | softpause-for-update
225
260
  # @return [Array] Array of wip classes
@@ -1,4 +1,4 @@
1
1
  module SFRest
2
2
  # Just tracks the version of sfrest.
3
- VERSION = '0.0.17'.freeze
3
+ VERSION = '0.0.18'.freeze
4
4
  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.17
4
+ version: 0.0.18
5
5
  platform: ruby
6
6
  authors:
7
7
  - ACSF Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-02-26 00:00:00.000000000 Z
11
+ date: 2018-05-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: excon
@@ -141,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  version: '0'
142
142
  requirements: []
143
143
  rubyforge_project:
144
- rubygems_version: 2.7.4
144
+ rubygems_version: 2.7.6
145
145
  signing_key:
146
146
  specification_version: 4
147
147
  summary: Acquia Site Factory Rest API.