forked from pantheon-deprecated/terminus-deprecated
-
Notifications
You must be signed in to change notification settings - Fork 0
/
terminus.user.api.inc
260 lines (216 loc) · 5.38 KB
/
terminus.user.api.inc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
<?php
/**
* @file
* API functions for User Integration
*/
/**
* API Call to Get One User's Data
*/
function terminus_api_user_get($user_uuid) {
$realm = 'user';
$uuid = $user_uuid;
$path = '';
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Get a User Profile
*/
function terminus_api_user_profile_get($user_uuid) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'profile';
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Get a User Organizations
*
* TODO: this should be handled as part of the overall user_get
*/
function terminus_api_user_organizations_get($user_uuid) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'organizations';
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Set a User Profile
*/
function terminus_api_user_profile_set($user_uuid, $profile) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'profile';
$method = 'PUT';
$data = $profile;
return terminus_request($realm, $uuid, $path, $method, $data);
}
/**
* API Call to Update/Patch a User Profile
*/
function terminus_api_user_profile_update($user_uuid, $profile) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'profile';
$method = 'PATCH';
$data = $profile;
return terminus_request($realm, $uuid, $path, $method, $data);
}
/**
* API Call to Get a Field from a User Profile
*/
function terminus_api_user_profile_get_attribute($user_uuid, $attribute) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'profile/' . $attribute;
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method, $data);
}
/**
* API Call to Set a Field from a User Profile
*/
function terminus_api_user_profile_set_attribute($user_uuid, $attribute, $value) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'profile/' . $attribute;
$method = 'PUT';
$data = $value;
return terminus_request($realm, $uuid, $path, $method, $data);
}
/**
* API Call to Set a User's Password
*/
function terminus_api_user_password_set($user_uuid, $password) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'password';
$method = 'PUT';
$data = $password;
return terminus_request($realm, $uuid, $path, $method, $data);
}
/**
* API Call to Get a User's Email
* Note - No logging!
*/
function terminus_api_user_email_get($user_uuid) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'email';
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Get a User's UUID
* NOTE - No logging!
*/
function terminus_api_user_uuid_get($email) {
$realm = 'user';
$uuid = $user_uuid;
$path = rawurlencode($email) . '/uuid';
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Check a User's Email by Email
* NOTE - No logging!
*/
function terminus_api_user_email_check_by_email($email) {
$realm = 'user';
$uuid = $user_uuid;
$path = rawurlencode($email) . '/email';
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Set a User's Email
*/
function terminus_api_user_email_set($user_uuid, $email) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'email';
$method = 'PUT';
$data = $email;
return terminus_request($realm, $uuid, $path, $method, $data);
}
/**
* API Call to Delete a User
*/
function terminus_api_user_delete($user_uuid) {
$realm = 'user';
$uuid = $user_uuid;
$method = 'DELETE';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Get a User's SSH Keys
*/
function terminus_api_user_sshkey_get($user_uuid) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'keys';
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Delete a User's SSH Keys
*/
function terminus_api_user_sshkey_delete_all($user_uuid) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'keys';
$method = 'DELETE';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Add a SSH Key to a User
*/
function terminus_api_user_sshkey_add($user_uuid, $sshkey) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'keys';
$method = 'POST';
$data = $sshkey;
return terminus_request($realm, $uuid, $path, $method, $data);
}
/**
* API Call to Delete a Specific SSH for a User
*/
function terminus_api_user_sshkey_delete_key($user_uuid, $sshkey_fingerprint) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'keys/' . $sshkey_fingerprint;
$method = 'DELETE';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Call to Add and Validate SSH Key
*/
function terminus_api_sshkey_validate($user_uuid, $sshkey) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'keys?validate=true';
$method = 'POST';
$data = $sshkey;
return terminus_request($realm, $uuid, $path, $method, $data);
}
/**
* API Function to Get List of Sites a User is a Team Member of
*/
function terminus_api_user_site_list($user_uuid) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'sites';
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method);
}
/**
* API Function to Get List of Sites Owned by a User
*/
function terminus_api_user_owned_list($user_uuid) {
$realm = 'user';
$uuid = $user_uuid;
$path = 'sites?owned=1';
$method = 'GET';
return terminus_request($realm, $uuid, $path, $method, $data);
}