sfrest 0.0.24 → 0.0.25
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sfrest/connection.rb +4 -2
- data/lib/sfrest/group.rb +84 -0
- data/lib/sfrest/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 454094d1aed9e441d633a8f69733518952f014a1aefa8246f5bf00cc659d4a34
|
4
|
+
data.tar.gz: 0de73fa9d7a32b350d78237e95b90630544952695b189d74576f6ef2c5f52107
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7bbc97856c5e30f44327d8c1cda39ed695e015b67afe5fcce668100c04b0ac9adb75f2a5c7254c978341d03342e298df039c4d2d4446cbebaa377e993b9981d4
|
7
|
+
data.tar.gz: 7dd69e1115edda16ec71d2a0954fc807364e4359c7f834a6c0cf8aae1709f41f31e24c57ba0f103a8dccf669c4fa51730fe6f82a07ea501636dc9528d354d43a
|
data/lib/sfrest/connection.rb
CHANGED
@@ -77,16 +77,18 @@ module SFRest
|
|
77
77
|
|
78
78
|
# http request via delete
|
79
79
|
# @param [string] uri
|
80
|
+
# @param [string] payload - This string will be supplied in the body of the request, similar to POST.
|
80
81
|
# @return [Object] ruby representation of the json response
|
81
82
|
# if the reponse body does not parse, raises
|
82
83
|
# a SFRest::InvalidResponse
|
83
|
-
def delete(uri)
|
84
|
+
def delete(uri, payload = '')
|
84
85
|
headers = { 'Content-Type' => 'application/json' }
|
85
86
|
res = Excon.delete(@base_url + uri.to_s,
|
86
87
|
headers: headers,
|
87
88
|
user: username,
|
88
89
|
password: password,
|
89
|
-
ssl_verify_peer: false
|
90
|
+
ssl_verify_peer: false,
|
91
|
+
body: payload)
|
90
92
|
api_response res
|
91
93
|
end
|
92
94
|
|
data/lib/sfrest/group.rb
CHANGED
@@ -15,6 +15,22 @@ module SFRest
|
|
15
15
|
@conn.post(current_path, payload)
|
16
16
|
end
|
17
17
|
|
18
|
+
# Deletes the group with the specified id
|
19
|
+
# @param [Integer] group_id Id of the group to fetch
|
20
|
+
def delete_group(group_id)
|
21
|
+
current_path = '/api/v1/groups/' << group_id.to_s
|
22
|
+
@conn.delete(current_path)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Renames existing group.
|
26
|
+
# @param [Integer] group_id Id of the group to rename.
|
27
|
+
# @param [String] groupname New name for the group.
|
28
|
+
def rename_group(group_id, groupname)
|
29
|
+
current_path = '/api/v1/groups/' + group_id.to_s + '/update'
|
30
|
+
payload = { 'group_name' => groupname }.to_json
|
31
|
+
@conn.put(current_path, payload)
|
32
|
+
end
|
33
|
+
|
18
34
|
# Gets a site group with a specified group id.
|
19
35
|
# @param [Integer] group_id Id of the group to fetch
|
20
36
|
# @return [Hash] group object from the SF Api
|
@@ -23,6 +39,74 @@ module SFRest
|
|
23
39
|
@conn.get(current_path)
|
24
40
|
end
|
25
41
|
|
42
|
+
# Gets all users that are members of this group
|
43
|
+
# @param [Integer] group_id Id of the group to fetch
|
44
|
+
# @return [Hash] {'count' => count, 'members' => Hash }
|
45
|
+
def get_members(group_id = 0)
|
46
|
+
current_path = '/api/v1/groups/' + group_id.to_s + '/members'
|
47
|
+
@conn.get(current_path)
|
48
|
+
end
|
49
|
+
|
50
|
+
# Add users to this group
|
51
|
+
# @param [Integer] group_id Id of the group
|
52
|
+
# @param [Array] uids of the users that need to be added
|
53
|
+
# @return [Hash] {'count' => count, 'uids_added' => Hash }
|
54
|
+
def add_members(group_id, uids)
|
55
|
+
current_path = '/api/v1/groups/' + group_id.to_s + '/members'
|
56
|
+
payload = { 'uids' => uids.map(&:to_i) }.to_json
|
57
|
+
@conn.post(current_path, payload)
|
58
|
+
end
|
59
|
+
|
60
|
+
# Remove members from this group
|
61
|
+
# @param [Integer] group_id Id of the group
|
62
|
+
# @param [Array] uids of the users that need to be removed
|
63
|
+
# @return [Hash] {'group_id' => 123, 'uids_removed' => [1, 2, ...]}
|
64
|
+
def remove_members(group_id, uids)
|
65
|
+
current_path = '/api/v1/groups/' + group_id.to_s + '/members'
|
66
|
+
payload = { 'uids' => uids.map(&:to_i) }.to_json
|
67
|
+
@conn.delete(current_path, payload)
|
68
|
+
end
|
69
|
+
|
70
|
+
# Promote users to group admins
|
71
|
+
# @param [Integer] group_id Id of the group
|
72
|
+
# @param [Array] uids of the users that need to be promoted
|
73
|
+
# @return [Hash] {'count' => count, 'uids_promoted' => [1, 2, ...] }
|
74
|
+
def promote_to_admins(group_id, uids)
|
75
|
+
current_path = '/api/v1/groups/' + group_id.to_s + '/admins'
|
76
|
+
payload = { 'uids' => uids.map(&:to_i) }.to_json
|
77
|
+
@conn.post(current_path, payload)
|
78
|
+
end
|
79
|
+
|
80
|
+
# Demote users from group admins
|
81
|
+
# @param [Integer] group_id Id of the group
|
82
|
+
# @param [Array] uids of the users that need to be demoted
|
83
|
+
# @return [Hash] {'count' => count, 'uids_demoted' => Hash }
|
84
|
+
def demote_from_admins(group_id, uids)
|
85
|
+
current_path = '/api/v1/groups/' + group_id.to_s + '/admins'
|
86
|
+
payload = { 'uids' => uids.map(&:to_i) }.to_json
|
87
|
+
@conn.delete(current_path, payload)
|
88
|
+
end
|
89
|
+
|
90
|
+
# Add sites to this group
|
91
|
+
# @param [Integer] group_id Id of the group
|
92
|
+
# @param [Array] site_ids Ids of the sites that need to be added
|
93
|
+
# @return [Hash] {'group_id' => 123, 'site_ids_added' => [1, 2, ...]}
|
94
|
+
def add_sites(group_id, site_ids)
|
95
|
+
current_path = '/api/v1/groups/' + group_id.to_s + '/sites'
|
96
|
+
payload = { 'site_ids' => site_ids }.to_json
|
97
|
+
@conn.post(current_path, payload)
|
98
|
+
end
|
99
|
+
|
100
|
+
# Remove sites from this group
|
101
|
+
# @param [Integer] group_id Id of the group
|
102
|
+
# @param [Array] site_ids Ids of the sites that need to be removed.
|
103
|
+
# @return [Hash] {'group_id' => 123, 'site_ids_removed' => [1, 2, ...], 'site_ids_failed' => [3, 4, ...]}
|
104
|
+
def remove_sites(group_id, site_ids)
|
105
|
+
current_path = '/api/v1/groups/' + group_id.to_s + '/sites'
|
106
|
+
payload = { 'site_ids' => site_ids }.to_json
|
107
|
+
@conn.delete(current_path, payload)
|
108
|
+
end
|
109
|
+
|
26
110
|
# Gets a list of all site groups.
|
27
111
|
# @return [Hash] all the groups on the factory plus a count
|
28
112
|
# {'count' => count, 'groups' => Hash }
|
data/lib/sfrest/version.rb
CHANGED
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.
|
4
|
+
version: 0.0.25
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- ACSF Engineering
|
@@ -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.
|
143
|
+
rubygems_version: 3.0.3
|
144
144
|
signing_key:
|
145
145
|
specification_version: 4
|
146
146
|
summary: Acquia Site Factory Rest API.
|