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\ApiKeysService\Resource; 19 20use Google\Service\ApiKeysService\Operation; 21use Google\Service\ApiKeysService\V2GetKeyStringResponse; 22use Google\Service\ApiKeysService\V2Key; 23use Google\Service\ApiKeysService\V2ListKeysResponse; 24use Google\Service\ApiKeysService\V2UndeleteKeyRequest; 25 26/** 27 * The "keys" collection of methods. 28 * Typical usage is: 29 * <code> 30 * $apikeysService = new Google\Service\ApiKeysService(...); 31 * $keys = $apikeysService->keys; 32 * </code> 33 */ 34class ProjectsLocationsKeys extends \Google\Service\Resource 35{ 36 /** 37 * Creates a new API key. NOTE: Key is a global resource; hence the only 38 * supported value for location is `global`. (keys.create) 39 * 40 * @param string $parent Required. The project in which the API key is created. 41 * @param V2Key $postBody 42 * @param array $optParams Optional parameters. 43 * 44 * @opt_param string keyId User specified key id (optional). If specified, it 45 * will become the final component of the key resource name. The id must be 46 * unique within the project, must conform with RFC-1034, is restricted to 47 * lower-cased letters, and has a maximum length of 63 characters. In another 48 * word, the id must match the regular expression: 49 * `[a-z]([a-z0-9-]{0,61}[a-z0-9])?`. The id must NOT be a UUID-like string. 50 * @return Operation 51 */ 52 public function create($parent, V2Key $postBody, $optParams = []) 53 { 54 $params = ['parent' => $parent, 'postBody' => $postBody]; 55 $params = array_merge($params, $optParams); 56 return $this->call('create', [$params], Operation::class); 57 } 58 /** 59 * Deletes an API key. Deleted key can be retrieved within 30 days of deletion. 60 * Afterward, key will be purged from the project. NOTE: Key is a global 61 * resource; hence the only supported value for location is `global`. 62 * (keys.delete) 63 * 64 * @param string $name Required. The resource name of the API key to be deleted. 65 * @param array $optParams Optional parameters. 66 * 67 * @opt_param string etag Optional. The etag known to the client for the 68 * expected state of the key. This is to be used for optimistic concurrency. 69 * @return Operation 70 */ 71 public function delete($name, $optParams = []) 72 { 73 $params = ['name' => $name]; 74 $params = array_merge($params, $optParams); 75 return $this->call('delete', [$params], Operation::class); 76 } 77 /** 78 * Gets the metadata for an API key. The key string of the API key isn't 79 * included in the response. NOTE: Key is a global resource; hence the only 80 * supported value for location is `global`. (keys.get) 81 * 82 * @param string $name Required. The resource name of the API key to get. 83 * @param array $optParams Optional parameters. 84 * @return V2Key 85 */ 86 public function get($name, $optParams = []) 87 { 88 $params = ['name' => $name]; 89 $params = array_merge($params, $optParams); 90 return $this->call('get', [$params], V2Key::class); 91 } 92 /** 93 * Get the key string for an API key. NOTE: Key is a global resource; hence the 94 * only supported value for location is `global`. (keys.getKeyString) 95 * 96 * @param string $name Required. The resource name of the API key to be 97 * retrieved. 98 * @param array $optParams Optional parameters. 99 * @return V2GetKeyStringResponse 100 */ 101 public function getKeyString($name, $optParams = []) 102 { 103 $params = ['name' => $name]; 104 $params = array_merge($params, $optParams); 105 return $this->call('getKeyString', [$params], V2GetKeyStringResponse::class); 106 } 107 /** 108 * Lists the API keys owned by a project. The key string of the API key isn't 109 * included in the response. NOTE: Key is a global resource; hence the only 110 * supported value for location is `global`. (keys.listProjectsLocationsKeys) 111 * 112 * @param string $parent Required. Lists all API keys associated with this 113 * project. 114 * @param array $optParams Optional parameters. 115 * 116 * @opt_param int pageSize Optional. Specifies the maximum number of results to 117 * be returned at a time. 118 * @opt_param string pageToken Optional. Requests a specific page of results. 119 * @opt_param bool showDeleted Optional. Indicate that keys deleted in the past 120 * 30 days should also be returned. 121 * @return V2ListKeysResponse 122 */ 123 public function listProjectsLocationsKeys($parent, $optParams = []) 124 { 125 $params = ['parent' => $parent]; 126 $params = array_merge($params, $optParams); 127 return $this->call('list', [$params], V2ListKeysResponse::class); 128 } 129 /** 130 * Patches the modifiable fields of an API key. The key string of the API key 131 * isn't included in the response. NOTE: Key is a global resource; hence the 132 * only supported value for location is `global`. (keys.patch) 133 * 134 * @param string $name Output only. The resource name of the key. The `name` has 135 * the form: `projects//locations/global/keys/`. For example: 136 * `projects/123456867718/locations/global/keys/b7ff1f9f-8275-410a-94dd- 137 * 3855ee9b5dd2` NOTE: Key is a global resource; hence the only supported value 138 * for location is `global`. 139 * @param V2Key $postBody 140 * @param array $optParams Optional parameters. 141 * 142 * @opt_param string updateMask The field mask specifies which fields to be 143 * updated as part of this request. All other fields are ignored. Mutable fields 144 * are: `display_name`,`restrictions` and `annotations`. If an update mask is 145 * not provided, the service treats it as an implied mask equivalent to all 146 * allowed fields that are set on the wire. If the field mask has a special 147 * value "*", the service treats it equivalent to replace all allowed mutable 148 * fields. 149 * @return Operation 150 */ 151 public function patch($name, V2Key $postBody, $optParams = []) 152 { 153 $params = ['name' => $name, 'postBody' => $postBody]; 154 $params = array_merge($params, $optParams); 155 return $this->call('patch', [$params], Operation::class); 156 } 157 /** 158 * Undeletes an API key which was deleted within 30 days. NOTE: Key is a global 159 * resource; hence the only supported value for location is `global`. 160 * (keys.undelete) 161 * 162 * @param string $name Required. The resource name of the API key to be 163 * undeleted. 164 * @param V2UndeleteKeyRequest $postBody 165 * @param array $optParams Optional parameters. 166 * @return Operation 167 */ 168 public function undelete($name, V2UndeleteKeyRequest $postBody, $optParams = []) 169 { 170 $params = ['name' => $name, 'postBody' => $postBody]; 171 $params = array_merge($params, $optParams); 172 return $this->call('undelete', [$params], Operation::class); 173 } 174} 175 176// Adding a class alias for backwards compatibility with the previous class name. 177class_alias(ProjectsLocationsKeys::class, 'Google_Service_ApiKeysService_Resource_ProjectsLocationsKeys'); 178