List
Retrieves the list of Key resources for the specified service account.
- TypeScript
- Python
import { cloudApi, serviceClients, Session } from "@yandex-cloud/nodejs-sdk";
const KeyFormat = cloudApi.iam.key_service.KeyFormat;
const ListKeysRequest = cloudApi.iam.key_service.ListKeysRequest;
(async () => {
const authToken = process.env["YC_OAUTH_TOKEN"];
const session = new Session({ oauthToken: authToken });
const client = session.client(serviceClients.KeyServiceClient);
const result = await client.list(
ListKeysRequest.fromPartial({
// format: KeyFormat.undefined,
// serviceAccountId: "serviceAccountId",
// pageSize: 0,
// pageToken: "pageToken"
})
);
console.log(result);
})();
import os
import grpc
import yandexcloud
from yandex.cloud.iam.v1.key_service_pb2 import KeyFormat
from yandex.cloud.iam.v1.key_service_pb2_grpc import KeyServiceStub
from yandex.cloud.iam.v1.key_service_pb2 import ListKeysRequest
token = os.getenv("YC_OAUTH_TOKEN")
sdk = yandexcloud.SDK(token=token)
service = sdk.client(KeyServiceStub)
response = service.List(
ListKeysRequest(
# format = KeyFormat.undefined,
# service_account_id = "serviceAccountId",
# page_size = 0,
# page_token = "pageToken"
)
)
print(response)
ListKeysRequest
format
: KeyFormat
Output format of the key.
serviceAccountId
: string
ID of the service account to list key pairs for. To get the service account ID, use a yandex.cloud.iam.v1.ServiceAccountService.List request. If not specified, it defaults to the subject that made the request.
pageSize
: int64
The maximum number of results per page to return. If the number of available results is larger than page_size, the service returns a ListKeysResponse.next_page_token that can be used to get the next page of results in subsequent list requests. Default value: 100.
pageToken
: string
Page token. To get the next page of results, set page_token to the ListKeysResponse.next_page_token returned by a previous list request.
ListKeysResponse
keys
: Key
List of Key resources.
nextPageToken
: string
This token allows you to get the next page of results for list requests. If the number of results is larger than ListKeysRequest.page_size, use the next_page_token as the value for the ListKeysRequest.page_token query parameter in the next list request. Each subsequent list request will have its own next_page_token to continue paging through the results.
Key
A Key resource. For more information, see Authorized keys.
Algorithm
ALGORITHM_UNSPECIFIED
RSA_2048
RSA with a 2048-bit key size. Default value.
RSA_4096
RSA with a 4096-bit key size.
id
: string
ID of the Key resource.
One of subject
userAccountId
: stringID of the user account that the Key resource belongs to.
serviceAccountId
: stringID of the service account that the Key resource belongs to.
createdAt
: google.protobuf.Timestamp
Creation timestamp.
description
: string
Description of the Key resource. 0-256 characters long.
keyAlgorithm
: Algorithm
An algorithm used to generate a key pair of the Key resource.
publicKey
: string
A public key of the Key resource.
lastUsedAt
: google.protobuf.Timestamp
Timestamp for the last use of this key.