sfrest 0.0.30 → 0.0.35

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: e5d935fa06aa4609da0f2a5216400ebc8b88ca7e5d973962f5834b83390ff516
4
- data.tar.gz: 2d532f771e96c443e41c0184ff03d2af957a1759ce8207eb99c75fa90cf9e99c
3
+ metadata.gz: 16898910d9454541990159add8a5ad32b5bf07f0538a8c35c86c0abc448c2f60
4
+ data.tar.gz: 614c622674db0cbae5bd91db694c71afb526ebcc2d698b10fe845a6366924480
5
5
  SHA512:
6
- metadata.gz: 0ced957ae4b74d3e968794cc4f7aebd061f278fe30f240fb04dc0fd2c4d3c90d23591972433c17005e923dddbaa2e9e690bf2c164225c60e203718c4b2f47a83
7
- data.tar.gz: 3bc8c3d799abbae1467c404b4cab407e7e23fec78fdc4d4651e91e73bedafd335cedc8c9b6a052e4bdf5daf2905f490e274b963bfb67e130d464abccb0a1449f
6
+ metadata.gz: 29ef2feca8cd6d6bb3a78efa6ebef26cea4c6fd52aad8b05d3a859582047a9f263fca0f58526b28c35b01197d66b3bb7d373aa6a494b08a716040d99bb43f8dc
7
+ data.tar.gz: 62303e0c264dbddec7652a8d6ab45b75f6ba9bd701bf5e565c74cf9e9048d53c783863472e480cc99772c63e8dc9db5b5592c072524a123cc9e8f9ea4e675d4e
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
@@ -61,5 +61,22 @@ module SFRest
61
61
  payload = { 'domain_name' => domain_name }.to_json
62
62
  @conn.post("/api/v1/domains/#{node_id}/remove", payload)
63
63
  end
64
+
65
+ # Get domain status
66
+ # @param [String] domain_name domain to remove. e.g. www.example.com
67
+ #
68
+ # @return [Hash] { "message" => "The domain is associated with the node.",
69
+ # "is_domain_associated" => TRUE,
70
+ # "node_id" => 123,
71
+ # "node_type" => "site",
72
+ # "time" => "2016-10-28T09:25:26+00:00",
73
+ # "stack_id" => 1,
74
+ # "domains" => array(
75
+ # "protected_domains" => array('site.example.sfdev.acquia-test.co'),
76
+ # "custom_domains" => array('www.abc.com/def', 'www.xyz.com'),
77
+ # ) }
78
+ def status(domain_name)
79
+ @conn.get("/api/v1/domains/status/#{domain_name}")
80
+ end
64
81
  end
65
82
  end
data/lib/sfrest/group.rb CHANGED
@@ -159,5 +159,13 @@ module SFRest
159
159
  end
160
160
  nil
161
161
  end
162
+
163
+ # Returns sites belonging to a specified group id.
164
+ # @param [Integer] group_id Id of the group to fetch
165
+ # @return [Hash] {'count' => count, 'sites' => Hash }
166
+ def sites(group_id = 0)
167
+ current_path = "/api/v1/groups/#{group_id}/sites"
168
+ @conn.get(current_path)
169
+ end
162
170
  end
163
171
  end
@@ -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.
data/lib/sfrest/stage.rb CHANGED
@@ -37,11 +37,11 @@ module SFRest
37
37
  # @return [Integer] Id of the staging task created.
38
38
  # rubocop:disable Metrics/ParameterLists
39
39
  def enhanced_stage(env: 'test',
40
- sites: nil,
40
+ sites: [],
41
41
  email_site_status: false,
42
42
  wipe_target_environment: false,
43
43
  synchronize_all_users: true,
44
- wipe_stacks: nil)
44
+ wipe_stacks: [])
45
45
  raise InvalidApiVersion, staging_versions unless staging_versions.include? 2
46
46
 
47
47
  payload = { 'to_env' => env, 'sites' => sites,
@@ -2,5 +2,5 @@
2
2
 
3
3
  module SFRest
4
4
  # Just tracks the version of sfrest.
5
- VERSION = '0.0.30'
5
+ VERSION = '0.0.35'
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.30
4
+ version: 0.0.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - ACSF Engineering
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-08-27 00:00:00.000000000 Z
11
+ date: 2021-06-23 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
@@ -140,7 +141,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
141
  - !ruby/object:Gem::Version
141
142
  version: '0'
142
143
  requirements: []
143
- rubygems_version: 3.0.8
144
+ rubygems_version: 3.0.3
144
145
  signing_key:
145
146
  specification_version: 4
146
147
  summary: Acquia Site Factory Rest API.