| 1 |
<?php |
| 2 |
/** |
| 3 |
* Copyright 2019 Google LLC |
| 4 |
* |
| 5 |
* Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 |
* you may not use this file except in compliance with the License. |
| 7 |
* You may obtain a copy of the License at |
| 8 |
* |
| 9 |
* http://www.apache.org/licenses/LICENSE-2.0 |
| 10 |
* |
| 11 |
* Unless required by applicable law or agreed to in writing, software |
| 12 |
* distributed under the License is distributed on an "AS IS" BASIS, |
| 13 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 |
* See the License for the specific language governing permissions and |
| 15 |
* limitations under the License. |
| 16 |
*/ |
| 17 |
|
| 18 |
namespace Google\Cloud\Storage; |
| 19 |
|
| 20 |
/** |
| 21 |
* Represents a newly created HMAC key. Provides access to the key metadata and |
| 22 |
* secret. |
| 23 |
* |
| 24 |
* Example: |
| 25 |
* ``` |
| 26 |
* use Google\Cloud\Storage\StorageClient; |
| 27 |
* |
| 28 |
* $storage = new StorageClient(); |
| 29 |
* $response = $storage->createHmacKey($serviceAccountEmail); |
| 30 |
* ``` |
| 31 |
*/ |
| 32 |
class CreatedHmacKey |
| 33 |
{ |
| 34 |
/** |
| 35 |
* @var HmacKey |
| 36 |
*/ |
| 37 |
private $hmacKey; |
| 38 |
|
| 39 |
/** |
| 40 |
* @var string |
| 41 |
*/ |
| 42 |
private $secret; |
| 43 |
|
| 44 |
/** |
| 45 |
* @param HmacKey $hmacKey The HMAC Key object. |
| 46 |
* @param string $secret The HMAC key secret. |
| 47 |
*/ |
| 48 |
public function __construct(HmacKey $hmacKey, $secret) |
| 49 |
{ |
| 50 |
$this->hmacKey = $hmacKey; |
| 51 |
$this->secret = $secret; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Get the HMAC key object. |
| 56 |
* |
| 57 |
* Example: |
| 58 |
* ``` |
| 59 |
* $key = $response->hmacKey(); |
| 60 |
* ``` |
| 61 |
* |
| 62 |
* @return HmacKey |
| 63 |
*/ |
| 64 |
public function hmacKey() |
| 65 |
{ |
| 66 |
return $this->hmacKey; |
| 67 |
} |
| 68 |
|
| 69 |
/** |
| 70 |
* Get the HMAC key secret. |
| 71 |
* |
| 72 |
* This value will never be returned from the API after first creation. Make |
| 73 |
* sure to record it for later use immediately upon key creation. |
| 74 |
* |
| 75 |
* Example: |
| 76 |
* ``` |
| 77 |
* $secret = $response->secret(); |
| 78 |
* ``` |
| 79 |
* |
| 80 |
* @return string |
| 81 |
*/ |
| 82 |
public function secret() |
| 83 |
{ |
| 84 |
return $this->secret; |
| 85 |
} |
| 86 |
} |
| 87 |
|