add bucket options and key management#66
add bucket options and key management#66macbookandrew wants to merge 13 commits intogliterd:masterfrom
Conversation
|
I’m not sure what’s up with the failing scrutinizer tests…I’m more familiar with Gitlab CI. When running |
|
@macbookandrew If you pull from master you'll get the fix I just applied. My apologies for that. |
|
@mlambley Thanks—updated and I’m seeing all passing tests now. |
mlambley
left a comment
There was a problem hiding this comment.
I'm requesting quite a few changes here, let me know if you want me to handle any of them myself. Cheers.
| protected $namePrefix; | ||
| protected $expirationTimestamp; | ||
|
|
||
| /** |
There was a problem hiding this comment.
Please add the new params to this docblock.
|
|
||
| class Key | ||
| { | ||
| const PERMISSION_LIST_KEYS = 'listKeys'; |
There was a problem hiding this comment.
Is it necessary to include these constants? I would expect that we would do something with them, like validate them against the capabilities the dev specified when creating the key, and also to recognise that some capabilities (eg. writeBucketRetentions) are present in the response but cannot be specified in the request.
But I don't want to do any of that, I'd rather just remove the consts and let the dev figure it out from the backblaze documentation.
| * @throws GuzzleException If the request fails. | ||
| * @throws B2Exception If the B2 server replies with an error. | ||
| * | ||
| * @return Key |
| $keys[] = new Key($key['applicationKeyId'], $key['keyName'], null, $key['capabilities'], $key['bucketId'], $key['namePrefix'], $key['expirationTimestamp']); | ||
| } | ||
|
|
||
| return $keys; |
There was a problem hiding this comment.
Do you want to go a step further and use $response['nextApplicationKeyId'] to continually call the API to list keys beyond the first page, similar to how listFiles works with its while (true) loop?
| protected $capabilities; | ||
| protected $bucketId; | ||
| protected $namePrefix; | ||
| protected $expirationTimestamp; |
There was a problem hiding this comment.
There is also $options returned by the create, list and delete key api calls, please include it in the same way as these.
| * @param $corsRules | ||
| */ | ||
| public function __construct($id, $name, $type) | ||
| public function __construct($id, $name, $type, $options, $corsRules) |
There was a problem hiding this comment.
While you're adding the extra fields you can include the remaining ones, bucketInfo, defaultFileLockConfiguration, lifecycleRules, revision
| * | ||
| * @return Key | ||
| */ | ||
| public function deleteKey(array $options) |
There was a problem hiding this comment.
Would you mind adding a test for each of the new functions?
| public function listKeys(array $options = []) | ||
| { | ||
| $request = [ | ||
| 'accountId' => $this->accountId, |
There was a problem hiding this comment.
Extra spacing here which isn't picked up by the linter for some reason, please fix it up while you're at it.
|
Hi @macbookandrew please let me know which of these changes you wish to do yourself and which you wish for me to do. Thanks. |
@mlambley here’s a followup PR for #56. Thanks!