-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CC-34136 Quicksight user registration and persistence #4
Merged
AsonUnique
merged 5 commits into
feature/cc-34041/dev-quick-sight-mvp
from
feature/cc-34041/cc-34136-persist-qs-user
Aug 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d6154a9
CC-34136 Quicksight user registration and persistence
AsonUnique 78cac83
Merge branch 'feature/cc-34041/dev-quick-sight-mvp' into feature/cc-3…
ilyakubanov f32602e
CC-34136 Fixes after CR
AsonUnique 2842bd0
CC-34136 Adjust phpstan config
AsonUnique 45fcd46
CC-34136 Fix test class name
AsonUnique File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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
124 changes: 124 additions & 0 deletions
124
src/SprykerEco/Zed/AmazonQuicksight/Business/ApiClient/AmazonQuicksightApiClient.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,124 @@ | ||
<?php | ||
|
||
/** | ||
* MIT License | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Zed\AmazonQuicksight\Business\ApiClient; | ||
|
||
use Aws\QuickSight\Exception\QuickSightException; | ||
use Generated\Shared\Transfer\ErrorTransfer; | ||
use Generated\Shared\Transfer\QuicksightUserRegisterRequestTransfer; | ||
use Generated\Shared\Transfer\QuicksightUserRegisterResponseTransfer; | ||
use Generated\Shared\Transfer\UserTransfer; | ||
use SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig; | ||
use SprykerEco\Zed\AmazonQuicksight\Business\Formatter\AmazonQuicksightRequestDataFormatterInterface; | ||
use SprykerEco\Zed\AmazonQuicksight\Business\Mapper\AmazonQuicksightMapperInterface; | ||
use SprykerEco\Zed\AmazonQuicksight\Dependency\External\AmazonQuicksightToAwsQuicksightClientInterface; | ||
|
||
class AmazonQuicksightApiClient implements AmazonQuicksightApiClientInterface | ||
{ | ||
/** | ||
* @var string | ||
*/ | ||
protected const QUICKSIGHT_USER_IDENTITY_TYPE = 'QUICKSIGHT'; | ||
ilyakubanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* @link https://docs.aws.amazon.com/quicksight/latest/APIReference/API_RegisterUser.html#API_RegisterUser_ResponseSyntax | ||
* | ||
* @var string | ||
*/ | ||
protected const RESPONSE_KEY_USER = 'User'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
protected const ERROR_MESSAGE_USER_REGISTRATION_FAILED = 'Failed to register Quicksight user.'; | ||
|
||
/** | ||
* @var \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig | ||
*/ | ||
protected AmazonQuicksightConfig $amazonQuicksightConfig; | ||
|
||
/** | ||
* @var \SprykerEco\Zed\AmazonQuicksight\Business\Mapper\AmazonQuicksightMapperInterface | ||
*/ | ||
protected AmazonQuicksightMapperInterface $amazonQuicksightMapper; | ||
|
||
protected AmazonQuicksightRequestDataFormatterInterface $amazonQuicksightRequestDataFormatter; | ||
ilyakubanov marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
/** | ||
* @var \SprykerEco\Zed\AmazonQuicksight\Dependency\External\AmazonQuicksightToAwsQuicksightClientInterface | ||
*/ | ||
protected AmazonQuicksightToAwsQuicksightClientInterface $amazonQuicksightToAwsQuicksightClient; | ||
|
||
/** | ||
* @param \SprykerEco\Zed\AmazonQuicksight\AmazonQuicksightConfig $amazonQuicksightConfig | ||
* @param \SprykerEco\Zed\AmazonQuicksight\Business\Mapper\AmazonQuicksightMapperInterface $amazonQuicksightMapper | ||
* @param \SprykerEco\Zed\AmazonQuicksight\Business\Formatter\AmazonQuicksightRequestDataFormatterInterface $amazonQuicksightRequestDataFormatter | ||
* @param \SprykerEco\Zed\AmazonQuicksight\Dependency\External\AmazonQuicksightToAwsQuicksightClientInterface $amazonQuicksightToAwsQuicksightClient | ||
*/ | ||
public function __construct( | ||
AmazonQuicksightConfig $amazonQuicksightConfig, | ||
AmazonQuicksightMapperInterface $amazonQuicksightMapper, | ||
AmazonQuicksightRequestDataFormatterInterface $amazonQuicksightRequestDataFormatter, | ||
AmazonQuicksightToAwsQuicksightClientInterface $amazonQuicksightToAwsQuicksightClient | ||
) { | ||
$this->amazonQuicksightConfig = $amazonQuicksightConfig; | ||
$this->amazonQuicksightMapper = $amazonQuicksightMapper; | ||
$this->amazonQuicksightRequestDataFormatter = $amazonQuicksightRequestDataFormatter; | ||
$this->amazonQuicksightToAwsQuicksightClient = $amazonQuicksightToAwsQuicksightClient; | ||
} | ||
|
||
/** | ||
* @param \Generated\Shared\Transfer\UserTransfer $userTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\QuicksightUserRegisterResponseTransfer | ||
*/ | ||
public function registerUser(UserTransfer $userTransfer): QuicksightUserRegisterResponseTransfer | ||
Check failure on line 79 in src/SprykerEco/Zed/AmazonQuicksight/Business/ApiClient/AmazonQuicksightApiClient.php GitHub Actions / Validation
Check failure on line 79 in src/SprykerEco/Zed/AmazonQuicksight/Business/ApiClient/AmazonQuicksightApiClient.php GitHub Actions / Validation
|
||
{ | ||
$quicksightUserRegisterRequestTransfer = $this->createQuicksightUserRegisterRequestTransfer(); | ||
$quicksightUserRegisterRequestTransfer = $this->amazonQuicksightMapper->mapUserTransferToQuicksightUserRegisterRequestTransfer( | ||
$userTransfer, | ||
$quicksightUserRegisterRequestTransfer, | ||
); | ||
|
||
$requestData = $this->amazonQuicksightRequestDataFormatter->formatRequestData( | ||
$quicksightUserRegisterRequestTransfer->toArray(true, true), | ||
); | ||
|
||
$quicksightUserRegisterResponseTransfer = new QuicksightUserRegisterResponseTransfer(); | ||
try { | ||
$response = $this->amazonQuicksightToAwsQuicksightClient->registerUser($requestData); | ||
} catch (QuickSightException $quickSightException) { | ||
return $quicksightUserRegisterResponseTransfer->addError( | ||
(new ErrorTransfer())->setMessage($quickSightException->getAwsErrorMessage()), | ||
); | ||
} | ||
|
||
if (!$response->hasKey(static::RESPONSE_KEY_USER)) { | ||
return $quicksightUserRegisterResponseTransfer->addError( | ||
(new ErrorTransfer())->setMessage(static::ERROR_MESSAGE_USER_REGISTRATION_FAILED), | ||
); | ||
} | ||
|
||
$quicksightUserTransfer = $this->amazonQuicksightMapper->mapQuicksightUserDataToQuicksightUserTransfer( | ||
$response->get(static::RESPONSE_KEY_USER), | ||
$userTransfer->getQuicksightUserOrFail(), | ||
); | ||
|
||
return $quicksightUserRegisterResponseTransfer->setQuicksightUser($quicksightUserTransfer); | ||
} | ||
|
||
/** | ||
* @return \Generated\Shared\Transfer\QuicksightUserRegisterRequestTransfer | ||
*/ | ||
protected function createQuicksightUserRegisterRequestTransfer(): QuicksightUserRegisterRequestTransfer | ||
{ | ||
return (new QuicksightUserRegisterRequestTransfer()) | ||
->setIdentityType(static::QUICKSIGHT_USER_IDENTITY_TYPE) | ||
->setAwsAccountId($this->amazonQuicksightConfig->getAwsAccountId()) | ||
->setNamespace($this->amazonQuicksightConfig->getQuicksightRegisterUserNamespace()); | ||
} | ||
} |
21 changes: 21 additions & 0 deletions
21
...SprykerEco/Zed/AmazonQuicksight/Business/ApiClient/AmazonQuicksightApiClientInterface.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,21 @@ | ||
<?php | ||
|
||
/** | ||
* MIT License | ||
* Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file. | ||
*/ | ||
|
||
namespace SprykerEco\Zed\AmazonQuicksight\Business\ApiClient; | ||
|
||
use Generated\Shared\Transfer\QuicksightUserRegisterResponseTransfer; | ||
use Generated\Shared\Transfer\UserTransfer; | ||
|
||
interface AmazonQuicksightApiClientInterface | ||
{ | ||
/** | ||
* @param \Generated\Shared\Transfer\UserTransfer $userTransfer | ||
* | ||
* @return \Generated\Shared\Transfer\QuicksightUserRegisterResponseTransfer | ||
*/ | ||
public function registerUser(UserTransfer $userTransfer): QuicksightUserRegisterResponseTransfer; | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mention that the request is sent for users with roles only