Instances of this class created via copy-construction or copy-assignment always compare equal. Instances created with equal std::shared_ptr<*Connection> objects compare equal. Objects that compare equal share the same underlying resources.
Performance
Creating a new instance of this class is a relatively expensive operation, new objects establish new connections to the service. In contrast, copy-construction, move-construction, and the corresponding assignment operations are relatively efficient as the copies share all underlying resources.
Thread Safety
Concurrent access to different instances of this class, even if they compare equal, is guaranteed to work. Two or more threads operating on the same instance of this class is not guaranteed to work. Since copy-construction and move-construction is a relatively efficient operation, consider using such a copy when using this class from multiple threads.
NOTE: Key is a global resource; hence the only supported value for location is global.
Parameters
Name
Description
parent
std::string const &
Required. The project in which the API key is created.
key
google::api::apikeys::v2::Key const &
Required. The API key fields to set at creation time. You can configure only the display_name, restrictions, and annotations fields.
key_id
std::string const &
User specified key id (optional). If specified, it will become the final component of the key resource name.
The id must be unique within the project, must conform with RFC-1034, is restricted to lower-cased letters, and has a maximum length of 63 characters. In another word, the id must match the regular expression: [a-z]([a-z0-9-]{0,61}[a-z0-9])?.
The id must NOT be a UUID-like string.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
A future that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the StatusOr returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.api.apikeys.v2.Key proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.
Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.api.apikeys.v2.CreateKeyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
A future that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the StatusOr returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.api.apikeys.v2.Key proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.
ListKeys(std::string const &, Options)
Lists the API keys owned by a project.
The key string of the API key isn't included in the response.
NOTE: Key is a global resource; hence the only supported value for location is global.
Parameters
Name
Description
parent
std::string const &
Required. Lists all API keys associated with this project.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
Returns
Type
Description
StreamRange< google::api::apikeys::v2::Key >
a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.api.apikeys.v2.Key, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.
The key string of the API key isn't included in the response.
NOTE: Key is a global resource; hence the only supported value for location is global.
Parameters
Name
Description
request
google::api::apikeys::v2::ListKeysRequest
Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.api.apikeys.v2.ListKeysRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
Returns
Type
Description
StreamRange< google::api::apikeys::v2::Key >
a StreamRange to iterate of the results. See the documentation of this type for details. In brief, this class has begin() and end() member functions returning a iterator class meeting the input iterator requirements. The value type for this iterator is a StatusOr as the iteration may fail even after some values are retrieved successfully, for example, if there is a network disconnect. An empty set of results does not indicate an error, it indicates that there are no resources meeting the request criteria. On a successful iteration the StatusOr<T> contains elements of type google.api.apikeys.v2.Key, or rather, the C++ class generated by Protobuf from that type. Please consult the Protobuf documentation for details on the Protobuf mapping rules.
GetKey(std::string const &, Options)
Gets the metadata for an API key.
The key string of the API key isn't included in the response.
NOTE: Key is a global resource; hence the only supported value for location is global.
Parameters
Name
Description
name
std::string const &
Required. The resource name of the API key to get.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
The key string of the API key isn't included in the response.
NOTE: Key is a global resource; hence the only supported value for location is global.
Parameters
Name
Description
request
google::api::apikeys::v2::GetKeyRequest const &
Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.api.apikeys.v2.GetKeyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.api.apikeys.v2.GetKeyStringRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
The key string of the API key isn't included in the response.
NOTE: Key is a global resource; hence the only supported value for location is global.
Parameters
Name
Description
key
google::api::apikeys::v2::Key const &
Required. Set the name field to the resource name of the API key to be updated. You can update only the display_name, restrictions, and annotations fields.
update_mask
google::protobuf::FieldMask const &
The field mask specifies which fields to be updated as part of this request. All other fields are ignored. Mutable fields are: display_name, restrictions, and annotations. If an update mask is not provided, the service treats it as an implied mask equivalent to all allowed fields that are set on the wire. If the field mask has a special value "*", the service treats it equivalent to replace all allowed mutable fields.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
A future that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the StatusOr returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.api.apikeys.v2.Key proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.
Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.api.apikeys.v2.UpdateKeyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
A future that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the StatusOr returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.api.apikeys.v2.Key proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.
DeleteKey(std::string const &, Options)
Deletes an API key.
Deleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project.
NOTE: Key is a global resource; hence the only supported value for location is global.
Parameters
Name
Description
name
std::string const &
Required. The resource name of the API key to be deleted.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
A future that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the StatusOr returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.api.apikeys.v2.Key proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.
Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.api.apikeys.v2.DeleteKeyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
A future that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the StatusOr returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.api.apikeys.v2.Key proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.
Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.api.apikeys.v2.UndeleteKeyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
A future that becomes satisfied when the LRO (Long Running Operation) completes or the polling policy in effect for this call is exhausted. The future is satisfied with an error if the LRO completes with an error or the polling policy is exhausted. In this case the StatusOr returned by the future contains the error. If the LRO completes successfully the value of the future contains the LRO's result. For this RPC the result is a google.api.apikeys.v2.Key proto message. The C++ class representing this message is created by Protobuf, using the Protobuf mapping rules.
Unary RPCs, such as the one wrapped by this function, receive a single request proto message which includes all the inputs for the RPC. In this case, the proto message is a google.api.apikeys.v2.LookupKeyRequest. Proto messages are converted to C++ classes by Protobuf, using the Protobuf mapping rules.
opts
Options
Optional. Override the class-level options, such as retry and backoff policies.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-14 UTC."],[[["\u003cp\u003eThis documentation outlines the \u003ccode\u003eApiKeysClient\u003c/code\u003e class, which is used to manage API keys for projects, and it is available in multiple versions, with version \u003ccode\u003e2.37.0-rc\u003c/code\u003e being the latest.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eApiKeysClient\u003c/code\u003e class supports various operations on API keys, including creating, listing, retrieving (metadata and the key string), updating, deleting, and undeleting keys within a 30-day window.\u003c/p\u003e\n"],["\u003cp\u003eThe class offers both methods that take individual parameters and methods that take a complete request proto for the operations performed on API Keys.\u003c/p\u003e\n"],["\u003cp\u003eEquality for \u003ccode\u003eApiKeysClient\u003c/code\u003e is determined by the underlying \u003ccode\u003estd::shared_ptr<Connection>\u003c/code\u003e, and while copy and move operations are efficient, creating new instances is expensive due to service connection overhead, and concurrent access to the same instance is not guaranteed to be thread-safe.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eLookupKey\u003c/code\u003e method is provided, to determine the project and resource name associated with a provided key string, however a key string is not included in the returned results of any of the other methods.\u003c/p\u003e\n"]]],[],null,["# Class ApiKeysClient (2.19.0)\n\nVersion 2.19.0keyboard_arrow_down\n\n- [2.42.0-rc (latest)](/cpp/docs/reference/apikeys/latest/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.41.0](/cpp/docs/reference/apikeys/2.41.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.40.0](/cpp/docs/reference/apikeys/2.40.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.39.0](/cpp/docs/reference/apikeys/2.39.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.38.0](/cpp/docs/reference/apikeys/2.38.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.37.0](/cpp/docs/reference/apikeys/2.37.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.36.0](/cpp/docs/reference/apikeys/2.36.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.35.0](/cpp/docs/reference/apikeys/2.35.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.34.0](/cpp/docs/reference/apikeys/2.34.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.33.0](/cpp/docs/reference/apikeys/2.33.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.32.0](/cpp/docs/reference/apikeys/2.32.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.31.0](/cpp/docs/reference/apikeys/2.31.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.30.0](/cpp/docs/reference/apikeys/2.30.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.29.0](/cpp/docs/reference/apikeys/2.29.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.28.0](/cpp/docs/reference/apikeys/2.28.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.27.0](/cpp/docs/reference/apikeys/2.27.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.26.0](/cpp/docs/reference/apikeys/2.26.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.25.1](/cpp/docs/reference/apikeys/2.25.1/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.24.0](/cpp/docs/reference/apikeys/2.24.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.23.0](/cpp/docs/reference/apikeys/2.23.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.22.1](/cpp/docs/reference/apikeys/2.22.1/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.21.0](/cpp/docs/reference/apikeys/2.21.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.20.0](/cpp/docs/reference/apikeys/2.20.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.19.0](/cpp/docs/reference/apikeys/2.19.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.18.0](/cpp/docs/reference/apikeys/2.18.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.17.0](/cpp/docs/reference/apikeys/2.17.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.16.0](/cpp/docs/reference/apikeys/2.16.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.15.1](/cpp/docs/reference/apikeys/2.15.1/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.14.0](/cpp/docs/reference/apikeys/2.14.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.13.0](/cpp/docs/reference/apikeys/2.13.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.12.0](/cpp/docs/reference/apikeys/2.12.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient)\n- [2.11.0](/cpp/docs/reference/apikeys/2.11.0/classgoogle_1_1cloud_1_1apikeys__v2_1_1ApiKeysClient) \nManages the API keys associated with projects. \n\n###### Equality\n\nInstances of this class created via copy-construction or copy-assignment always compare equal. Instances created with equal `std::shared_ptr\u003c*Connection\u003e` objects compare equal. Objects that compare equal share the same underlying resources.\n\n###### Performance\n\nCreating a new instance of this class is a relatively expensive operation, new objects establish new connections to the service. In contrast, copy-construction, move-construction, and the corresponding assignment operations are relatively efficient as the copies share all underlying resources.\n\n###### Thread Safety\n\nConcurrent access to different instances of this class, even if they compare equal, is guaranteed to work. Two or more threads operating on the same instance of this class is not guaranteed to work. Since copy-construction and move-construction is a relatively efficient operation, consider using such a copy when using this class from multiple threads.\n\nConstructors\n------------\n\n### ApiKeysClient(ApiKeysClient const \\&)\n\nCopy and move support\n\n### ApiKeysClient(ApiKeysClient \\&\\&)\n\nCopy and move support\n\n### ApiKeysClient(std::shared_ptr\\\u003c ApiKeysConnection \\\u003e, Options)\n\nOperators\n---------\n\n### operator=(ApiKeysClient const \\&)\n\nCopy and move support\n\n### operator=(ApiKeysClient \\&\\&)\n\nCopy and move support\n\nFunctions\n---------\n\n### CreateKey(std::string const \\&, google::api::apikeys::v2::Key const \\&, std::string const \\&, Options)\n\nCreates a new API key. \nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### CreateKey(google::api::apikeys::v2::CreateKeyRequest const \\&, Options)\n\nCreates a new API key. \nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### ListKeys(std::string const \\&, Options)\n\nLists the API keys owned by a project. \nThe key string of the API key isn't included in the response.\n\nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### ListKeys(google::api::apikeys::v2::ListKeysRequest, Options)\n\nLists the API keys owned by a project. \nThe key string of the API key isn't included in the response.\n\nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### GetKey(std::string const \\&, Options)\n\nGets the metadata for an API key. \nThe key string of the API key isn't included in the response.\n\nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### GetKey(google::api::apikeys::v2::GetKeyRequest const \\&, Options)\n\nGets the metadata for an API key. \nThe key string of the API key isn't included in the response.\n\nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### GetKeyString(std::string const \\&, Options)\n\nGet the key string for an API key. \nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### GetKeyString(google::api::apikeys::v2::GetKeyStringRequest const \\&, Options)\n\nGet the key string for an API key. \nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### UpdateKey(google::api::apikeys::v2::Key const \\&, google::protobuf::FieldMask const \\&, Options)\n\nPatches the modifiable fields of an API key. \nThe key string of the API key isn't included in the response.\n\nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### UpdateKey(google::api::apikeys::v2::UpdateKeyRequest const \\&, Options)\n\nPatches the modifiable fields of an API key. \nThe key string of the API key isn't included in the response.\n\nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### DeleteKey(std::string const \\&, Options)\n\nDeletes an API key. \nDeleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project.\n\nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### DeleteKey(google::api::apikeys::v2::DeleteKeyRequest const \\&, Options)\n\nDeletes an API key. \nDeleted key can be retrieved within 30 days of deletion. Afterward, key will be purged from the project.\n\nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### UndeleteKey(google::api::apikeys::v2::UndeleteKeyRequest const \\&, Options)\n\nUndeletes an API key which was deleted within 30 days. \nNOTE: Key is a global resource; hence the only supported value for location is `global`.\n\n### LookupKey(google::api::apikeys::v2::LookupKeyRequest const \\&, Options)\n\nFind the parent project and resource name of the API key that matches the key string in the request. \nIf the API key has been purged, resource name will not be set. The service account must have the `apikeys.keys.lookup` permission on the parent project."]]