IdentityProviders   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 96
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
eloc 32
c 1
b 0
f 0
dl 0
loc 96
rs 10

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getAll() 0 6 1
A delete() 0 6 1
A update() 0 22 1
A enable() 0 6 1
A get() 0 6 1
A disable() 0 6 1
1
<?php
2
3
namespace AcquiaCloudApi\Endpoints;
4
5
use AcquiaCloudApi\Response\IdentityProviderResponse;
6
use AcquiaCloudApi\Response\IdentityProvidersResponse;
7
use AcquiaCloudApi\Response\OperationResponse;
8
9
/**
10
 * Class IdentityProviders
11
 *
12
 * @package AcquiaCloudApi\CloudApi
13
 */
14
class IdentityProviders extends CloudApiBase
15
{
16
    /**
17
     * Returns a list of identity providers for the user.
18
     *
19
     * @return IdentityProvidersResponse<IdentityProviderResponse>
20
     */
21
    public function getAll(): IdentityProvidersResponse
22
    {
23
        return new IdentityProvidersResponse(
24
            $this->client->request(
25
                'get',
26
                "/identity-providers"
27
            )
28
        );
29
    }
30
31
    /**
32
     * Returns a specific identity provider by UUID.
33
     *
34
     * @param string $idpUuid The identity provider ID
35
     */
36
    public function get(string $idpUuid): IdentityProviderResponse
37
    {
38
        return new IdentityProviderResponse(
39
            $this->client->request(
40
                'get',
41
                "/identity-providers/$idpUuid"
42
            )
43
        );
44
    }
45
46
    /**
47
     * Delete a specific identity provider by UUID.
48
     */
49
    public function delete(string $idpUuid): OperationResponse
50
    {
51
        return new OperationResponse(
52
            $this->client->request(
53
                'delete',
54
                "/identity-providers/$idpUuid"
55
            )
56
        );
57
    }
58
59
    /**
60
     * Disables an identity provider by UUID.
61
     */
62
    public function disable(string $idpUuid): OperationResponse
63
    {
64
        return new OperationResponse(
65
            $this->client->request(
66
                'post',
67
                "/identity-providers/$idpUuid/actions/disable"
68
            )
69
        );
70
    }
71
72
    /**
73
     * Enables an identity provider by UUID.
74
     */
75
    public function enable(string $idpUuid): OperationResponse
76
    {
77
        return new OperationResponse(
78
            $this->client->request(
79
                'post',
80
                "/identity-providers/$idpUuid/actions/enable"
81
            )
82
        );
83
    }
84
85
    /**
86
     * Updates a identity provider by UUID.
87
     */
88
    public function update(
89
        string $idpUuid,
90
        string $label,
91
        string $entityId,
92
        string $ssoUrl,
93
        string $certificate
94
    ): OperationResponse {
95
96
        $options = [
97
            'json' => [
98
                'label' => $label,
99
                'entity_id' => $entityId,
100
                'sso_url' => $ssoUrl,
101
                'certificate' => $certificate,
102
            ],
103
        ];
104
105
        return new OperationResponse(
106
            $this->client->request(
107
                'put',
108
                "/identity-providers/$idpUuid",
109
                $options
110
            )
111
        );
112
    }
113
}
114