1<?php 2/* 3 * Copyright 2014 Google Inc. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); you may not 6 * use this file except in compliance with the License. You may obtain a copy of 7 * 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, WITHOUT 13 * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 14 * License for the specific language governing permissions and limitations under 15 * the License. 16 */ 17 18namespace Google\Service\SecretManager\Resource; 19 20use Google\Service\SecretManager\AddSecretVersionRequest; 21use Google\Service\SecretManager\ListSecretsResponse; 22use Google\Service\SecretManager\Policy; 23use Google\Service\SecretManager\Secret; 24use Google\Service\SecretManager\SecretVersion; 25use Google\Service\SecretManager\SecretmanagerEmpty; 26use Google\Service\SecretManager\SetIamPolicyRequest; 27use Google\Service\SecretManager\TestIamPermissionsRequest; 28use Google\Service\SecretManager\TestIamPermissionsResponse; 29 30/** 31 * The "secrets" collection of methods. 32 * Typical usage is: 33 * <code> 34 * $secretmanagerService = new Google\Service\SecretManager(...); 35 * $secrets = $secretmanagerService->secrets; 36 * </code> 37 */ 38class ProjectsSecrets extends \Google\Service\Resource 39{ 40 /** 41 * Creates a new SecretVersion containing secret data and attaches it to an 42 * existing Secret. (secrets.addVersion) 43 * 44 * @param string $parent Required. The resource name of the Secret to associate 45 * with the SecretVersion in the format `projects/secrets`. 46 * @param AddSecretVersionRequest $postBody 47 * @param array $optParams Optional parameters. 48 * @return SecretVersion 49 */ 50 public function addVersion($parent, AddSecretVersionRequest $postBody, $optParams = []) 51 { 52 $params = ['parent' => $parent, 'postBody' => $postBody]; 53 $params = array_merge($params, $optParams); 54 return $this->call('addVersion', [$params], SecretVersion::class); 55 } 56 /** 57 * Creates a new Secret containing no SecretVersions. (secrets.create) 58 * 59 * @param string $parent Required. The resource name of the project to associate 60 * with the Secret, in the format `projects`. 61 * @param Secret $postBody 62 * @param array $optParams Optional parameters. 63 * 64 * @opt_param string secretId Required. This must be unique within the project. 65 * A secret ID is a string with a maximum length of 255 characters and can 66 * contain uppercase and lowercase letters, numerals, and the hyphen (`-`) and 67 * underscore (`_`) characters. 68 * @return Secret 69 */ 70 public function create($parent, Secret $postBody, $optParams = []) 71 { 72 $params = ['parent' => $parent, 'postBody' => $postBody]; 73 $params = array_merge($params, $optParams); 74 return $this->call('create', [$params], Secret::class); 75 } 76 /** 77 * Deletes a Secret. (secrets.delete) 78 * 79 * @param string $name Required. The resource name of the Secret to delete in 80 * the format `projects/secrets`. 81 * @param array $optParams Optional parameters. 82 * 83 * @opt_param string etag Optional. Etag of the Secret. The request succeeds if 84 * it matches the etag of the currently stored secret object. If the etag is 85 * omitted, the request succeeds. 86 * @return SecretmanagerEmpty 87 */ 88 public function delete($name, $optParams = []) 89 { 90 $params = ['name' => $name]; 91 $params = array_merge($params, $optParams); 92 return $this->call('delete', [$params], SecretmanagerEmpty::class); 93 } 94 /** 95 * Gets metadata for a given Secret. (secrets.get) 96 * 97 * @param string $name Required. The resource name of the Secret, in the format 98 * `projects/secrets`. 99 * @param array $optParams Optional parameters. 100 * @return Secret 101 */ 102 public function get($name, $optParams = []) 103 { 104 $params = ['name' => $name]; 105 $params = array_merge($params, $optParams); 106 return $this->call('get', [$params], Secret::class); 107 } 108 /** 109 * Gets the access control policy for a secret. Returns empty policy if the 110 * secret exists and does not have a policy set. (secrets.getIamPolicy) 111 * 112 * @param string $resource REQUIRED: The resource for which the policy is being 113 * requested. See the operation documentation for the appropriate value for this 114 * field. 115 * @param array $optParams Optional parameters. 116 * 117 * @opt_param int options.requestedPolicyVersion Optional. The maximum policy 118 * version that will be used to format the policy. Valid values are 0, 1, and 3. 119 * Requests specifying an invalid value will be rejected. Requests for policies 120 * with any conditional role bindings must specify version 3. Policies with no 121 * conditional role bindings may specify any valid value or leave the field 122 * unset. The policy in the response might use the policy version that you 123 * specified, or it might use a lower policy version. For example, if you 124 * specify version 3, but the policy has no conditional role bindings, the 125 * response uses version 1. To learn which resources support conditions in their 126 * IAM policies, see the [IAM 127 * documentation](https://cloud.google.com/iam/help/conditions/resource- 128 * policies). 129 * @return Policy 130 */ 131 public function getIamPolicy($resource, $optParams = []) 132 { 133 $params = ['resource' => $resource]; 134 $params = array_merge($params, $optParams); 135 return $this->call('getIamPolicy', [$params], Policy::class); 136 } 137 /** 138 * Lists Secrets. (secrets.listProjectsSecrets) 139 * 140 * @param string $parent Required. The resource name of the project associated 141 * with the Secrets, in the format `projects`. 142 * @param array $optParams Optional parameters. 143 * 144 * @opt_param string filter Optional. Filter string, adhering to the rules in 145 * [List-operation filtering](https://cloud.google.com/secret- 146 * manager/docs/filtering). List only secrets matching the filter. If filter is 147 * empty, all secrets are listed. 148 * @opt_param int pageSize Optional. The maximum number of results to be 149 * returned in a single page. If set to 0, the server decides the number of 150 * results to return. If the number is greater than 25000, it is capped at 151 * 25000. 152 * @opt_param string pageToken Optional. Pagination token, returned earlier via 153 * ListSecretsResponse.next_page_token. 154 * @return ListSecretsResponse 155 */ 156 public function listProjectsSecrets($parent, $optParams = []) 157 { 158 $params = ['parent' => $parent]; 159 $params = array_merge($params, $optParams); 160 return $this->call('list', [$params], ListSecretsResponse::class); 161 } 162 /** 163 * Updates metadata of an existing Secret. (secrets.patch) 164 * 165 * @param string $name Output only. The resource name of the Secret in the 166 * format `projects/secrets`. 167 * @param Secret $postBody 168 * @param array $optParams Optional parameters. 169 * 170 * @opt_param string updateMask Required. Specifies the fields to be updated. 171 * @return Secret 172 */ 173 public function patch($name, Secret $postBody, $optParams = []) 174 { 175 $params = ['name' => $name, 'postBody' => $postBody]; 176 $params = array_merge($params, $optParams); 177 return $this->call('patch', [$params], Secret::class); 178 } 179 /** 180 * Sets the access control policy on the specified secret. Replaces any existing 181 * policy. Permissions on SecretVersions are enforced according to the policy 182 * set on the associated Secret. (secrets.setIamPolicy) 183 * 184 * @param string $resource REQUIRED: The resource for which the policy is being 185 * specified. See the operation documentation for the appropriate value for this 186 * field. 187 * @param SetIamPolicyRequest $postBody 188 * @param array $optParams Optional parameters. 189 * @return Policy 190 */ 191 public function setIamPolicy($resource, SetIamPolicyRequest $postBody, $optParams = []) 192 { 193 $params = ['resource' => $resource, 'postBody' => $postBody]; 194 $params = array_merge($params, $optParams); 195 return $this->call('setIamPolicy', [$params], Policy::class); 196 } 197 /** 198 * Returns permissions that a caller has for the specified secret. If the secret 199 * does not exist, this call returns an empty set of permissions, not a 200 * NOT_FOUND error. Note: This operation is designed to be used for building 201 * permission-aware UIs and command-line tools, not for authorization checking. 202 * This operation may "fail open" without warning. (secrets.testIamPermissions) 203 * 204 * @param string $resource REQUIRED: The resource for which the policy detail is 205 * being requested. See the operation documentation for the appropriate value 206 * for this field. 207 * @param TestIamPermissionsRequest $postBody 208 * @param array $optParams Optional parameters. 209 * @return TestIamPermissionsResponse 210 */ 211 public function testIamPermissions($resource, TestIamPermissionsRequest $postBody, $optParams = []) 212 { 213 $params = ['resource' => $resource, 'postBody' => $postBody]; 214 $params = array_merge($params, $optParams); 215 return $this->call('testIamPermissions', [$params], TestIamPermissionsResponse::class); 216 } 217} 218 219// Adding a class alias for backwards compatibility with the previous class name. 220class_alias(ProjectsSecrets::class, 'Google_Service_SecretManager_Resource_ProjectsSecrets'); 221