-
Notifications
You must be signed in to change notification settings - Fork 149
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add endpoints to create/get/remove application credentials * add token creation using application credentials * cancel running workflows on new commit --------- Co-authored-by: smarcet <smarcet@gmail.com> Co-authored-by: k0ka <k0ka@users.noreply.github.com>
- Loading branch information
1 parent
7651038
commit aeb5012
Showing
23 changed files
with
568 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
Application Credentials | ||
======================= | ||
|
||
Add application credential | ||
-------------------------- | ||
|
||
.. sample:: Identity/v3/application_credentials/add_application_credentials.php | ||
|
||
Show application credential details | ||
----------------------------------- | ||
|
||
.. sample:: Identity/v3/application_credentials/show_application_credentials.php | ||
|
||
Delete application credential | ||
----------------------------- | ||
|
||
.. sample:: Identity/v3/application_credentials/delete_application_credentials.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,7 @@ Identity v3 | |
.. toctree:: | ||
:maxdepth: 3 | ||
|
||
application-credentials | ||
credentials | ||
domains | ||
endpoints | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
25 changes: 25 additions & 0 deletions
25
samples/Identity/v3/application_credentials/add_application_credential.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<?php | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
$openstack = new OpenStack\OpenStack([ | ||
'authUrl' => '{authUrl}', | ||
'region' => '{region}', | ||
'user' => [ | ||
'id' => '{userId}', | ||
'password' => '{password}' | ||
], | ||
'scope' => [ | ||
'project' => [ | ||
'id' => '{projectId}' | ||
] | ||
] | ||
]); | ||
|
||
$identity = $openstack->identityV3(['region' => '{region}']); | ||
|
||
$user = $identity->getUser('{userId}'); | ||
$applicationCredential = $user->createApplicationCredential([ | ||
'name' => '{name}', | ||
'description' => '{description}', | ||
]); |
24 changes: 24 additions & 0 deletions
24
samples/Identity/v3/application_credentials/delete_application_credential.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
$openstack = new OpenStack\OpenStack([ | ||
'authUrl' => '{authUrl}', | ||
'region' => '{region}', | ||
'user' => [ | ||
'id' => '{userId}', | ||
'password' => '{password}' | ||
], | ||
'scope' => [ | ||
'project' => [ | ||
'id' => '{projectId}' | ||
] | ||
] | ||
]); | ||
|
||
$identity = $openstack->identityV3(['region' => '{region}']); | ||
|
||
$user = $identity->getUser('{userId}'); | ||
$applicationCredential = $user->getApplicationCredential('{applicationCredentialId}'); | ||
$applicationCredential->delete(); | ||
|
24 changes: 24 additions & 0 deletions
24
samples/Identity/v3/application_credentials/show_application_credential.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
$openstack = new OpenStack\OpenStack([ | ||
'authUrl' => '{authUrl}', | ||
'region' => '{region}', | ||
'user' => [ | ||
'id' => '{userId}', | ||
'password' => '{password}' | ||
], | ||
'scope' => [ | ||
'project' => [ | ||
'id' => '{projectId}' | ||
] | ||
] | ||
]); | ||
|
||
$identity = $openstack->identityV3(['region' => '{region}']); | ||
|
||
$user = $identity->getUser('{userId}'); | ||
$applicationCredential = $user->getApplicationCredential('{applicationCredentialId}'); | ||
$applicationCredential->retrieve(); | ||
|
24 changes: 24 additions & 0 deletions
24
samples/Identity/v3/tokens/generate_token_with_application_credential_id.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
require 'vendor/autoload.php'; | ||
|
||
$openstack = new OpenStack\OpenStack([ | ||
'authUrl' => '{authUrl}', | ||
'region' => '{region}', | ||
'user' => [ | ||
'id' => '{userId}', | ||
'password' => '{password}' | ||
], | ||
'scope' => [ | ||
'project' => ['id' => '{projectId}'] | ||
] | ||
]); | ||
|
||
$identity = $openstack->identityV3(); | ||
|
||
$token = $identity->generateToken([ | ||
'application_credential' => [ | ||
'id' => '{applicationCredentialId}', | ||
'secret' => '{secret}' | ||
] | ||
]); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
<?php | ||
|
||
namespace OpenStack\Identity\v3\Models; | ||
|
||
use OpenStack\Common\Resource\Creatable; | ||
use OpenStack\Common\Resource\Deletable; | ||
use OpenStack\Common\Resource\Listable; | ||
use OpenStack\Common\Resource\OperatorResource; | ||
use OpenStack\Common\Resource\Retrievable; | ||
|
||
/** | ||
* @property \OpenStack\Identity\v3\Api $api | ||
*/ | ||
class ApplicationCredential extends OperatorResource implements Creatable, Listable, Retrievable, Deletable | ||
{ | ||
/** @var string */ | ||
public $id; | ||
|
||
/** @var string */ | ||
public $userId; | ||
|
||
/** @var string */ | ||
public $name; | ||
|
||
/** @var string */ | ||
public $description; | ||
|
||
/** @var string|null */ | ||
public $secret = null; | ||
|
||
protected $aliases = [ | ||
'user_id' => 'userId', | ||
]; | ||
|
||
protected $resourceKey = 'application_credential'; | ||
protected $resourcesKey = 'application_credentials'; | ||
|
||
/** | ||
* {@inheritdoc} | ||
* | ||
* @param array $userOptions {@see \OpenStack\Identity\v3\Api::postApplicationCredential} | ||
*/ | ||
public function create(array $userOptions): Creatable | ||
{ | ||
$response = $this->execute($this->api->postApplicationCredential(), $userOptions); | ||
|
||
return $this->populateFromResponse($response); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function retrieve() | ||
{ | ||
$response = $this->execute( | ||
$this->api->getApplicationCredential(), | ||
['id' => $this->id, 'userId' => $this->userId] | ||
); | ||
$this->populateFromResponse($response); | ||
} | ||
|
||
/** | ||
* {@inheritdoc} | ||
*/ | ||
public function delete() | ||
{ | ||
$this->executeWithState($this->api->deleteApplicationCredential()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.