Total Complexity | 64 |
Total Lines | 1085 |
Duplicated Lines | 0 % |
Changes | 15 | ||
Bugs | 0 | Features | 0 |
Complex classes like Client often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
While breaking up the class, it is a good idea to analyze how other classes use Client, and based on these observations, apply Extract Interface, too.
1 | <?php |
||
34 | class Client implements ClientInterface |
||
35 | { |
||
36 | /** @var ConnectorInterface The API connector. */ |
||
37 | protected $connector; |
||
38 | |||
39 | /** @var array Query strings to be applied to the request. */ |
||
40 | protected $query = []; |
||
41 | |||
42 | /** |
||
43 | * Client constructor. |
||
44 | * |
||
45 | * @param ConnectorInterface $connector |
||
46 | */ |
||
47 | public function __construct(ConnectorInterface $connector) |
||
50 | } |
||
51 | |||
52 | /** |
||
53 | * Client factory method for instantiating . |
||
54 | * |
||
55 | * @param ConnectorInterface $connector |
||
56 | * |
||
57 | * @return static |
||
58 | */ |
||
59 | public static function factory(ConnectorInterface $connector) |
||
60 | { |
||
61 | $client = new static( |
||
62 | $connector |
||
63 | ); |
||
64 | |||
65 | return $client; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * Get query from Client. |
||
70 | * |
||
71 | * @return array |
||
72 | */ |
||
73 | public function getQuery() |
||
74 | { |
||
75 | return $this->query; |
||
76 | } |
||
77 | |||
78 | /** |
||
79 | * Clear query. |
||
80 | */ |
||
81 | public function clearQuery() |
||
82 | { |
||
83 | $this->query = []; |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Add a query parameter to filter results. |
||
88 | * |
||
89 | * @param string $name |
||
90 | * @param string $value |
||
91 | */ |
||
92 | public function addQuery($name, $value) |
||
93 | { |
||
94 | $this->query = array_merge_recursive($this->query, [$name => $value]); |
||
95 | } |
||
96 | |||
97 | /** |
||
98 | * Returns details about your account. |
||
99 | * |
||
100 | * @return AccountResponse |
||
101 | */ |
||
102 | public function account() |
||
105 | } |
||
106 | |||
107 | /** |
||
108 | * Shows all applications. |
||
109 | * |
||
110 | * @return ApplicationsResponse |
||
111 | */ |
||
112 | public function applications() |
||
113 | { |
||
114 | return new ApplicationsResponse($this->connector->request('get', '/applications', $this->query)); |
||
115 | } |
||
116 | |||
117 | /** |
||
118 | * Shows information about an application. |
||
119 | * |
||
120 | * @param string $applicationUuid |
||
121 | * @return ApplicationResponse |
||
122 | */ |
||
123 | public function application($applicationUuid) |
||
124 | { |
||
125 | return new ApplicationResponse( |
||
126 | $this->connector->request( |
||
127 | 'get', |
||
128 | "/applications/${applicationUuid}", |
||
129 | $this->query |
||
130 | ) |
||
131 | ); |
||
132 | } |
||
133 | |||
134 | /** |
||
135 | * Renames an application. |
||
136 | * |
||
137 | * @param string $applicationUuid |
||
138 | * @param string $name |
||
139 | * @return OperationResponse |
||
140 | */ |
||
141 | public function renameApplication($applicationUuid, $name) |
||
142 | { |
||
143 | |||
144 | $options = [ |
||
145 | 'form_params' => [ |
||
146 | 'name' => $name, |
||
147 | ], |
||
148 | ]; |
||
149 | |||
150 | return new OperationResponse( |
||
151 | $this->connector->request( |
||
152 | 'put', |
||
153 | "/applications/${applicationUuid}", |
||
154 | $options, |
||
155 | $this->query |
||
156 | ) |
||
157 | ); |
||
158 | } |
||
159 | |||
160 | /** |
||
161 | * Shows all code branches and tags in an application. |
||
162 | * |
||
163 | * @param string $applicationUuid |
||
164 | * @return BranchesResponse |
||
165 | */ |
||
166 | public function code($applicationUuid) |
||
167 | { |
||
168 | return new BranchesResponse( |
||
169 | $this->connector->request( |
||
170 | 'get', |
||
171 | "/applications/${applicationUuid}/code", |
||
172 | $this->query |
||
173 | ) |
||
174 | ); |
||
175 | } |
||
176 | |||
177 | /** |
||
178 | * Shows all databases in an application. |
||
179 | * |
||
180 | * @param string $applicationUuid |
||
181 | * @return DatabasesResponse |
||
182 | */ |
||
183 | public function databases($applicationUuid) |
||
184 | { |
||
185 | return new DatabasesResponse( |
||
186 | $this->connector->request( |
||
187 | 'get', |
||
188 | "/applications/${applicationUuid}/databases", |
||
189 | $this->query |
||
190 | ) |
||
191 | ); |
||
192 | } |
||
193 | |||
194 | /** |
||
195 | * Shows all databases in an environment. |
||
196 | * |
||
197 | * @param string $environmentUuid |
||
198 | * @return DatabasesResponse |
||
199 | */ |
||
200 | public function environmentDatabases($environmentUuid) |
||
201 | { |
||
202 | return new DatabasesResponse( |
||
203 | $this->connector->request( |
||
204 | 'get', |
||
205 | "/environments/${environmentUuid}/databases", |
||
206 | $this->query |
||
207 | ) |
||
208 | ); |
||
209 | } |
||
210 | |||
211 | /** |
||
212 | * Copies a database from an environment to an environment. |
||
213 | * |
||
214 | * @param string $environmentFromUuid |
||
215 | * @param string $dbName |
||
216 | * @param string $environmentToUuid |
||
217 | * @return OperationResponse |
||
218 | */ |
||
219 | public function databaseCopy($environmentFromUuid, $dbName, $environmentToUuid) |
||
220 | { |
||
221 | $options = [ |
||
222 | 'form_params' => [ |
||
223 | 'name' => $dbName, |
||
224 | 'source' => $environmentFromUuid, |
||
225 | ], |
||
226 | ]; |
||
227 | |||
228 | return new OperationResponse( |
||
229 | $this->connector->request('post', "/environments/${environmentToUuid}/databases", $this->query, $options) |
||
230 | ); |
||
231 | } |
||
232 | |||
233 | /** |
||
234 | * Create a new database. |
||
235 | * |
||
236 | * @param string $applicationUuid |
||
237 | * @param string $name |
||
238 | * @return OperationResponse |
||
239 | */ |
||
240 | public function databaseCreate($applicationUuid, $name) |
||
241 | { |
||
242 | $options = [ |
||
243 | 'form_params' => [ |
||
244 | 'name' => $name, |
||
245 | ], |
||
246 | ]; |
||
247 | |||
248 | return new OperationResponse( |
||
249 | $this->connector->request('post', "/applications/${applicationUuid}/databases", $this->query, $options) |
||
250 | ); |
||
251 | } |
||
252 | |||
253 | /** |
||
254 | * Delete a database. |
||
255 | * |
||
256 | * @param string $applicationUuid |
||
257 | * @param string $name |
||
258 | * @return OperationResponse |
||
259 | */ |
||
260 | public function databaseDelete($applicationUuid, $name) |
||
261 | { |
||
262 | return new OperationResponse( |
||
263 | $this->connector->request('delete', "/applications/${applicationUuid}/databases/${name}", $this->query) |
||
264 | ); |
||
265 | } |
||
266 | |||
267 | /** |
||
268 | * Backup a database. |
||
269 | * |
||
270 | * @param string $environmentUuid |
||
271 | * @param string $dbName |
||
272 | * @return OperationResponse |
||
273 | */ |
||
274 | public function createDatabaseBackup($environmentUuid, $dbName) |
||
275 | { |
||
276 | return new OperationResponse( |
||
277 | $this->connector->request( |
||
278 | 'post', |
||
279 | "/environments/${environmentUuid}/databases/${dbName}/backups", |
||
280 | $this->query |
||
281 | ) |
||
282 | ); |
||
283 | } |
||
284 | |||
285 | /** |
||
286 | * Shows all database backups in an environment. |
||
287 | * |
||
288 | * @param string $environmentUuid |
||
289 | * @param string $dbName |
||
290 | * @return BackupsResponse |
||
291 | */ |
||
292 | public function databaseBackups($environmentUuid, $dbName) |
||
293 | { |
||
294 | return new BackupsResponse( |
||
295 | $this->connector->request( |
||
296 | 'get', |
||
297 | "/environments/${environmentUuid}/databases/${dbName}/backups", |
||
298 | $this->query |
||
299 | ) |
||
300 | ); |
||
301 | } |
||
302 | |||
303 | /** |
||
304 | * Gets information about a database backup. |
||
305 | * |
||
306 | * @param string $environmentUuid |
||
307 | * @param string $dbName |
||
308 | * @param int $backupId |
||
309 | * @return BackupResponse |
||
310 | */ |
||
311 | public function databaseBackup($environmentUuid, $dbName, $backupId) |
||
312 | { |
||
313 | return new BackupResponse( |
||
314 | $this->connector->request( |
||
315 | 'get', |
||
316 | "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}", |
||
317 | $this->query |
||
318 | ) |
||
319 | ); |
||
320 | } |
||
321 | |||
322 | /** |
||
323 | * Restores a database backup to a database in an environment. |
||
324 | * |
||
325 | * @param string $environmentUuid |
||
326 | * @param string $dbName |
||
327 | * @param int $backupId |
||
328 | * @return OperationResponse |
||
329 | */ |
||
330 | public function restoreDatabaseBackup($environmentUuid, $dbName, $backupId) |
||
331 | { |
||
332 | return new OperationResponse( |
||
333 | $this->connector->request( |
||
334 | 'post', |
||
335 | "/environments/${environmentUuid}/databases/${dbName}/backups/${backupId}/actions/restore", |
||
336 | $this->query |
||
337 | ) |
||
338 | ); |
||
339 | } |
||
340 | |||
341 | /** |
||
342 | * Copies files from an environment to another environment. |
||
343 | * |
||
344 | * @param string $environmentUuidFrom |
||
345 | * @param string $environmentUuidTo |
||
346 | * @return OperationResponse |
||
347 | */ |
||
348 | public function copyFiles($environmentUuidFrom, $environmentUuidTo) |
||
349 | { |
||
350 | $options = [ |
||
351 | 'form_params' => [ |
||
352 | 'source' => $environmentUuidFrom, |
||
353 | ], |
||
354 | ]; |
||
355 | |||
356 | return new OperationResponse( |
||
357 | $this->connector->request('post', "/environments/${environmentUuidTo}/files", $this->query, $options) |
||
358 | ); |
||
359 | } |
||
360 | |||
361 | /** |
||
362 | * Deploys a code branch/tag to an environment. |
||
363 | * |
||
364 | * @param string $environmentUuid |
||
365 | * @param string $branch |
||
366 | * @return OperationResponse |
||
367 | */ |
||
368 | public function switchCode($environmentUuid, $branch) |
||
369 | { |
||
370 | |||
371 | $options = [ |
||
372 | 'form_params' => [ |
||
373 | 'branch' => $branch, |
||
374 | ], |
||
375 | ]; |
||
376 | |||
377 | return new OperationResponse( |
||
378 | $this->connector->request( |
||
379 | 'post', |
||
380 | "/environments/${environmentUuid}/code/actions/switch", |
||
381 | $this->query, |
||
382 | $options |
||
383 | ) |
||
384 | ); |
||
385 | } |
||
386 | |||
387 | /** |
||
388 | * Deploys code from one environment to another environment. |
||
389 | * |
||
390 | * @param string $environmentFromUuid |
||
391 | * @param string $environmentToUuid |
||
392 | * @param string $commitMessage |
||
393 | */ |
||
394 | public function deployCode($environmentFromUuid, $environmentToUuid, $commitMessage = null) |
||
395 | { |
||
396 | |||
397 | $options = [ |
||
398 | 'form_params' => [ |
||
399 | 'source' => $environmentFromUuid, |
||
400 | 'message' => $commitMessage, |
||
401 | ], |
||
402 | ]; |
||
403 | |||
404 | return new OperationResponse( |
||
405 | $this->connector->request( |
||
406 | 'post', |
||
407 | "/environments/${environmentToUuid}/code", |
||
408 | $this->query, |
||
409 | $options |
||
410 | ) |
||
411 | ); |
||
412 | } |
||
413 | |||
414 | /** |
||
415 | * Shows all domains on an environment. |
||
416 | * |
||
417 | * @param string $environmentUuid |
||
418 | * @return DomainsResponse |
||
419 | */ |
||
420 | public function domains($environmentUuid) |
||
427 | ) |
||
428 | ); |
||
429 | } |
||
430 | |||
431 | /** |
||
432 | * Return details about a domain. |
||
433 | * |
||
434 | * @param string $environmentUuid |
||
435 | * @param string $domain |
||
436 | * @return DomainResponse |
||
437 | */ |
||
438 | public function domain($environmentUuid, $domain) |
||
439 | { |
||
440 | return new DomainResponse( |
||
441 | $this->connector->request( |
||
442 | 'get', |
||
443 | "/environments/${environmentUuid}/domains/${domain}", |
||
444 | $this->query |
||
445 | ) |
||
446 | ); |
||
447 | } |
||
448 | |||
449 | /** |
||
450 | * Adds a domain to an environment. |
||
451 | * |
||
452 | * @param string $environmentUuid |
||
453 | * @param string $hostname |
||
454 | * @return OperationResponse |
||
455 | */ |
||
456 | public function createDomain($environmentUuid, $hostname) |
||
457 | { |
||
458 | |||
459 | $options = [ |
||
460 | 'form_params' => [ |
||
461 | 'hostname' => $hostname, |
||
462 | ], |
||
463 | ]; |
||
464 | |||
465 | return new OperationResponse( |
||
466 | $this->connector->request('post', "/environments/${environmentUuid}/domains", $this->query, $options) |
||
467 | ); |
||
468 | } |
||
469 | |||
470 | /** |
||
471 | * Deletes a domain from an environment. |
||
472 | * |
||
473 | * @param string $environmentUuid |
||
474 | * @param string $domain |
||
475 | * @return OperationResponse |
||
476 | */ |
||
477 | public function deleteDomain($environmentUuid, $domain) |
||
478 | { |
||
479 | return new OperationResponse( |
||
480 | $this->connector->request('delete', "/environments/${environmentUuid}/domains/${domain}", $this->query) |
||
481 | ); |
||
482 | } |
||
483 | |||
484 | /** |
||
485 | * Purges varnish for selected domains in an environment. |
||
486 | * |
||
487 | * @param string $environmentUuid |
||
488 | * @param array $domains |
||
489 | * @return OperationResponse |
||
490 | */ |
||
491 | public function purgeVarnishCache($environmentUuid, array $domains) |
||
492 | { |
||
493 | |||
494 | $options = [ |
||
495 | 'form_params' => [ |
||
496 | 'domains' => $domains, |
||
497 | ], |
||
498 | ]; |
||
499 | |||
500 | return new OperationResponse( |
||
501 | $this->connector->request( |
||
502 | 'post', |
||
503 | "/environments/${environmentUuid}/domains/actions/clear-varnish", |
||
504 | $this->query, |
||
505 | $options |
||
506 | ) |
||
507 | ); |
||
508 | } |
||
509 | |||
510 | /** |
||
511 | * Shows all tasks in an application. |
||
512 | * |
||
513 | * @param string $applicationUuid |
||
514 | * @return TasksResponse |
||
515 | */ |
||
516 | public function tasks($applicationUuid) |
||
517 | { |
||
518 | return new TasksResponse( |
||
519 | $this->connector->request( |
||
520 | 'get', |
||
521 | "/applications/${applicationUuid}/tasks", |
||
522 | $this->query |
||
523 | ) |
||
524 | ); |
||
525 | } |
||
526 | |||
527 | /** |
||
528 | * Shows all environments in an application. |
||
529 | * |
||
530 | * @param string $applicationUuid |
||
531 | * @return EnvironmentsResponse |
||
532 | */ |
||
533 | public function environments($applicationUuid) |
||
534 | { |
||
535 | return new EnvironmentsResponse( |
||
536 | $this->connector->request( |
||
537 | 'get', |
||
538 | "/applications/${applicationUuid}/environments", |
||
539 | $this->query |
||
540 | ) |
||
541 | ); |
||
542 | } |
||
543 | |||
544 | /** |
||
545 | * Gets information about an environment. |
||
546 | * |
||
547 | * @param string $environmentUuid |
||
548 | * @return EnvironmentResponse |
||
549 | */ |
||
550 | public function environment($environmentUuid) |
||
551 | { |
||
552 | return new EnvironmentResponse( |
||
553 | $this->connector->request( |
||
554 | 'get', |
||
555 | "/environments/${environmentUuid}", |
||
556 | $this->query |
||
557 | ) |
||
558 | ); |
||
559 | } |
||
560 | |||
561 | /** |
||
562 | * Renames an environment. |
||
563 | * |
||
564 | * @param string $environmentUuid |
||
565 | * @param string $label |
||
566 | * @return OperationResponse |
||
567 | */ |
||
568 | public function renameEnvironment($environmentUuid, $label) |
||
569 | { |
||
570 | |||
571 | $options = [ |
||
572 | 'form_params' => [ |
||
573 | 'label' => $label, |
||
574 | ], |
||
575 | ]; |
||
576 | |||
577 | return new OperationResponse( |
||
578 | $this->connector->request( |
||
579 | 'post', |
||
580 | "/environments/${environmentUuid}/actions/change-label", |
||
581 | $this->query, |
||
582 | $options |
||
583 | ) |
||
584 | ); |
||
585 | } |
||
586 | |||
587 | /** |
||
588 | * Show all servers associated with an environment. |
||
589 | * |
||
590 | * @param string $environmentUuid |
||
591 | * @return ServersResponse |
||
592 | */ |
||
593 | public function servers($environmentUuid) |
||
594 | { |
||
595 | return new ServersResponse( |
||
596 | $this->connector->request( |
||
597 | 'get', |
||
598 | "/environments/${environmentUuid}/servers", |
||
599 | $this->query |
||
600 | ) |
||
601 | ); |
||
602 | } |
||
603 | |||
604 | /** |
||
605 | * Enable livedev mode for an environment. |
||
606 | * |
||
607 | * @param string $environmentUuid |
||
608 | * @return OperationResponse |
||
609 | */ |
||
610 | public function enableLiveDev($environmentUuid) |
||
611 | { |
||
612 | return new OperationResponse( |
||
613 | $this->connector->request('post', "/environments/${environmentUuid}/livedev/actions/enable", $this->query) |
||
614 | ); |
||
615 | } |
||
616 | |||
617 | /** |
||
618 | * Disable livedev mode for an environment. |
||
619 | * |
||
620 | * @param string $environmentUuid |
||
621 | * @return OperationResponse |
||
622 | */ |
||
623 | public function disableLiveDev($environmentUuid) |
||
624 | { |
||
625 | |||
626 | $options = [ |
||
627 | 'form_params' => [ |
||
628 | 'discard' => 1, |
||
629 | ], |
||
630 | ]; |
||
631 | |||
632 | return new OperationResponse( |
||
633 | $this->connector->request( |
||
634 | 'post', |
||
635 | "/environments/${environmentUuid}/livedev/actions/disable", |
||
636 | $this->query, |
||
637 | $options |
||
638 | ) |
||
639 | ); |
||
640 | } |
||
641 | |||
642 | /** |
||
643 | * Enable production mode for an environment. |
||
644 | * |
||
645 | * @param string $environmentUuid |
||
646 | * @return OperationResponse |
||
647 | */ |
||
648 | public function enableProductionMode($environmentUuid) |
||
649 | { |
||
650 | return new OperationResponse( |
||
651 | $this->connector->request( |
||
652 | 'post', |
||
653 | "/environments/${environmentUuid}/production-mode/actions/enable", |
||
654 | $this->query |
||
655 | ) |
||
656 | ); |
||
657 | } |
||
658 | |||
659 | /** |
||
660 | * Disable production mode for an environment. |
||
661 | * |
||
662 | * @param string $environmentUuid |
||
663 | * @return OperationResponse |
||
664 | */ |
||
665 | public function disableProductionMode($environmentUuid) |
||
666 | { |
||
667 | return new OperationResponse( |
||
668 | $this->connector->request( |
||
669 | 'post', |
||
670 | "/environments/${environmentUuid}/production-mode/actions/disable", |
||
671 | $this->query |
||
672 | ) |
||
673 | ); |
||
674 | } |
||
675 | |||
676 | /** |
||
677 | * Show all cron tasks for an environment. |
||
678 | * |
||
679 | * @param string $environmentUuid The environment ID |
||
680 | * @return CronsResponse |
||
681 | */ |
||
682 | public function crons($environmentUuid) |
||
683 | { |
||
684 | return new CronsResponse( |
||
685 | $this->connector->request( |
||
686 | 'get', |
||
687 | "/environments/${environmentUuid}/crons", |
||
688 | $this->query |
||
689 | ) |
||
690 | ); |
||
691 | } |
||
692 | |||
693 | /** |
||
694 | * Get information about a cron task. |
||
695 | * |
||
696 | * @param string $environmentUuid The environment ID |
||
697 | * @param int $cronId |
||
698 | * @return CronResponse |
||
699 | */ |
||
700 | public function cron($environmentUuid, $cronId) |
||
701 | { |
||
702 | return new CronResponse( |
||
703 | $this->connector->request( |
||
704 | 'get', |
||
705 | "/environments/${environmentUuid}/crons/${cronId}", |
||
706 | $this->query |
||
707 | ) |
||
708 | ); |
||
709 | } |
||
710 | |||
711 | /** |
||
712 | * Add a cron task. |
||
713 | * |
||
714 | * @param string $environmentUuid |
||
715 | * @param string $command |
||
716 | * @param string $frequency |
||
717 | * @param string $label |
||
718 | * @return OperationResponse |
||
719 | */ |
||
720 | public function createCron($environmentUuid, $command, $frequency, $label) |
||
721 | { |
||
722 | |||
723 | $options = [ |
||
724 | 'form_params' => [ |
||
725 | 'command' => $command, |
||
726 | 'frequency' => $frequency, |
||
727 | 'label' => $label, |
||
728 | ], |
||
729 | ]; |
||
730 | |||
731 | return new OperationResponse( |
||
732 | $this->connector->request('post', "/environments/${environmentUuid}/crons", $this->query, $options) |
||
733 | ); |
||
734 | } |
||
735 | |||
736 | /** |
||
737 | * Delete a cron task. |
||
738 | * |
||
739 | * @param string $environmentUuid |
||
740 | * @param int $cronId |
||
741 | * @return OperationResponse |
||
742 | */ |
||
743 | public function deleteCron($environmentUuid, $cronId) |
||
744 | { |
||
745 | return new OperationResponse( |
||
746 | $this->connector->request('delete', "/environments/${environmentUuid}/crons/${cronId}", $this->query) |
||
747 | ); |
||
748 | } |
||
749 | |||
750 | /** |
||
751 | * Disable a cron task. |
||
752 | * |
||
753 | * @param string $environmentUuid |
||
754 | * @param int $cronId |
||
755 | * @return OperationResponse |
||
756 | */ |
||
757 | public function disableCron($environmentUuid, $cronId) |
||
758 | { |
||
759 | return new OperationResponse( |
||
760 | $this->connector->request( |
||
761 | 'post', |
||
762 | "/environments/${environmentUuid}/crons/${cronId}/actions/disable", |
||
763 | $this->query |
||
764 | ) |
||
765 | ); |
||
766 | } |
||
767 | |||
768 | /** |
||
769 | * Enable a cron task. |
||
770 | * |
||
771 | * @param string $environmentUuid |
||
772 | * @param int $cronId |
||
773 | * @return OperationResponse |
||
774 | */ |
||
775 | public function enableCron($environmentUuid, $cronId) |
||
776 | { |
||
777 | return new OperationResponse( |
||
778 | $this->connector->request( |
||
779 | 'post', |
||
780 | "/environments/${environmentUuid}/crons/${cronId}/actions/enable", |
||
781 | $this->query |
||
782 | ) |
||
783 | ); |
||
784 | } |
||
785 | |||
786 | /** |
||
787 | * Provides an archived set of files for Acquia Drush aliases. |
||
788 | * |
||
789 | * @return StreamInterface |
||
790 | */ |
||
791 | public function drushAliases() |
||
792 | { |
||
793 | return $this->connector->request('get', '/account/drush-aliases/download', $this->query); |
||
794 | } |
||
795 | |||
796 | /** |
||
797 | * Show insights data from an application. |
||
798 | * |
||
799 | * @param string $applicationUuid |
||
800 | * @return InsightsResponse |
||
801 | */ |
||
802 | public function applicationInsights($applicationUuid) |
||
803 | { |
||
804 | return new InsightsResponse( |
||
805 | $this->connector->request('get', "/applications/${applicationUuid}/insight", $this->query) |
||
806 | ); |
||
807 | } |
||
808 | |||
809 | /** |
||
810 | * Show insights data from a specific environment. |
||
811 | * |
||
812 | * @param string $environmentUuid |
||
813 | * @return InsightsResponse |
||
814 | */ |
||
815 | public function environmentInsights($environmentUuid) |
||
816 | { |
||
817 | return new InsightsResponse( |
||
818 | $this->connector->request('get', "/environments/${environmentUuid}/insight", $this->query) |
||
819 | ); |
||
820 | } |
||
821 | |||
822 | /** |
||
823 | * Show all organizations. |
||
824 | * |
||
825 | * @return OrganizationsResponse |
||
826 | */ |
||
827 | public function organizations() |
||
828 | { |
||
829 | return new OrganizationsResponse($this->connector->request('get', '/organizations', $this->query)); |
||
830 | } |
||
831 | |||
832 | /** |
||
833 | * Show all applications in an organisation. |
||
834 | * |
||
835 | * @param string $organizationUuid |
||
836 | * |
||
837 | * @return ApplicationsResponse |
||
838 | */ |
||
839 | public function organizationApplications($organizationUuid) |
||
840 | { |
||
841 | return new ApplicationsResponse( |
||
842 | $this->connector->request('get', "/organizations/${organizationUuid}/applications", $this->query) |
||
843 | ); |
||
844 | } |
||
845 | |||
846 | /** |
||
847 | * Show all roles in an organization. |
||
848 | * |
||
849 | * @param string $organizationUuid |
||
850 | * @return RolesResponse |
||
851 | */ |
||
852 | public function organizationRoles($organizationUuid) |
||
853 | { |
||
854 | return new RolesResponse( |
||
855 | $this->connector->request('get', "/organizations/${organizationUuid}/roles", $this->query) |
||
856 | ); |
||
857 | } |
||
858 | |||
859 | /** |
||
860 | * Update the permissions associated with a role. |
||
861 | * |
||
862 | * @param string $roleUuid |
||
863 | * @param array $permissions |
||
864 | * @return OperationResponse |
||
865 | */ |
||
866 | public function updateRole($roleUuid, array $permissions) |
||
867 | { |
||
868 | $options = [ |
||
869 | 'form_params' => [ |
||
870 | 'permissions' => $permissions, |
||
871 | ], |
||
872 | ]; |
||
873 | |||
874 | return new OperationResponse( |
||
875 | $this->connector->request('put', "/roles/${roleUuid}", $this->query, $options) |
||
876 | ); |
||
877 | } |
||
878 | |||
879 | /** |
||
880 | * Create a new role. |
||
881 | * |
||
882 | * @param string $organizationUuid |
||
883 | * @param string $name |
||
884 | * @param array $permissions |
||
885 | * @param null|string $description |
||
886 | * @return OperationResponse |
||
887 | */ |
||
888 | public function createRole($organizationUuid, $name, array $permissions, $description = null) |
||
889 | { |
||
890 | $options = [ |
||
891 | 'form_params' => [ |
||
892 | 'name' => $name, |
||
893 | 'permissions' => $permissions, |
||
894 | 'description' => $description, |
||
895 | ], |
||
896 | ]; |
||
897 | |||
898 | return new OperationResponse( |
||
899 | $this->connector->request('post', "/organizations/${organizationUuid}/roles", $this->query, $options) |
||
900 | ); |
||
901 | } |
||
902 | |||
903 | /** |
||
904 | * Delete a role. |
||
905 | * |
||
906 | * @param string $roleUuid |
||
907 | * @return OperationResponse |
||
908 | */ |
||
909 | public function deleteRole($roleUuid) |
||
910 | { |
||
911 | return new OperationResponse($this->connector->request('delete', "/roles/${roleUuid}", $this->query)); |
||
912 | } |
||
913 | |||
914 | /** |
||
915 | * Show all teams in an organization. |
||
916 | * |
||
917 | * @param string $organizationUuid |
||
918 | * @return TeamsResponse |
||
919 | */ |
||
920 | public function organizationTeams($organizationUuid) |
||
921 | { |
||
922 | return new TeamsResponse( |
||
923 | $this->connector->request('get', "/organizations/${organizationUuid}/teams", $this->query) |
||
924 | ); |
||
925 | } |
||
926 | |||
927 | /** |
||
928 | * Show all teams. |
||
929 | * |
||
930 | * @return TeamsResponse |
||
931 | */ |
||
932 | public function teams() |
||
933 | { |
||
934 | return new TeamsResponse( |
||
935 | $this->connector->request('get', '/teams', $this->query) |
||
936 | ); |
||
937 | } |
||
938 | |||
939 | /** |
||
940 | * Rename an existing team. |
||
941 | * |
||
942 | * @param string $teamUuid |
||
943 | * @param string $name |
||
944 | * @return OperationResponse |
||
945 | */ |
||
946 | public function renameTeam($teamUuid, $name) |
||
947 | { |
||
948 | $options = [ |
||
949 | 'form_params' => [ |
||
950 | 'name' => $name, |
||
951 | ], |
||
952 | ]; |
||
953 | |||
954 | return new OperationResponse( |
||
955 | $this->connector->request('put', "/teams/${teamUuid}", $options) |
||
956 | ); |
||
957 | } |
||
958 | |||
959 | /** |
||
960 | * Create a new team. |
||
961 | * |
||
962 | * @param string $organizationUuid |
||
963 | * @param string $name |
||
964 | * @return OperationResponse |
||
965 | */ |
||
966 | public function createTeam($organizationUuid, $name) |
||
967 | { |
||
968 | $options = [ |
||
969 | 'form_params' => [ |
||
970 | 'name' => $name, |
||
971 | ], |
||
972 | ]; |
||
973 | |||
974 | return new OperationResponse( |
||
975 | $this->connector->request('post', "/organizations/${organizationUuid}/teams", $this->query, $options) |
||
976 | ); |
||
977 | } |
||
978 | |||
979 | /** |
||
980 | * Delete a team. |
||
981 | * |
||
982 | * @param string $teamUuid |
||
983 | * @return OperationResponse |
||
984 | */ |
||
985 | public function deleteTeam($teamUuid) |
||
986 | { |
||
987 | return new OperationResponse( |
||
988 | $this->connector->request('delete', "/teams/${teamUuid}", $this->query) |
||
989 | ); |
||
990 | } |
||
991 | |||
992 | /** |
||
993 | * Add an application to a team. |
||
994 | * |
||
995 | * @param string $teamUuid |
||
996 | * @param string $applicationUuid |
||
997 | * @return OperationResponse |
||
998 | */ |
||
999 | public function addApplicationToTeam($teamUuid, $applicationUuid) |
||
1009 | ); |
||
1010 | } |
||
1011 | |||
1012 | /** |
||
1013 | * Invites a user to join a team. |
||
1014 | * |
||
1015 | * @param string $teamUuid |
||
1016 | * @param string $email |
||
1017 | * @param array $roles |
||
1018 | * @return OperationResponse |
||
1019 | */ |
||
1020 | public function createTeamInvite($teamUuid, $email, $roles) |
||
1021 | { |
||
1022 | $options = [ |
||
1023 | 'form_params' => [ |
||
1024 | 'email' => $email, |
||
1025 | 'roles' => $roles |
||
1026 | ], |
||
1027 | ]; |
||
1028 | |||
1029 | return new OperationResponse( |
||
1030 | $this->connector->request('post', "/teams/${teamUuid}/invites", $options) |
||
1031 | ); |
||
1032 | } |
||
1033 | |||
1034 | /** |
||
1035 | * Invites a user to become admin of an organization. |
||
1036 | * |
||
1037 | * @param string $organizationUuid |
||
1038 | * @param string $email |
||
1039 | * @return OperationResponse |
||
1040 | */ |
||
1041 | public function createOrganizationAdminInvite($organizationUuid, $email) |
||
1042 | { |
||
1043 | $options = [ |
||
1044 | 'form_params' => [ |
||
1045 | 'email' => $email, |
||
1046 | ], |
||
1047 | ]; |
||
1048 | |||
1049 | return new OperationResponse( |
||
1050 | $this->connector->request('post', "/teams/${organizationUuid}/invites", $this->query, $options) |
||
1051 | ); |
||
1052 | } |
||
1053 | |||
1054 | /** |
||
1055 | * Show all applications associated with a team. |
||
1056 | * |
||
1057 | * @param string $teamUuid |
||
1058 | * @return ApplicationsResponse |
||
1059 | */ |
||
1060 | public function teamApplications($teamUuid) |
||
1061 | { |
||
1062 | return new ApplicationsResponse( |
||
1063 | $this->connector->request('get', "/teams/${teamUuid}/applications", $this->query) |
||
1064 | ); |
||
1065 | } |
||
1066 | |||
1067 | /** |
||
1068 | * Show all members of an organisation. |
||
1069 | * |
||
1070 | * @param string $organizationUuid |
||
1071 | * @return MembersResponse |
||
1072 | */ |
||
1073 | public function members($organizationUuid) |
||
1074 | { |
||
1075 | return new MembersResponse( |
||
1076 | $this->connector->request('get', "/organizations/${organizationUuid}/members", $this->query) |
||
1077 | ); |
||
1078 | } |
||
1079 | |||
1080 | /** |
||
1081 | * Show all members invited to an organisation. |
||
1082 | * |
||
1083 | * @param string $organizationUuid |
||
1084 | * @return InvitationsResponse |
||
1085 | */ |
||
1086 | public function invitees($organizationUuid) |
||
1090 | ); |
||
1091 | } |
||
1092 | |||
1093 | /** |
||
1094 | * Delete a member from an organisation. |
||
1095 | * |
||
1096 | * @param string $organizationUuid |
||
1097 | * @param string $memberUuid |
||
1098 | * @return OperationResponse |
||
1099 | */ |
||
1100 | public function deleteMember($organizationUuid, $memberUuid) |
||
1101 | { |
||
1102 | return new OperationResponse( |
||
1103 | $this->connector->request( |
||
1104 | 'delete', |
||
1105 | "/organizations/${organizationUuid}/members/${memberUuid}", |
||
1106 | $this->query |
||
1107 | ) |
||
1108 | ); |
||
1109 | } |
||
1110 | |||
1111 | /** |
||
1112 | * Show all available permissions. |
||
1113 | * |
||
1114 | * @return PermissionsResponse |
||
1115 | */ |
||
1116 | public function permissions() |
||
1119 | } |
||
1120 | } |
||
1121 |