diff --git a/packages/google-cloud-oslogin/README.md b/packages/google-cloud-oslogin/README.md index 5b80022bd0d..747c5bc8d37 100644 --- a/packages/google-cloud-oslogin/README.md +++ b/packages/google-cloud-oslogin/README.md @@ -102,12 +102,14 @@ Samples are in the [`samples/`](https://github.com/googleapis/google-cloud-node/ | Sample | Source Code | Try it | | --------------------------- | --------------------------------- | ------ | +| Os_login_service.create_ssh_public_key | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.create_ssh_public_key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1/os_login_service.create_ssh_public_key.js,samples/README.md) | | Os_login_service.delete_posix_account | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_posix_account.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_posix_account.js,samples/README.md) | | Os_login_service.delete_ssh_public_key | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_ssh_public_key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_ssh_public_key.js,samples/README.md) | | Os_login_service.get_login_profile | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_login_profile.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_login_profile.js,samples/README.md) | | Os_login_service.get_ssh_public_key | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_ssh_public_key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1/os_login_service.get_ssh_public_key.js,samples/README.md) | | Os_login_service.import_ssh_public_key | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.import_ssh_public_key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1/os_login_service.import_ssh_public_key.js,samples/README.md) | | Os_login_service.update_ssh_public_key | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.update_ssh_public_key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1/os_login_service.update_ssh_public_key.js,samples/README.md) | +| Os_login_service.create_ssh_public_key | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.create_ssh_public_key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.create_ssh_public_key.js,samples/README.md) | | Os_login_service.delete_posix_account | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_posix_account.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_posix_account.js,samples/README.md) | | Os_login_service.delete_ssh_public_key | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_ssh_public_key.js,samples/README.md) | | Os_login_service.get_login_profile | [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js,samples/README.md) | diff --git a/packages/google-cloud-oslogin/protos/google/cloud/oslogin/common/common.proto b/packages/google-cloud-oslogin/protos/google/cloud/oslogin/common/common.proto index 4d9755f0d20..6eeaf8908d8 100644 --- a/packages/google-cloud-oslogin/protos/google/cloud/oslogin/common/common.proto +++ b/packages/google-cloud-oslogin/protos/google/cloud/oslogin/common/common.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -26,8 +25,6 @@ option java_outer_classname = "OsLoginProto"; option java_package = "com.google.cloud.oslogin.common"; option php_namespace = "Google\\Cloud\\OsLogin\\Common"; option ruby_package = "Google::Cloud::OsLogin::Common"; - -// Define a "User" resource owned by OS Login. option (google.api.resource_definition) = { type: "oslogin.googleapis.com/User" pattern: "users/{user}" diff --git a/packages/google-cloud-oslogin/protos/google/cloud/oslogin/v1/oslogin.proto b/packages/google-cloud-oslogin/protos/google/cloud/oslogin/v1/oslogin.proto index 25e9be0a07e..fb3575600c4 100644 --- a/packages/google-cloud-oslogin/protos/google/cloud/oslogin/v1/oslogin.proto +++ b/packages/google-cloud-oslogin/protos/google/cloud/oslogin/v1/oslogin.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -41,7 +40,18 @@ service OsLoginService { option (google.api.default_host) = "oslogin.googleapis.com"; option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/cloud-platform," - "https://www.googleapis.com/auth/compute"; + "https://www.googleapis.com/auth/cloud-platform.read-only," + "https://www.googleapis.com/auth/compute," + "https://www.googleapis.com/auth/compute.readonly"; + + // Create an SSH public key + rpc CreateSshPublicKey(CreateSshPublicKeyRequest) returns (google.cloud.oslogin.common.SshPublicKey) { + option (google.api.http) = { + post: "/v1/{parent=users/*}/sshPublicKeys" + body: "ssh_public_key" + }; + option (google.api.method_signature) = "parent,ssh_public_key"; + } // Deletes a POSIX account. rpc DeletePosixAccount(DeletePosixAccountRequest) returns (google.protobuf.Empty) { @@ -113,6 +123,20 @@ message LoginProfile { map ssh_public_keys = 3; } +// A request message for creating an SSH public key. +message CreateSshPublicKeyRequest { + // Required. The unique ID for the user in format `users/{user}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "oslogin.googleapis.com/SshPublicKey" + } + ]; + + // Required. The SSH public key and expiration time. + google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(google.api.field_behavior) = REQUIRED]; +} + // A request message for deleting a POSIX account entry. message DeletePosixAccountRequest { // Required. A reference to the POSIX account to update. POSIX accounts are identified @@ -190,6 +214,9 @@ message ImportSshPublicKeyRequest { message ImportSshPublicKeyResponse { // The login profile information for the user. LoginProfile login_profile = 1; + + // Detailed information about import results. + string details = 2; } // A request message for updating an SSH public key. diff --git a/packages/google-cloud-oslogin/protos/google/cloud/oslogin/v1beta/oslogin.proto b/packages/google-cloud-oslogin/protos/google/cloud/oslogin/v1beta/oslogin.proto index a5d7847466a..9a7a06b4a03 100644 --- a/packages/google-cloud-oslogin/protos/google/cloud/oslogin/v1beta/oslogin.proto +++ b/packages/google-cloud-oslogin/protos/google/cloud/oslogin/v1beta/oslogin.proto @@ -1,4 +1,4 @@ -// Copyright 2019 Google LLC. +// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. @@ -11,7 +11,6 @@ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. -// syntax = "proto3"; @@ -45,6 +44,15 @@ service OsLoginService { "https://www.googleapis.com/auth/compute," "https://www.googleapis.com/auth/compute.readonly"; + // Create an SSH public key + rpc CreateSshPublicKey(CreateSshPublicKeyRequest) returns (google.cloud.oslogin.common.SshPublicKey) { + option (google.api.http) = { + post: "/v1beta/{parent=users/*}/sshPublicKeys" + body: "ssh_public_key" + }; + option (google.api.method_signature) = "parent,ssh_public_key"; + } + // Deletes a POSIX account. rpc DeletePosixAccount(DeletePosixAccountRequest) returns (google.protobuf.Empty) { option (google.api.http) = { @@ -113,6 +121,23 @@ message LoginProfile { // A map from SSH public key fingerprint to the associated key object. map ssh_public_keys = 3; + + // The registered security key credentials for a user. + repeated SecurityKey security_keys = 5; +} + +// A request message for creating an SSH public key. +message CreateSshPublicKeyRequest { + // Required. The unique ID for the user in format `users/{user}`. + string parent = 1 [ + (google.api.field_behavior) = REQUIRED, + (google.api.resource_reference) = { + child_type: "oslogin.googleapis.com/SshPublicKey" + } + ]; + + // Required. The SSH public key and expiration time. + google.cloud.oslogin.common.SshPublicKey ssh_public_key = 2 [(google.api.field_behavior) = REQUIRED]; } // A request message for deleting a POSIX account entry. @@ -146,13 +171,19 @@ message GetLoginProfileRequest { // Required. The unique ID for the user in format `users/{user}`. string name = 1 [ (google.api.field_behavior) = REQUIRED, - (google.api.resource_reference).type = "oslogin.googleapis.com/User"]; + (google.api.resource_reference) = { + type: "oslogin.googleapis.com/User" + } + ]; // The project ID of the Google Cloud Platform project. string project_id = 2; // A system ID for filtering the results of the request. string system_id = 3; + + // The view configures whether to retrieve security keys information. + LoginProfileView view = 4; } // A request message for retrieving an SSH public key. @@ -180,12 +211,18 @@ message ImportSshPublicKeyRequest { // The project ID of the Google Cloud Platform project. string project_id = 3; + + // The view configures whether to retrieve security keys information. + LoginProfileView view = 4; } // A response message for importing an SSH public key. message ImportSshPublicKeyResponse { // The login profile information for the user. LoginProfile login_profile = 1; + + // Detailed information about import results. + string details = 2; } // A request message for updating an SSH public key. @@ -206,3 +243,46 @@ message UpdateSshPublicKeyRequest { // Mask to control which fields get updated. Updates all if not present. google.protobuf.FieldMask update_mask = 3; } + +// The credential information for a Google registered security key. +message SecurityKey { + // Public key text in SSH format, defined by + // [RFC4253]("https://www.ietf.org/rfc/rfc4253.txt") section 6.6. + string public_key = 1; + + // Hardware-backed private key text in SSH format. + string private_key = 2; + + // The FIDO protocol type used to register this credential. + oneof protocol_type { + // The U2F protocol type. + UniversalTwoFactor universal_two_factor = 3; + + // The Web Authentication protocol type. + WebAuthn web_authn = 4; + } +} + +// Security key information specific to the U2F protocol. +message UniversalTwoFactor { + // Application ID for the U2F protocol. + string app_id = 1; +} + +// Security key information specific to the Web Authentication protocol. +message WebAuthn { + // Relying party ID for Web Authentication. + string rp_id = 1; +} + +// The login profile view limits the user content retrieved. +enum LoginProfileView { + // The default login profile view. The API defaults to the BASIC view. + LOGIN_PROFILE_VIEW_UNSPECIFIED = 0; + + // Includes POSIX and SSH key information. + BASIC = 1; + + // Include security key information for the user. + SECURITY_KEY = 2; +} diff --git a/packages/google-cloud-oslogin/protos/protos.d.ts b/packages/google-cloud-oslogin/protos/protos.d.ts index 16610929e8c..3f993ae2c58 100644 --- a/packages/google-cloud-oslogin/protos/protos.d.ts +++ b/packages/google-cloud-oslogin/protos/protos.d.ts @@ -329,6 +329,20 @@ export namespace google { */ public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): OsLoginService; + /** + * Calls CreateSshPublicKey. + * @param request CreateSshPublicKeyRequest message or plain object + * @param callback Node-style callback called with the error, if any, and SshPublicKey + */ + public createSshPublicKey(request: google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, callback: google.cloud.oslogin.v1.OsLoginService.CreateSshPublicKeyCallback): void; + + /** + * Calls CreateSshPublicKey. + * @param request CreateSshPublicKeyRequest message or plain object + * @returns Promise + */ + public createSshPublicKey(request: google.cloud.oslogin.v1.ICreateSshPublicKeyRequest): Promise; + /** * Calls DeletePosixAccount. * @param request DeletePosixAccountRequest message or plain object @@ -416,6 +430,13 @@ export namespace google { namespace OsLoginService { + /** + * Callback as used by {@link google.cloud.oslogin.v1.OsLoginService|createSshPublicKey}. + * @param error Error, if any + * @param [response] SshPublicKey + */ + type CreateSshPublicKeyCallback = (error: (Error|null), response?: google.cloud.oslogin.common.SshPublicKey) => void; + /** * Callback as used by {@link google.cloud.oslogin.v1.OsLoginService|deletePosixAccount}. * @param error Error, if any @@ -568,6 +589,109 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a CreateSshPublicKeyRequest. */ + interface ICreateSshPublicKeyRequest { + + /** CreateSshPublicKeyRequest parent */ + parent?: (string|null); + + /** CreateSshPublicKeyRequest sshPublicKey */ + sshPublicKey?: (google.cloud.oslogin.common.ISshPublicKey|null); + } + + /** Represents a CreateSshPublicKeyRequest. */ + class CreateSshPublicKeyRequest implements ICreateSshPublicKeyRequest { + + /** + * Constructs a new CreateSshPublicKeyRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.oslogin.v1.ICreateSshPublicKeyRequest); + + /** CreateSshPublicKeyRequest parent. */ + public parent: string; + + /** CreateSshPublicKeyRequest sshPublicKey. */ + public sshPublicKey?: (google.cloud.oslogin.common.ISshPublicKey|null); + + /** + * Creates a new CreateSshPublicKeyRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateSshPublicKeyRequest instance + */ + public static create(properties?: google.cloud.oslogin.v1.ICreateSshPublicKeyRequest): google.cloud.oslogin.v1.CreateSshPublicKeyRequest; + + /** + * Encodes the specified CreateSshPublicKeyRequest message. Does not implicitly {@link google.cloud.oslogin.v1.CreateSshPublicKeyRequest.verify|verify} messages. + * @param message CreateSshPublicKeyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateSshPublicKeyRequest message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1.CreateSshPublicKeyRequest.verify|verify} messages. + * @param message CreateSshPublicKeyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateSshPublicKeyRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateSshPublicKeyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.oslogin.v1.CreateSshPublicKeyRequest; + + /** + * Decodes a CreateSshPublicKeyRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateSshPublicKeyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.oslogin.v1.CreateSshPublicKeyRequest; + + /** + * Verifies a CreateSshPublicKeyRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreateSshPublicKeyRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateSshPublicKeyRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.oslogin.v1.CreateSshPublicKeyRequest; + + /** + * Creates a plain object from a CreateSshPublicKeyRequest message. Also converts values to other types if specified. + * @param message CreateSshPublicKeyRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.oslogin.v1.CreateSshPublicKeyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateSshPublicKeyRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateSshPublicKeyRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a DeletePosixAccountRequest. */ interface IDeletePosixAccountRequest { @@ -1082,6 +1206,9 @@ export namespace google { /** ImportSshPublicKeyResponse loginProfile */ loginProfile?: (google.cloud.oslogin.v1.ILoginProfile|null); + + /** ImportSshPublicKeyResponse details */ + details?: (string|null); } /** Represents an ImportSshPublicKeyResponse. */ @@ -1096,6 +1223,9 @@ export namespace google { /** ImportSshPublicKeyResponse loginProfile. */ public loginProfile?: (google.cloud.oslogin.v1.ILoginProfile|null); + /** ImportSshPublicKeyResponse details. */ + public details: string; + /** * Creates a new ImportSshPublicKeyResponse instance using the specified properties. * @param [properties] Properties to set @@ -1307,6 +1437,20 @@ export namespace google { */ public static create(rpcImpl: $protobuf.RPCImpl, requestDelimited?: boolean, responseDelimited?: boolean): OsLoginService; + /** + * Calls CreateSshPublicKey. + * @param request CreateSshPublicKeyRequest message or plain object + * @param callback Node-style callback called with the error, if any, and SshPublicKey + */ + public createSshPublicKey(request: google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, callback: google.cloud.oslogin.v1beta.OsLoginService.CreateSshPublicKeyCallback): void; + + /** + * Calls CreateSshPublicKey. + * @param request CreateSshPublicKeyRequest message or plain object + * @returns Promise + */ + public createSshPublicKey(request: google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest): Promise; + /** * Calls DeletePosixAccount. * @param request DeletePosixAccountRequest message or plain object @@ -1394,6 +1538,13 @@ export namespace google { namespace OsLoginService { + /** + * Callback as used by {@link google.cloud.oslogin.v1beta.OsLoginService|createSshPublicKey}. + * @param error Error, if any + * @param [response] SshPublicKey + */ + type CreateSshPublicKeyCallback = (error: (Error|null), response?: google.cloud.oslogin.common.SshPublicKey) => void; + /** * Callback as used by {@link google.cloud.oslogin.v1beta.OsLoginService|deletePosixAccount}. * @param error Error, if any @@ -1448,6 +1599,9 @@ export namespace google { /** LoginProfile sshPublicKeys */ sshPublicKeys?: ({ [k: string]: google.cloud.oslogin.common.ISshPublicKey }|null); + + /** LoginProfile securityKeys */ + securityKeys?: (google.cloud.oslogin.v1beta.ISecurityKey[]|null); } /** Represents a LoginProfile. */ @@ -1468,6 +1622,9 @@ export namespace google { /** LoginProfile sshPublicKeys. */ public sshPublicKeys: { [k: string]: google.cloud.oslogin.common.ISshPublicKey }; + /** LoginProfile securityKeys. */ + public securityKeys: google.cloud.oslogin.v1beta.ISecurityKey[]; + /** * Creates a new LoginProfile instance using the specified properties. * @param [properties] Properties to set @@ -1546,6 +1703,109 @@ export namespace google { public static getTypeUrl(typeUrlPrefix?: string): string; } + /** Properties of a CreateSshPublicKeyRequest. */ + interface ICreateSshPublicKeyRequest { + + /** CreateSshPublicKeyRequest parent */ + parent?: (string|null); + + /** CreateSshPublicKeyRequest sshPublicKey */ + sshPublicKey?: (google.cloud.oslogin.common.ISshPublicKey|null); + } + + /** Represents a CreateSshPublicKeyRequest. */ + class CreateSshPublicKeyRequest implements ICreateSshPublicKeyRequest { + + /** + * Constructs a new CreateSshPublicKeyRequest. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest); + + /** CreateSshPublicKeyRequest parent. */ + public parent: string; + + /** CreateSshPublicKeyRequest sshPublicKey. */ + public sshPublicKey?: (google.cloud.oslogin.common.ISshPublicKey|null); + + /** + * Creates a new CreateSshPublicKeyRequest instance using the specified properties. + * @param [properties] Properties to set + * @returns CreateSshPublicKeyRequest instance + */ + public static create(properties?: google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest): google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest; + + /** + * Encodes the specified CreateSshPublicKeyRequest message. Does not implicitly {@link google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest.verify|verify} messages. + * @param message CreateSshPublicKeyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified CreateSshPublicKeyRequest message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest.verify|verify} messages. + * @param message CreateSshPublicKeyRequest message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a CreateSshPublicKeyRequest message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns CreateSshPublicKeyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest; + + /** + * Decodes a CreateSshPublicKeyRequest message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns CreateSshPublicKeyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest; + + /** + * Verifies a CreateSshPublicKeyRequest message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a CreateSshPublicKeyRequest message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns CreateSshPublicKeyRequest + */ + public static fromObject(object: { [k: string]: any }): google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest; + + /** + * Creates a plain object from a CreateSshPublicKeyRequest message. Also converts values to other types if specified. + * @param message CreateSshPublicKeyRequest + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this CreateSshPublicKeyRequest to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for CreateSshPublicKeyRequest + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + /** Properties of a DeletePosixAccountRequest. */ interface IDeletePosixAccountRequest { @@ -1751,6 +2011,9 @@ export namespace google { /** GetLoginProfileRequest systemId */ systemId?: (string|null); + + /** GetLoginProfileRequest view */ + view?: (google.cloud.oslogin.v1beta.LoginProfileView|keyof typeof google.cloud.oslogin.v1beta.LoginProfileView|null); } /** Represents a GetLoginProfileRequest. */ @@ -1771,6 +2034,9 @@ export namespace google { /** GetLoginProfileRequest systemId. */ public systemId: string; + /** GetLoginProfileRequest view. */ + public view: (google.cloud.oslogin.v1beta.LoginProfileView|keyof typeof google.cloud.oslogin.v1beta.LoginProfileView); + /** * Creates a new GetLoginProfileRequest instance using the specified properties. * @param [properties] Properties to set @@ -1957,6 +2223,9 @@ export namespace google { /** ImportSshPublicKeyRequest projectId */ projectId?: (string|null); + + /** ImportSshPublicKeyRequest view */ + view?: (google.cloud.oslogin.v1beta.LoginProfileView|keyof typeof google.cloud.oslogin.v1beta.LoginProfileView|null); } /** Represents an ImportSshPublicKeyRequest. */ @@ -1977,6 +2246,9 @@ export namespace google { /** ImportSshPublicKeyRequest projectId. */ public projectId: string; + /** ImportSshPublicKeyRequest view. */ + public view: (google.cloud.oslogin.v1beta.LoginProfileView|keyof typeof google.cloud.oslogin.v1beta.LoginProfileView); + /** * Creates a new ImportSshPublicKeyRequest instance using the specified properties. * @param [properties] Properties to set @@ -2060,6 +2332,9 @@ export namespace google { /** ImportSshPublicKeyResponse loginProfile */ loginProfile?: (google.cloud.oslogin.v1beta.ILoginProfile|null); + + /** ImportSshPublicKeyResponse details */ + details?: (string|null); } /** Represents an ImportSshPublicKeyResponse. */ @@ -2074,6 +2349,9 @@ export namespace google { /** ImportSshPublicKeyResponse loginProfile. */ public loginProfile?: (google.cloud.oslogin.v1beta.ILoginProfile|null); + /** ImportSshPublicKeyResponse details. */ + public details: string; + /** * Creates a new ImportSshPublicKeyResponse instance using the specified properties. * @param [properties] Properties to set @@ -2260,6 +2538,325 @@ export namespace google { */ public static getTypeUrl(typeUrlPrefix?: string): string; } + + /** Properties of a SecurityKey. */ + interface ISecurityKey { + + /** SecurityKey publicKey */ + publicKey?: (string|null); + + /** SecurityKey privateKey */ + privateKey?: (string|null); + + /** SecurityKey universalTwoFactor */ + universalTwoFactor?: (google.cloud.oslogin.v1beta.IUniversalTwoFactor|null); + + /** SecurityKey webAuthn */ + webAuthn?: (google.cloud.oslogin.v1beta.IWebAuthn|null); + } + + /** Represents a SecurityKey. */ + class SecurityKey implements ISecurityKey { + + /** + * Constructs a new SecurityKey. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.oslogin.v1beta.ISecurityKey); + + /** SecurityKey publicKey. */ + public publicKey: string; + + /** SecurityKey privateKey. */ + public privateKey: string; + + /** SecurityKey universalTwoFactor. */ + public universalTwoFactor?: (google.cloud.oslogin.v1beta.IUniversalTwoFactor|null); + + /** SecurityKey webAuthn. */ + public webAuthn?: (google.cloud.oslogin.v1beta.IWebAuthn|null); + + /** SecurityKey protocolType. */ + public protocolType?: ("universalTwoFactor"|"webAuthn"); + + /** + * Creates a new SecurityKey instance using the specified properties. + * @param [properties] Properties to set + * @returns SecurityKey instance + */ + public static create(properties?: google.cloud.oslogin.v1beta.ISecurityKey): google.cloud.oslogin.v1beta.SecurityKey; + + /** + * Encodes the specified SecurityKey message. Does not implicitly {@link google.cloud.oslogin.v1beta.SecurityKey.verify|verify} messages. + * @param message SecurityKey message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.oslogin.v1beta.ISecurityKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified SecurityKey message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1beta.SecurityKey.verify|verify} messages. + * @param message SecurityKey message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.oslogin.v1beta.ISecurityKey, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a SecurityKey message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns SecurityKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.oslogin.v1beta.SecurityKey; + + /** + * Decodes a SecurityKey message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns SecurityKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.oslogin.v1beta.SecurityKey; + + /** + * Verifies a SecurityKey message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a SecurityKey message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns SecurityKey + */ + public static fromObject(object: { [k: string]: any }): google.cloud.oslogin.v1beta.SecurityKey; + + /** + * Creates a plain object from a SecurityKey message. Also converts values to other types if specified. + * @param message SecurityKey + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.oslogin.v1beta.SecurityKey, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this SecurityKey to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for SecurityKey + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of an UniversalTwoFactor. */ + interface IUniversalTwoFactor { + + /** UniversalTwoFactor appId */ + appId?: (string|null); + } + + /** Represents an UniversalTwoFactor. */ + class UniversalTwoFactor implements IUniversalTwoFactor { + + /** + * Constructs a new UniversalTwoFactor. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.oslogin.v1beta.IUniversalTwoFactor); + + /** UniversalTwoFactor appId. */ + public appId: string; + + /** + * Creates a new UniversalTwoFactor instance using the specified properties. + * @param [properties] Properties to set + * @returns UniversalTwoFactor instance + */ + public static create(properties?: google.cloud.oslogin.v1beta.IUniversalTwoFactor): google.cloud.oslogin.v1beta.UniversalTwoFactor; + + /** + * Encodes the specified UniversalTwoFactor message. Does not implicitly {@link google.cloud.oslogin.v1beta.UniversalTwoFactor.verify|verify} messages. + * @param message UniversalTwoFactor message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.oslogin.v1beta.IUniversalTwoFactor, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified UniversalTwoFactor message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1beta.UniversalTwoFactor.verify|verify} messages. + * @param message UniversalTwoFactor message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.oslogin.v1beta.IUniversalTwoFactor, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes an UniversalTwoFactor message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns UniversalTwoFactor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.oslogin.v1beta.UniversalTwoFactor; + + /** + * Decodes an UniversalTwoFactor message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns UniversalTwoFactor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.oslogin.v1beta.UniversalTwoFactor; + + /** + * Verifies an UniversalTwoFactor message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates an UniversalTwoFactor message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns UniversalTwoFactor + */ + public static fromObject(object: { [k: string]: any }): google.cloud.oslogin.v1beta.UniversalTwoFactor; + + /** + * Creates a plain object from an UniversalTwoFactor message. Also converts values to other types if specified. + * @param message UniversalTwoFactor + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.oslogin.v1beta.UniversalTwoFactor, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this UniversalTwoFactor to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for UniversalTwoFactor + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** Properties of a WebAuthn. */ + interface IWebAuthn { + + /** WebAuthn rpId */ + rpId?: (string|null); + } + + /** Represents a WebAuthn. */ + class WebAuthn implements IWebAuthn { + + /** + * Constructs a new WebAuthn. + * @param [properties] Properties to set + */ + constructor(properties?: google.cloud.oslogin.v1beta.IWebAuthn); + + /** WebAuthn rpId. */ + public rpId: string; + + /** + * Creates a new WebAuthn instance using the specified properties. + * @param [properties] Properties to set + * @returns WebAuthn instance + */ + public static create(properties?: google.cloud.oslogin.v1beta.IWebAuthn): google.cloud.oslogin.v1beta.WebAuthn; + + /** + * Encodes the specified WebAuthn message. Does not implicitly {@link google.cloud.oslogin.v1beta.WebAuthn.verify|verify} messages. + * @param message WebAuthn message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encode(message: google.cloud.oslogin.v1beta.IWebAuthn, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Encodes the specified WebAuthn message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1beta.WebAuthn.verify|verify} messages. + * @param message WebAuthn message or plain object to encode + * @param [writer] Writer to encode to + * @returns Writer + */ + public static encodeDelimited(message: google.cloud.oslogin.v1beta.IWebAuthn, writer?: $protobuf.Writer): $protobuf.Writer; + + /** + * Decodes a WebAuthn message from the specified reader or buffer. + * @param reader Reader or buffer to decode from + * @param [length] Message length if known beforehand + * @returns WebAuthn + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decode(reader: ($protobuf.Reader|Uint8Array), length?: number): google.cloud.oslogin.v1beta.WebAuthn; + + /** + * Decodes a WebAuthn message from the specified reader or buffer, length delimited. + * @param reader Reader or buffer to decode from + * @returns WebAuthn + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + public static decodeDelimited(reader: ($protobuf.Reader|Uint8Array)): google.cloud.oslogin.v1beta.WebAuthn; + + /** + * Verifies a WebAuthn message. + * @param message Plain object to verify + * @returns `null` if valid, otherwise the reason why it is not + */ + public static verify(message: { [k: string]: any }): (string|null); + + /** + * Creates a WebAuthn message from a plain object. Also converts values to their respective internal types. + * @param object Plain object + * @returns WebAuthn + */ + public static fromObject(object: { [k: string]: any }): google.cloud.oslogin.v1beta.WebAuthn; + + /** + * Creates a plain object from a WebAuthn message. Also converts values to other types if specified. + * @param message WebAuthn + * @param [options] Conversion options + * @returns Plain object + */ + public static toObject(message: google.cloud.oslogin.v1beta.WebAuthn, options?: $protobuf.IConversionOptions): { [k: string]: any }; + + /** + * Converts this WebAuthn to JSON. + * @returns JSON object + */ + public toJSON(): { [k: string]: any }; + + /** + * Gets the default type url for WebAuthn + * @param [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns The default type url + */ + public static getTypeUrl(typeUrlPrefix?: string): string; + } + + /** LoginProfileView enum. */ + enum LoginProfileView { + LOGIN_PROFILE_VIEW_UNSPECIFIED = 0, + BASIC = 1, + SECURITY_KEY = 2 + } } } } diff --git a/packages/google-cloud-oslogin/protos/protos.js b/packages/google-cloud-oslogin/protos/protos.js index fcbdf1da119..7fd62425e5b 100644 --- a/packages/google-cloud-oslogin/protos/protos.js +++ b/packages/google-cloud-oslogin/protos/protos.js @@ -899,6 +899,39 @@ return new this(rpcImpl, requestDelimited, responseDelimited); }; + /** + * Callback as used by {@link google.cloud.oslogin.v1.OsLoginService|createSshPublicKey}. + * @memberof google.cloud.oslogin.v1.OsLoginService + * @typedef CreateSshPublicKeyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.oslogin.common.SshPublicKey} [response] SshPublicKey + */ + + /** + * Calls CreateSshPublicKey. + * @function createSshPublicKey + * @memberof google.cloud.oslogin.v1.OsLoginService + * @instance + * @param {google.cloud.oslogin.v1.ICreateSshPublicKeyRequest} request CreateSshPublicKeyRequest message or plain object + * @param {google.cloud.oslogin.v1.OsLoginService.CreateSshPublicKeyCallback} callback Node-style callback called with the error, if any, and SshPublicKey + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(OsLoginService.prototype.createSshPublicKey = function createSshPublicKey(request, callback) { + return this.rpcCall(createSshPublicKey, $root.google.cloud.oslogin.v1.CreateSshPublicKeyRequest, $root.google.cloud.oslogin.common.SshPublicKey, request, callback); + }, "name", { value: "CreateSshPublicKey" }); + + /** + * Calls CreateSshPublicKey. + * @function createSshPublicKey + * @memberof google.cloud.oslogin.v1.OsLoginService + * @instance + * @param {google.cloud.oslogin.v1.ICreateSshPublicKeyRequest} request CreateSshPublicKeyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.oslogin.v1.OsLoginService|deletePosixAccount}. * @memberof google.cloud.oslogin.v1.OsLoginService @@ -1414,6 +1447,238 @@ return LoginProfile; })(); + v1.CreateSshPublicKeyRequest = (function() { + + /** + * Properties of a CreateSshPublicKeyRequest. + * @memberof google.cloud.oslogin.v1 + * @interface ICreateSshPublicKeyRequest + * @property {string|null} [parent] CreateSshPublicKeyRequest parent + * @property {google.cloud.oslogin.common.ISshPublicKey|null} [sshPublicKey] CreateSshPublicKeyRequest sshPublicKey + */ + + /** + * Constructs a new CreateSshPublicKeyRequest. + * @memberof google.cloud.oslogin.v1 + * @classdesc Represents a CreateSshPublicKeyRequest. + * @implements ICreateSshPublicKeyRequest + * @constructor + * @param {google.cloud.oslogin.v1.ICreateSshPublicKeyRequest=} [properties] Properties to set + */ + function CreateSshPublicKeyRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * CreateSshPublicKeyRequest parent. + * @member {string} parent + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @instance + */ + CreateSshPublicKeyRequest.prototype.parent = ""; + + /** + * CreateSshPublicKeyRequest sshPublicKey. + * @member {google.cloud.oslogin.common.ISshPublicKey|null|undefined} sshPublicKey + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @instance + */ + CreateSshPublicKeyRequest.prototype.sshPublicKey = null; + + /** + * Creates a new CreateSshPublicKeyRequest instance using the specified properties. + * @function create + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @static + * @param {google.cloud.oslogin.v1.ICreateSshPublicKeyRequest=} [properties] Properties to set + * @returns {google.cloud.oslogin.v1.CreateSshPublicKeyRequest} CreateSshPublicKeyRequest instance + */ + CreateSshPublicKeyRequest.create = function create(properties) { + return new CreateSshPublicKeyRequest(properties); + }; + + /** + * Encodes the specified CreateSshPublicKeyRequest message. Does not implicitly {@link google.cloud.oslogin.v1.CreateSshPublicKeyRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @static + * @param {google.cloud.oslogin.v1.ICreateSshPublicKeyRequest} message CreateSshPublicKeyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateSshPublicKeyRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.sshPublicKey != null && Object.hasOwnProperty.call(message, "sshPublicKey")) + $root.google.cloud.oslogin.common.SshPublicKey.encode(message.sshPublicKey, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreateSshPublicKeyRequest message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1.CreateSshPublicKeyRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @static + * @param {google.cloud.oslogin.v1.ICreateSshPublicKeyRequest} message CreateSshPublicKeyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateSshPublicKeyRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateSshPublicKeyRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.oslogin.v1.CreateSshPublicKeyRequest} CreateSshPublicKeyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateSshPublicKeyRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.oslogin.v1.CreateSshPublicKeyRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.sshPublicKey = $root.google.cloud.oslogin.common.SshPublicKey.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateSshPublicKeyRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.oslogin.v1.CreateSshPublicKeyRequest} CreateSshPublicKeyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateSshPublicKeyRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateSshPublicKeyRequest message. + * @function verify + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateSshPublicKeyRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.sshPublicKey != null && message.hasOwnProperty("sshPublicKey")) { + var error = $root.google.cloud.oslogin.common.SshPublicKey.verify(message.sshPublicKey); + if (error) + return "sshPublicKey." + error; + } + return null; + }; + + /** + * Creates a CreateSshPublicKeyRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.oslogin.v1.CreateSshPublicKeyRequest} CreateSshPublicKeyRequest + */ + CreateSshPublicKeyRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.oslogin.v1.CreateSshPublicKeyRequest) + return object; + var message = new $root.google.cloud.oslogin.v1.CreateSshPublicKeyRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.sshPublicKey != null) { + if (typeof object.sshPublicKey !== "object") + throw TypeError(".google.cloud.oslogin.v1.CreateSshPublicKeyRequest.sshPublicKey: object expected"); + message.sshPublicKey = $root.google.cloud.oslogin.common.SshPublicKey.fromObject(object.sshPublicKey); + } + return message; + }; + + /** + * Creates a plain object from a CreateSshPublicKeyRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @static + * @param {google.cloud.oslogin.v1.CreateSshPublicKeyRequest} message CreateSshPublicKeyRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateSshPublicKeyRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.sshPublicKey = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.sshPublicKey != null && message.hasOwnProperty("sshPublicKey")) + object.sshPublicKey = $root.google.cloud.oslogin.common.SshPublicKey.toObject(message.sshPublicKey, options); + return object; + }; + + /** + * Converts this CreateSshPublicKeyRequest to JSON. + * @function toJSON + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @instance + * @returns {Object.} JSON object + */ + CreateSshPublicKeyRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateSshPublicKeyRequest + * @function getTypeUrl + * @memberof google.cloud.oslogin.v1.CreateSshPublicKeyRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateSshPublicKeyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.oslogin.v1.CreateSshPublicKeyRequest"; + }; + + return CreateSshPublicKeyRequest; + })(); + v1.DeletePosixAccountRequest = (function() { /** @@ -2535,6 +2800,7 @@ * @memberof google.cloud.oslogin.v1 * @interface IImportSshPublicKeyResponse * @property {google.cloud.oslogin.v1.ILoginProfile|null} [loginProfile] ImportSshPublicKeyResponse loginProfile + * @property {string|null} [details] ImportSshPublicKeyResponse details */ /** @@ -2560,6 +2826,14 @@ */ ImportSshPublicKeyResponse.prototype.loginProfile = null; + /** + * ImportSshPublicKeyResponse details. + * @member {string} details + * @memberof google.cloud.oslogin.v1.ImportSshPublicKeyResponse + * @instance + */ + ImportSshPublicKeyResponse.prototype.details = ""; + /** * Creates a new ImportSshPublicKeyResponse instance using the specified properties. * @function create @@ -2586,6 +2860,8 @@ writer = $Writer.create(); if (message.loginProfile != null && Object.hasOwnProperty.call(message, "loginProfile")) $root.google.cloud.oslogin.v1.LoginProfile.encode(message.loginProfile, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.details != null && Object.hasOwnProperty.call(message, "details")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.details); return writer; }; @@ -2624,6 +2900,10 @@ message.loginProfile = $root.google.cloud.oslogin.v1.LoginProfile.decode(reader, reader.uint32()); break; } + case 2: { + message.details = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -2664,6 +2944,9 @@ if (error) return "loginProfile." + error; } + if (message.details != null && message.hasOwnProperty("details")) + if (!$util.isString(message.details)) + return "details: string expected"; return null; }; @@ -2684,6 +2967,8 @@ throw TypeError(".google.cloud.oslogin.v1.ImportSshPublicKeyResponse.loginProfile: object expected"); message.loginProfile = $root.google.cloud.oslogin.v1.LoginProfile.fromObject(object.loginProfile); } + if (object.details != null) + message.details = String(object.details); return message; }; @@ -2700,10 +2985,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.loginProfile = null; + object.details = ""; + } if (message.loginProfile != null && message.hasOwnProperty("loginProfile")) object.loginProfile = $root.google.cloud.oslogin.v1.LoginProfile.toObject(message.loginProfile, options); + if (message.details != null && message.hasOwnProperty("details")) + object.details = message.details; return object; }; @@ -3040,6 +3329,39 @@ return new this(rpcImpl, requestDelimited, responseDelimited); }; + /** + * Callback as used by {@link google.cloud.oslogin.v1beta.OsLoginService|createSshPublicKey}. + * @memberof google.cloud.oslogin.v1beta.OsLoginService + * @typedef CreateSshPublicKeyCallback + * @type {function} + * @param {Error|null} error Error, if any + * @param {google.cloud.oslogin.common.SshPublicKey} [response] SshPublicKey + */ + + /** + * Calls CreateSshPublicKey. + * @function createSshPublicKey + * @memberof google.cloud.oslogin.v1beta.OsLoginService + * @instance + * @param {google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest} request CreateSshPublicKeyRequest message or plain object + * @param {google.cloud.oslogin.v1beta.OsLoginService.CreateSshPublicKeyCallback} callback Node-style callback called with the error, if any, and SshPublicKey + * @returns {undefined} + * @variation 1 + */ + Object.defineProperty(OsLoginService.prototype.createSshPublicKey = function createSshPublicKey(request, callback) { + return this.rpcCall(createSshPublicKey, $root.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest, $root.google.cloud.oslogin.common.SshPublicKey, request, callback); + }, "name", { value: "CreateSshPublicKey" }); + + /** + * Calls CreateSshPublicKey. + * @function createSshPublicKey + * @memberof google.cloud.oslogin.v1beta.OsLoginService + * @instance + * @param {google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest} request CreateSshPublicKeyRequest message or plain object + * @returns {Promise} Promise + * @variation 2 + */ + /** * Callback as used by {@link google.cloud.oslogin.v1beta.OsLoginService|deletePosixAccount}. * @memberof google.cloud.oslogin.v1beta.OsLoginService @@ -3250,6 +3572,7 @@ * @property {string|null} [name] LoginProfile name * @property {Array.|null} [posixAccounts] LoginProfile posixAccounts * @property {Object.|null} [sshPublicKeys] LoginProfile sshPublicKeys + * @property {Array.|null} [securityKeys] LoginProfile securityKeys */ /** @@ -3263,6 +3586,7 @@ function LoginProfile(properties) { this.posixAccounts = []; this.sshPublicKeys = {}; + this.securityKeys = []; if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -3293,6 +3617,14 @@ */ LoginProfile.prototype.sshPublicKeys = $util.emptyObject; + /** + * LoginProfile securityKeys. + * @member {Array.} securityKeys + * @memberof google.cloud.oslogin.v1beta.LoginProfile + * @instance + */ + LoginProfile.prototype.securityKeys = $util.emptyArray; + /** * Creates a new LoginProfile instance using the specified properties. * @function create @@ -3327,6 +3659,9 @@ writer.uint32(/* id 3, wireType 2 =*/26).fork().uint32(/* id 1, wireType 2 =*/10).string(keys[i]); $root.google.cloud.oslogin.common.SshPublicKey.encode(message.sshPublicKeys[keys[i]], writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim().ldelim(); } + if (message.securityKeys != null && message.securityKeys.length) + for (var i = 0; i < message.securityKeys.length; ++i) + $root.google.cloud.oslogin.v1beta.SecurityKey.encode(message.securityKeys[i], writer.uint32(/* id 5, wireType 2 =*/42).fork()).ldelim(); return writer; }; @@ -3394,6 +3729,12 @@ message.sshPublicKeys[key] = value; break; } + case 5: { + if (!(message.securityKeys && message.securityKeys.length)) + message.securityKeys = []; + message.securityKeys.push($root.google.cloud.oslogin.v1beta.SecurityKey.decode(reader, reader.uint32())); + break; + } default: reader.skipType(tag & 7); break; @@ -3451,6 +3792,15 @@ return "sshPublicKeys." + error; } } + if (message.securityKeys != null && message.hasOwnProperty("securityKeys")) { + if (!Array.isArray(message.securityKeys)) + return "securityKeys: array expected"; + for (var i = 0; i < message.securityKeys.length; ++i) { + var error = $root.google.cloud.oslogin.v1beta.SecurityKey.verify(message.securityKeys[i]); + if (error) + return "securityKeys." + error; + } + } return null; }; @@ -3488,6 +3838,16 @@ message.sshPublicKeys[keys[i]] = $root.google.cloud.oslogin.common.SshPublicKey.fromObject(object.sshPublicKeys[keys[i]]); } } + if (object.securityKeys) { + if (!Array.isArray(object.securityKeys)) + throw TypeError(".google.cloud.oslogin.v1beta.LoginProfile.securityKeys: array expected"); + message.securityKeys = []; + for (var i = 0; i < object.securityKeys.length; ++i) { + if (typeof object.securityKeys[i] !== "object") + throw TypeError(".google.cloud.oslogin.v1beta.LoginProfile.securityKeys: object expected"); + message.securityKeys[i] = $root.google.cloud.oslogin.v1beta.SecurityKey.fromObject(object.securityKeys[i]); + } + } return message; }; @@ -3504,8 +3864,10 @@ if (!options) options = {}; var object = {}; - if (options.arrays || options.defaults) + if (options.arrays || options.defaults) { object.posixAccounts = []; + object.securityKeys = []; + } if (options.objects || options.defaults) object.sshPublicKeys = {}; if (options.defaults) @@ -3523,6 +3885,11 @@ for (var j = 0; j < keys2.length; ++j) object.sshPublicKeys[keys2[j]] = $root.google.cloud.oslogin.common.SshPublicKey.toObject(message.sshPublicKeys[keys2[j]], options); } + if (message.securityKeys && message.securityKeys.length) { + object.securityKeys = []; + for (var j = 0; j < message.securityKeys.length; ++j) + object.securityKeys[j] = $root.google.cloud.oslogin.v1beta.SecurityKey.toObject(message.securityKeys[j], options); + } return object; }; @@ -3555,24 +3922,25 @@ return LoginProfile; })(); - v1beta.DeletePosixAccountRequest = (function() { + v1beta.CreateSshPublicKeyRequest = (function() { /** - * Properties of a DeletePosixAccountRequest. + * Properties of a CreateSshPublicKeyRequest. * @memberof google.cloud.oslogin.v1beta - * @interface IDeletePosixAccountRequest - * @property {string|null} [name] DeletePosixAccountRequest name + * @interface ICreateSshPublicKeyRequest + * @property {string|null} [parent] CreateSshPublicKeyRequest parent + * @property {google.cloud.oslogin.common.ISshPublicKey|null} [sshPublicKey] CreateSshPublicKeyRequest sshPublicKey */ /** - * Constructs a new DeletePosixAccountRequest. + * Constructs a new CreateSshPublicKeyRequest. * @memberof google.cloud.oslogin.v1beta - * @classdesc Represents a DeletePosixAccountRequest. - * @implements IDeletePosixAccountRequest + * @classdesc Represents a CreateSshPublicKeyRequest. + * @implements ICreateSshPublicKeyRequest * @constructor - * @param {google.cloud.oslogin.v1beta.IDeletePosixAccountRequest=} [properties] Properties to set + * @param {google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest=} [properties] Properties to set */ - function DeletePosixAccountRequest(properties) { + function CreateSshPublicKeyRequest(properties) { if (properties) for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) if (properties[keys[i]] != null) @@ -3580,16 +3948,247 @@ } /** - * DeletePosixAccountRequest name. - * @member {string} name - * @memberof google.cloud.oslogin.v1beta.DeletePosixAccountRequest + * CreateSshPublicKeyRequest parent. + * @member {string} parent + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest * @instance */ - DeletePosixAccountRequest.prototype.name = ""; + CreateSshPublicKeyRequest.prototype.parent = ""; /** - * Creates a new DeletePosixAccountRequest instance using the specified properties. - * @function create + * CreateSshPublicKeyRequest sshPublicKey. + * @member {google.cloud.oslogin.common.ISshPublicKey|null|undefined} sshPublicKey + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @instance + */ + CreateSshPublicKeyRequest.prototype.sshPublicKey = null; + + /** + * Creates a new CreateSshPublicKeyRequest instance using the specified properties. + * @function create + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @static + * @param {google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest=} [properties] Properties to set + * @returns {google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest} CreateSshPublicKeyRequest instance + */ + CreateSshPublicKeyRequest.create = function create(properties) { + return new CreateSshPublicKeyRequest(properties); + }; + + /** + * Encodes the specified CreateSshPublicKeyRequest message. Does not implicitly {@link google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest.verify|verify} messages. + * @function encode + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @static + * @param {google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest} message CreateSshPublicKeyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateSshPublicKeyRequest.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.parent != null && Object.hasOwnProperty.call(message, "parent")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.parent); + if (message.sshPublicKey != null && Object.hasOwnProperty.call(message, "sshPublicKey")) + $root.google.cloud.oslogin.common.SshPublicKey.encode(message.sshPublicKey, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified CreateSshPublicKeyRequest message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @static + * @param {google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest} message CreateSshPublicKeyRequest message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + CreateSshPublicKeyRequest.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a CreateSshPublicKeyRequest message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest} CreateSshPublicKeyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateSshPublicKeyRequest.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.parent = reader.string(); + break; + } + case 2: { + message.sshPublicKey = $root.google.cloud.oslogin.common.SshPublicKey.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a CreateSshPublicKeyRequest message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest} CreateSshPublicKeyRequest + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + CreateSshPublicKeyRequest.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a CreateSshPublicKeyRequest message. + * @function verify + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + CreateSshPublicKeyRequest.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.parent != null && message.hasOwnProperty("parent")) + if (!$util.isString(message.parent)) + return "parent: string expected"; + if (message.sshPublicKey != null && message.hasOwnProperty("sshPublicKey")) { + var error = $root.google.cloud.oslogin.common.SshPublicKey.verify(message.sshPublicKey); + if (error) + return "sshPublicKey." + error; + } + return null; + }; + + /** + * Creates a CreateSshPublicKeyRequest message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest} CreateSshPublicKeyRequest + */ + CreateSshPublicKeyRequest.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest) + return object; + var message = new $root.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest(); + if (object.parent != null) + message.parent = String(object.parent); + if (object.sshPublicKey != null) { + if (typeof object.sshPublicKey !== "object") + throw TypeError(".google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest.sshPublicKey: object expected"); + message.sshPublicKey = $root.google.cloud.oslogin.common.SshPublicKey.fromObject(object.sshPublicKey); + } + return message; + }; + + /** + * Creates a plain object from a CreateSshPublicKeyRequest message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @static + * @param {google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest} message CreateSshPublicKeyRequest + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + CreateSshPublicKeyRequest.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.parent = ""; + object.sshPublicKey = null; + } + if (message.parent != null && message.hasOwnProperty("parent")) + object.parent = message.parent; + if (message.sshPublicKey != null && message.hasOwnProperty("sshPublicKey")) + object.sshPublicKey = $root.google.cloud.oslogin.common.SshPublicKey.toObject(message.sshPublicKey, options); + return object; + }; + + /** + * Converts this CreateSshPublicKeyRequest to JSON. + * @function toJSON + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @instance + * @returns {Object.} JSON object + */ + CreateSshPublicKeyRequest.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for CreateSshPublicKeyRequest + * @function getTypeUrl + * @memberof google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + CreateSshPublicKeyRequest.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest"; + }; + + return CreateSshPublicKeyRequest; + })(); + + v1beta.DeletePosixAccountRequest = (function() { + + /** + * Properties of a DeletePosixAccountRequest. + * @memberof google.cloud.oslogin.v1beta + * @interface IDeletePosixAccountRequest + * @property {string|null} [name] DeletePosixAccountRequest name + */ + + /** + * Constructs a new DeletePosixAccountRequest. + * @memberof google.cloud.oslogin.v1beta + * @classdesc Represents a DeletePosixAccountRequest. + * @implements IDeletePosixAccountRequest + * @constructor + * @param {google.cloud.oslogin.v1beta.IDeletePosixAccountRequest=} [properties] Properties to set + */ + function DeletePosixAccountRequest(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * DeletePosixAccountRequest name. + * @member {string} name + * @memberof google.cloud.oslogin.v1beta.DeletePosixAccountRequest + * @instance + */ + DeletePosixAccountRequest.prototype.name = ""; + + /** + * Creates a new DeletePosixAccountRequest instance using the specified properties. + * @function create * @memberof google.cloud.oslogin.v1beta.DeletePosixAccountRequest * @static * @param {google.cloud.oslogin.v1beta.IDeletePosixAccountRequest=} [properties] Properties to set @@ -3970,6 +4569,7 @@ * @property {string|null} [name] GetLoginProfileRequest name * @property {string|null} [projectId] GetLoginProfileRequest projectId * @property {string|null} [systemId] GetLoginProfileRequest systemId + * @property {google.cloud.oslogin.v1beta.LoginProfileView|null} [view] GetLoginProfileRequest view */ /** @@ -4011,6 +4611,14 @@ */ GetLoginProfileRequest.prototype.systemId = ""; + /** + * GetLoginProfileRequest view. + * @member {google.cloud.oslogin.v1beta.LoginProfileView} view + * @memberof google.cloud.oslogin.v1beta.GetLoginProfileRequest + * @instance + */ + GetLoginProfileRequest.prototype.view = 0; + /** * Creates a new GetLoginProfileRequest instance using the specified properties. * @function create @@ -4041,6 +4649,8 @@ writer.uint32(/* id 2, wireType 2 =*/18).string(message.projectId); if (message.systemId != null && Object.hasOwnProperty.call(message, "systemId")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.systemId); + if (message.view != null && Object.hasOwnProperty.call(message, "view")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.view); return writer; }; @@ -4087,6 +4697,10 @@ message.systemId = reader.string(); break; } + case 4: { + message.view = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -4131,6 +4745,15 @@ if (message.systemId != null && message.hasOwnProperty("systemId")) if (!$util.isString(message.systemId)) return "systemId: string expected"; + if (message.view != null && message.hasOwnProperty("view")) + switch (message.view) { + default: + return "view: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -4152,6 +4775,26 @@ message.projectId = String(object.projectId); if (object.systemId != null) message.systemId = String(object.systemId); + switch (object.view) { + default: + if (typeof object.view === "number") { + message.view = object.view; + break; + } + break; + case "LOGIN_PROFILE_VIEW_UNSPECIFIED": + case 0: + message.view = 0; + break; + case "BASIC": + case 1: + message.view = 1; + break; + case "SECURITY_KEY": + case 2: + message.view = 2; + break; + } return message; }; @@ -4172,6 +4815,7 @@ object.name = ""; object.projectId = ""; object.systemId = ""; + object.view = options.enums === String ? "LOGIN_PROFILE_VIEW_UNSPECIFIED" : 0; } if (message.name != null && message.hasOwnProperty("name")) object.name = message.name; @@ -4179,6 +4823,8 @@ object.projectId = message.projectId; if (message.systemId != null && message.hasOwnProperty("systemId")) object.systemId = message.systemId; + if (message.view != null && message.hasOwnProperty("view")) + object.view = options.enums === String ? $root.google.cloud.oslogin.v1beta.LoginProfileView[message.view] === undefined ? message.view : $root.google.cloud.oslogin.v1beta.LoginProfileView[message.view] : message.view; return object; }; @@ -4423,6 +5069,7 @@ * @property {string|null} [parent] ImportSshPublicKeyRequest parent * @property {google.cloud.oslogin.common.ISshPublicKey|null} [sshPublicKey] ImportSshPublicKeyRequest sshPublicKey * @property {string|null} [projectId] ImportSshPublicKeyRequest projectId + * @property {google.cloud.oslogin.v1beta.LoginProfileView|null} [view] ImportSshPublicKeyRequest view */ /** @@ -4464,6 +5111,14 @@ */ ImportSshPublicKeyRequest.prototype.projectId = ""; + /** + * ImportSshPublicKeyRequest view. + * @member {google.cloud.oslogin.v1beta.LoginProfileView} view + * @memberof google.cloud.oslogin.v1beta.ImportSshPublicKeyRequest + * @instance + */ + ImportSshPublicKeyRequest.prototype.view = 0; + /** * Creates a new ImportSshPublicKeyRequest instance using the specified properties. * @function create @@ -4494,6 +5149,8 @@ $root.google.cloud.oslogin.common.SshPublicKey.encode(message.sshPublicKey, writer.uint32(/* id 2, wireType 2 =*/18).fork()).ldelim(); if (message.projectId != null && Object.hasOwnProperty.call(message, "projectId")) writer.uint32(/* id 3, wireType 2 =*/26).string(message.projectId); + if (message.view != null && Object.hasOwnProperty.call(message, "view")) + writer.uint32(/* id 4, wireType 0 =*/32).int32(message.view); return writer; }; @@ -4540,6 +5197,10 @@ message.projectId = reader.string(); break; } + case 4: { + message.view = reader.int32(); + break; + } default: reader.skipType(tag & 7); break; @@ -4586,6 +5247,15 @@ if (message.projectId != null && message.hasOwnProperty("projectId")) if (!$util.isString(message.projectId)) return "projectId: string expected"; + if (message.view != null && message.hasOwnProperty("view")) + switch (message.view) { + default: + return "view: enum value expected"; + case 0: + case 1: + case 2: + break; + } return null; }; @@ -4610,6 +5280,26 @@ } if (object.projectId != null) message.projectId = String(object.projectId); + switch (object.view) { + default: + if (typeof object.view === "number") { + message.view = object.view; + break; + } + break; + case "LOGIN_PROFILE_VIEW_UNSPECIFIED": + case 0: + message.view = 0; + break; + case "BASIC": + case 1: + message.view = 1; + break; + case "SECURITY_KEY": + case 2: + message.view = 2; + break; + } return message; }; @@ -4630,6 +5320,7 @@ object.parent = ""; object.sshPublicKey = null; object.projectId = ""; + object.view = options.enums === String ? "LOGIN_PROFILE_VIEW_UNSPECIFIED" : 0; } if (message.parent != null && message.hasOwnProperty("parent")) object.parent = message.parent; @@ -4637,6 +5328,8 @@ object.sshPublicKey = $root.google.cloud.oslogin.common.SshPublicKey.toObject(message.sshPublicKey, options); if (message.projectId != null && message.hasOwnProperty("projectId")) object.projectId = message.projectId; + if (message.view != null && message.hasOwnProperty("view")) + object.view = options.enums === String ? $root.google.cloud.oslogin.v1beta.LoginProfileView[message.view] === undefined ? message.view : $root.google.cloud.oslogin.v1beta.LoginProfileView[message.view] : message.view; return object; }; @@ -4676,6 +5369,7 @@ * @memberof google.cloud.oslogin.v1beta * @interface IImportSshPublicKeyResponse * @property {google.cloud.oslogin.v1beta.ILoginProfile|null} [loginProfile] ImportSshPublicKeyResponse loginProfile + * @property {string|null} [details] ImportSshPublicKeyResponse details */ /** @@ -4701,6 +5395,14 @@ */ ImportSshPublicKeyResponse.prototype.loginProfile = null; + /** + * ImportSshPublicKeyResponse details. + * @member {string} details + * @memberof google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse + * @instance + */ + ImportSshPublicKeyResponse.prototype.details = ""; + /** * Creates a new ImportSshPublicKeyResponse instance using the specified properties. * @function create @@ -4727,6 +5429,8 @@ writer = $Writer.create(); if (message.loginProfile != null && Object.hasOwnProperty.call(message, "loginProfile")) $root.google.cloud.oslogin.v1beta.LoginProfile.encode(message.loginProfile, writer.uint32(/* id 1, wireType 2 =*/10).fork()).ldelim(); + if (message.details != null && Object.hasOwnProperty.call(message, "details")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.details); return writer; }; @@ -4765,6 +5469,10 @@ message.loginProfile = $root.google.cloud.oslogin.v1beta.LoginProfile.decode(reader, reader.uint32()); break; } + case 2: { + message.details = reader.string(); + break; + } default: reader.skipType(tag & 7); break; @@ -4805,6 +5513,9 @@ if (error) return "loginProfile." + error; } + if (message.details != null && message.hasOwnProperty("details")) + if (!$util.isString(message.details)) + return "details: string expected"; return null; }; @@ -4825,6 +5536,8 @@ throw TypeError(".google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse.loginProfile: object expected"); message.loginProfile = $root.google.cloud.oslogin.v1beta.LoginProfile.fromObject(object.loginProfile); } + if (object.details != null) + message.details = String(object.details); return message; }; @@ -4841,10 +5554,14 @@ if (!options) options = {}; var object = {}; - if (options.defaults) + if (options.defaults) { object.loginProfile = null; + object.details = ""; + } if (message.loginProfile != null && message.hasOwnProperty("loginProfile")) object.loginProfile = $root.google.cloud.oslogin.v1beta.LoginProfile.toObject(message.loginProfile, options); + if (message.details != null && message.hasOwnProperty("details")) + object.details = message.details; return object; }; @@ -5137,6 +5854,738 @@ return UpdateSshPublicKeyRequest; })(); + v1beta.SecurityKey = (function() { + + /** + * Properties of a SecurityKey. + * @memberof google.cloud.oslogin.v1beta + * @interface ISecurityKey + * @property {string|null} [publicKey] SecurityKey publicKey + * @property {string|null} [privateKey] SecurityKey privateKey + * @property {google.cloud.oslogin.v1beta.IUniversalTwoFactor|null} [universalTwoFactor] SecurityKey universalTwoFactor + * @property {google.cloud.oslogin.v1beta.IWebAuthn|null} [webAuthn] SecurityKey webAuthn + */ + + /** + * Constructs a new SecurityKey. + * @memberof google.cloud.oslogin.v1beta + * @classdesc Represents a SecurityKey. + * @implements ISecurityKey + * @constructor + * @param {google.cloud.oslogin.v1beta.ISecurityKey=} [properties] Properties to set + */ + function SecurityKey(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * SecurityKey publicKey. + * @member {string} publicKey + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @instance + */ + SecurityKey.prototype.publicKey = ""; + + /** + * SecurityKey privateKey. + * @member {string} privateKey + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @instance + */ + SecurityKey.prototype.privateKey = ""; + + /** + * SecurityKey universalTwoFactor. + * @member {google.cloud.oslogin.v1beta.IUniversalTwoFactor|null|undefined} universalTwoFactor + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @instance + */ + SecurityKey.prototype.universalTwoFactor = null; + + /** + * SecurityKey webAuthn. + * @member {google.cloud.oslogin.v1beta.IWebAuthn|null|undefined} webAuthn + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @instance + */ + SecurityKey.prototype.webAuthn = null; + + // OneOf field names bound to virtual getters and setters + var $oneOfFields; + + /** + * SecurityKey protocolType. + * @member {"universalTwoFactor"|"webAuthn"|undefined} protocolType + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @instance + */ + Object.defineProperty(SecurityKey.prototype, "protocolType", { + get: $util.oneOfGetter($oneOfFields = ["universalTwoFactor", "webAuthn"]), + set: $util.oneOfSetter($oneOfFields) + }); + + /** + * Creates a new SecurityKey instance using the specified properties. + * @function create + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @static + * @param {google.cloud.oslogin.v1beta.ISecurityKey=} [properties] Properties to set + * @returns {google.cloud.oslogin.v1beta.SecurityKey} SecurityKey instance + */ + SecurityKey.create = function create(properties) { + return new SecurityKey(properties); + }; + + /** + * Encodes the specified SecurityKey message. Does not implicitly {@link google.cloud.oslogin.v1beta.SecurityKey.verify|verify} messages. + * @function encode + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @static + * @param {google.cloud.oslogin.v1beta.ISecurityKey} message SecurityKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SecurityKey.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.publicKey != null && Object.hasOwnProperty.call(message, "publicKey")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.publicKey); + if (message.privateKey != null && Object.hasOwnProperty.call(message, "privateKey")) + writer.uint32(/* id 2, wireType 2 =*/18).string(message.privateKey); + if (message.universalTwoFactor != null && Object.hasOwnProperty.call(message, "universalTwoFactor")) + $root.google.cloud.oslogin.v1beta.UniversalTwoFactor.encode(message.universalTwoFactor, writer.uint32(/* id 3, wireType 2 =*/26).fork()).ldelim(); + if (message.webAuthn != null && Object.hasOwnProperty.call(message, "webAuthn")) + $root.google.cloud.oslogin.v1beta.WebAuthn.encode(message.webAuthn, writer.uint32(/* id 4, wireType 2 =*/34).fork()).ldelim(); + return writer; + }; + + /** + * Encodes the specified SecurityKey message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1beta.SecurityKey.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @static + * @param {google.cloud.oslogin.v1beta.ISecurityKey} message SecurityKey message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + SecurityKey.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a SecurityKey message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.oslogin.v1beta.SecurityKey} SecurityKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SecurityKey.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.oslogin.v1beta.SecurityKey(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.publicKey = reader.string(); + break; + } + case 2: { + message.privateKey = reader.string(); + break; + } + case 3: { + message.universalTwoFactor = $root.google.cloud.oslogin.v1beta.UniversalTwoFactor.decode(reader, reader.uint32()); + break; + } + case 4: { + message.webAuthn = $root.google.cloud.oslogin.v1beta.WebAuthn.decode(reader, reader.uint32()); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a SecurityKey message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.oslogin.v1beta.SecurityKey} SecurityKey + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + SecurityKey.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a SecurityKey message. + * @function verify + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + SecurityKey.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + var properties = {}; + if (message.publicKey != null && message.hasOwnProperty("publicKey")) + if (!$util.isString(message.publicKey)) + return "publicKey: string expected"; + if (message.privateKey != null && message.hasOwnProperty("privateKey")) + if (!$util.isString(message.privateKey)) + return "privateKey: string expected"; + if (message.universalTwoFactor != null && message.hasOwnProperty("universalTwoFactor")) { + properties.protocolType = 1; + { + var error = $root.google.cloud.oslogin.v1beta.UniversalTwoFactor.verify(message.universalTwoFactor); + if (error) + return "universalTwoFactor." + error; + } + } + if (message.webAuthn != null && message.hasOwnProperty("webAuthn")) { + if (properties.protocolType === 1) + return "protocolType: multiple values"; + properties.protocolType = 1; + { + var error = $root.google.cloud.oslogin.v1beta.WebAuthn.verify(message.webAuthn); + if (error) + return "webAuthn." + error; + } + } + return null; + }; + + /** + * Creates a SecurityKey message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.oslogin.v1beta.SecurityKey} SecurityKey + */ + SecurityKey.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.oslogin.v1beta.SecurityKey) + return object; + var message = new $root.google.cloud.oslogin.v1beta.SecurityKey(); + if (object.publicKey != null) + message.publicKey = String(object.publicKey); + if (object.privateKey != null) + message.privateKey = String(object.privateKey); + if (object.universalTwoFactor != null) { + if (typeof object.universalTwoFactor !== "object") + throw TypeError(".google.cloud.oslogin.v1beta.SecurityKey.universalTwoFactor: object expected"); + message.universalTwoFactor = $root.google.cloud.oslogin.v1beta.UniversalTwoFactor.fromObject(object.universalTwoFactor); + } + if (object.webAuthn != null) { + if (typeof object.webAuthn !== "object") + throw TypeError(".google.cloud.oslogin.v1beta.SecurityKey.webAuthn: object expected"); + message.webAuthn = $root.google.cloud.oslogin.v1beta.WebAuthn.fromObject(object.webAuthn); + } + return message; + }; + + /** + * Creates a plain object from a SecurityKey message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @static + * @param {google.cloud.oslogin.v1beta.SecurityKey} message SecurityKey + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + SecurityKey.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) { + object.publicKey = ""; + object.privateKey = ""; + } + if (message.publicKey != null && message.hasOwnProperty("publicKey")) + object.publicKey = message.publicKey; + if (message.privateKey != null && message.hasOwnProperty("privateKey")) + object.privateKey = message.privateKey; + if (message.universalTwoFactor != null && message.hasOwnProperty("universalTwoFactor")) { + object.universalTwoFactor = $root.google.cloud.oslogin.v1beta.UniversalTwoFactor.toObject(message.universalTwoFactor, options); + if (options.oneofs) + object.protocolType = "universalTwoFactor"; + } + if (message.webAuthn != null && message.hasOwnProperty("webAuthn")) { + object.webAuthn = $root.google.cloud.oslogin.v1beta.WebAuthn.toObject(message.webAuthn, options); + if (options.oneofs) + object.protocolType = "webAuthn"; + } + return object; + }; + + /** + * Converts this SecurityKey to JSON. + * @function toJSON + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @instance + * @returns {Object.} JSON object + */ + SecurityKey.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for SecurityKey + * @function getTypeUrl + * @memberof google.cloud.oslogin.v1beta.SecurityKey + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + SecurityKey.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.oslogin.v1beta.SecurityKey"; + }; + + return SecurityKey; + })(); + + v1beta.UniversalTwoFactor = (function() { + + /** + * Properties of an UniversalTwoFactor. + * @memberof google.cloud.oslogin.v1beta + * @interface IUniversalTwoFactor + * @property {string|null} [appId] UniversalTwoFactor appId + */ + + /** + * Constructs a new UniversalTwoFactor. + * @memberof google.cloud.oslogin.v1beta + * @classdesc Represents an UniversalTwoFactor. + * @implements IUniversalTwoFactor + * @constructor + * @param {google.cloud.oslogin.v1beta.IUniversalTwoFactor=} [properties] Properties to set + */ + function UniversalTwoFactor(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * UniversalTwoFactor appId. + * @member {string} appId + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @instance + */ + UniversalTwoFactor.prototype.appId = ""; + + /** + * Creates a new UniversalTwoFactor instance using the specified properties. + * @function create + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @static + * @param {google.cloud.oslogin.v1beta.IUniversalTwoFactor=} [properties] Properties to set + * @returns {google.cloud.oslogin.v1beta.UniversalTwoFactor} UniversalTwoFactor instance + */ + UniversalTwoFactor.create = function create(properties) { + return new UniversalTwoFactor(properties); + }; + + /** + * Encodes the specified UniversalTwoFactor message. Does not implicitly {@link google.cloud.oslogin.v1beta.UniversalTwoFactor.verify|verify} messages. + * @function encode + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @static + * @param {google.cloud.oslogin.v1beta.IUniversalTwoFactor} message UniversalTwoFactor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UniversalTwoFactor.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.appId != null && Object.hasOwnProperty.call(message, "appId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.appId); + return writer; + }; + + /** + * Encodes the specified UniversalTwoFactor message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1beta.UniversalTwoFactor.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @static + * @param {google.cloud.oslogin.v1beta.IUniversalTwoFactor} message UniversalTwoFactor message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + UniversalTwoFactor.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes an UniversalTwoFactor message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.oslogin.v1beta.UniversalTwoFactor} UniversalTwoFactor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UniversalTwoFactor.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.oslogin.v1beta.UniversalTwoFactor(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.appId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes an UniversalTwoFactor message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.oslogin.v1beta.UniversalTwoFactor} UniversalTwoFactor + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + UniversalTwoFactor.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies an UniversalTwoFactor message. + * @function verify + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + UniversalTwoFactor.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.appId != null && message.hasOwnProperty("appId")) + if (!$util.isString(message.appId)) + return "appId: string expected"; + return null; + }; + + /** + * Creates an UniversalTwoFactor message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.oslogin.v1beta.UniversalTwoFactor} UniversalTwoFactor + */ + UniversalTwoFactor.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.oslogin.v1beta.UniversalTwoFactor) + return object; + var message = new $root.google.cloud.oslogin.v1beta.UniversalTwoFactor(); + if (object.appId != null) + message.appId = String(object.appId); + return message; + }; + + /** + * Creates a plain object from an UniversalTwoFactor message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @static + * @param {google.cloud.oslogin.v1beta.UniversalTwoFactor} message UniversalTwoFactor + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + UniversalTwoFactor.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.appId = ""; + if (message.appId != null && message.hasOwnProperty("appId")) + object.appId = message.appId; + return object; + }; + + /** + * Converts this UniversalTwoFactor to JSON. + * @function toJSON + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @instance + * @returns {Object.} JSON object + */ + UniversalTwoFactor.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for UniversalTwoFactor + * @function getTypeUrl + * @memberof google.cloud.oslogin.v1beta.UniversalTwoFactor + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + UniversalTwoFactor.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.oslogin.v1beta.UniversalTwoFactor"; + }; + + return UniversalTwoFactor; + })(); + + v1beta.WebAuthn = (function() { + + /** + * Properties of a WebAuthn. + * @memberof google.cloud.oslogin.v1beta + * @interface IWebAuthn + * @property {string|null} [rpId] WebAuthn rpId + */ + + /** + * Constructs a new WebAuthn. + * @memberof google.cloud.oslogin.v1beta + * @classdesc Represents a WebAuthn. + * @implements IWebAuthn + * @constructor + * @param {google.cloud.oslogin.v1beta.IWebAuthn=} [properties] Properties to set + */ + function WebAuthn(properties) { + if (properties) + for (var keys = Object.keys(properties), i = 0; i < keys.length; ++i) + if (properties[keys[i]] != null) + this[keys[i]] = properties[keys[i]]; + } + + /** + * WebAuthn rpId. + * @member {string} rpId + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @instance + */ + WebAuthn.prototype.rpId = ""; + + /** + * Creates a new WebAuthn instance using the specified properties. + * @function create + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @static + * @param {google.cloud.oslogin.v1beta.IWebAuthn=} [properties] Properties to set + * @returns {google.cloud.oslogin.v1beta.WebAuthn} WebAuthn instance + */ + WebAuthn.create = function create(properties) { + return new WebAuthn(properties); + }; + + /** + * Encodes the specified WebAuthn message. Does not implicitly {@link google.cloud.oslogin.v1beta.WebAuthn.verify|verify} messages. + * @function encode + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @static + * @param {google.cloud.oslogin.v1beta.IWebAuthn} message WebAuthn message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WebAuthn.encode = function encode(message, writer) { + if (!writer) + writer = $Writer.create(); + if (message.rpId != null && Object.hasOwnProperty.call(message, "rpId")) + writer.uint32(/* id 1, wireType 2 =*/10).string(message.rpId); + return writer; + }; + + /** + * Encodes the specified WebAuthn message, length delimited. Does not implicitly {@link google.cloud.oslogin.v1beta.WebAuthn.verify|verify} messages. + * @function encodeDelimited + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @static + * @param {google.cloud.oslogin.v1beta.IWebAuthn} message WebAuthn message or plain object to encode + * @param {$protobuf.Writer} [writer] Writer to encode to + * @returns {$protobuf.Writer} Writer + */ + WebAuthn.encodeDelimited = function encodeDelimited(message, writer) { + return this.encode(message, writer).ldelim(); + }; + + /** + * Decodes a WebAuthn message from the specified reader or buffer. + * @function decode + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @param {number} [length] Message length if known beforehand + * @returns {google.cloud.oslogin.v1beta.WebAuthn} WebAuthn + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WebAuthn.decode = function decode(reader, length) { + if (!(reader instanceof $Reader)) + reader = $Reader.create(reader); + var end = length === undefined ? reader.len : reader.pos + length, message = new $root.google.cloud.oslogin.v1beta.WebAuthn(); + while (reader.pos < end) { + var tag = reader.uint32(); + switch (tag >>> 3) { + case 1: { + message.rpId = reader.string(); + break; + } + default: + reader.skipType(tag & 7); + break; + } + } + return message; + }; + + /** + * Decodes a WebAuthn message from the specified reader or buffer, length delimited. + * @function decodeDelimited + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @static + * @param {$protobuf.Reader|Uint8Array} reader Reader or buffer to decode from + * @returns {google.cloud.oslogin.v1beta.WebAuthn} WebAuthn + * @throws {Error} If the payload is not a reader or valid buffer + * @throws {$protobuf.util.ProtocolError} If required fields are missing + */ + WebAuthn.decodeDelimited = function decodeDelimited(reader) { + if (!(reader instanceof $Reader)) + reader = new $Reader(reader); + return this.decode(reader, reader.uint32()); + }; + + /** + * Verifies a WebAuthn message. + * @function verify + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @static + * @param {Object.} message Plain object to verify + * @returns {string|null} `null` if valid, otherwise the reason why it is not + */ + WebAuthn.verify = function verify(message) { + if (typeof message !== "object" || message === null) + return "object expected"; + if (message.rpId != null && message.hasOwnProperty("rpId")) + if (!$util.isString(message.rpId)) + return "rpId: string expected"; + return null; + }; + + /** + * Creates a WebAuthn message from a plain object. Also converts values to their respective internal types. + * @function fromObject + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @static + * @param {Object.} object Plain object + * @returns {google.cloud.oslogin.v1beta.WebAuthn} WebAuthn + */ + WebAuthn.fromObject = function fromObject(object) { + if (object instanceof $root.google.cloud.oslogin.v1beta.WebAuthn) + return object; + var message = new $root.google.cloud.oslogin.v1beta.WebAuthn(); + if (object.rpId != null) + message.rpId = String(object.rpId); + return message; + }; + + /** + * Creates a plain object from a WebAuthn message. Also converts values to other types if specified. + * @function toObject + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @static + * @param {google.cloud.oslogin.v1beta.WebAuthn} message WebAuthn + * @param {$protobuf.IConversionOptions} [options] Conversion options + * @returns {Object.} Plain object + */ + WebAuthn.toObject = function toObject(message, options) { + if (!options) + options = {}; + var object = {}; + if (options.defaults) + object.rpId = ""; + if (message.rpId != null && message.hasOwnProperty("rpId")) + object.rpId = message.rpId; + return object; + }; + + /** + * Converts this WebAuthn to JSON. + * @function toJSON + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @instance + * @returns {Object.} JSON object + */ + WebAuthn.prototype.toJSON = function toJSON() { + return this.constructor.toObject(this, $protobuf.util.toJSONOptions); + }; + + /** + * Gets the default type url for WebAuthn + * @function getTypeUrl + * @memberof google.cloud.oslogin.v1beta.WebAuthn + * @static + * @param {string} [typeUrlPrefix] your custom typeUrlPrefix(default "type.googleapis.com") + * @returns {string} The default type url + */ + WebAuthn.getTypeUrl = function getTypeUrl(typeUrlPrefix) { + if (typeUrlPrefix === undefined) { + typeUrlPrefix = "type.googleapis.com"; + } + return typeUrlPrefix + "/google.cloud.oslogin.v1beta.WebAuthn"; + }; + + return WebAuthn; + })(); + + /** + * LoginProfileView enum. + * @name google.cloud.oslogin.v1beta.LoginProfileView + * @enum {number} + * @property {number} LOGIN_PROFILE_VIEW_UNSPECIFIED=0 LOGIN_PROFILE_VIEW_UNSPECIFIED value + * @property {number} BASIC=1 BASIC value + * @property {number} SECURITY_KEY=2 SECURITY_KEY value + */ + v1beta.LoginProfileView = (function() { + var valuesById = {}, values = Object.create(valuesById); + values[valuesById[0] = "LOGIN_PROFILE_VIEW_UNSPECIFIED"] = 0; + values[valuesById[1] = "BASIC"] = 1; + values[valuesById[2] = "SECURITY_KEY"] = 2; + return values; + })(); + return v1beta; })(); diff --git a/packages/google-cloud-oslogin/protos/protos.json b/packages/google-cloud-oslogin/protos/protos.json index a07b79a4f36..b3d32e35c8a 100644 --- a/packages/google-cloud-oslogin/protos/protos.json +++ b/packages/google-cloud-oslogin/protos/protos.json @@ -129,9 +129,29 @@ "OsLoginService": { "options": { "(google.api.default_host)": "oslogin.googleapis.com", - "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/compute" + "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/cloud-platform.read-only,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/compute.readonly" }, "methods": { + "CreateSshPublicKey": { + "requestType": "CreateSshPublicKeyRequest", + "responseType": "google.cloud.oslogin.common.SshPublicKey", + "options": { + "(google.api.http).post": "/v1/{parent=users/*}/sshPublicKeys", + "(google.api.http).body": "ssh_public_key", + "(google.api.method_signature)": "parent,ssh_public_key" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1/{parent=users/*}/sshPublicKeys", + "body": "ssh_public_key" + } + }, + { + "(google.api.method_signature)": "parent,ssh_public_key" + } + ] + }, "DeletePosixAccount": { "requestType": "DeletePosixAccountRequest", "responseType": "google.protobuf.Empty", @@ -273,6 +293,25 @@ } } }, + "CreateSshPublicKeyRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "oslogin.googleapis.com/SshPublicKey" + } + }, + "sshPublicKey": { + "type": "google.cloud.oslogin.common.SshPublicKey", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } + } + } + }, "DeletePosixAccountRequest": { "fields": { "name": { @@ -357,6 +396,10 @@ "loginProfile": { "type": "LoginProfile", "id": 1 + }, + "details": { + "type": "string", + "id": 2 } } }, @@ -402,6 +445,26 @@ "(google.api.oauth_scopes)": "https://www.googleapis.com/auth/cloud-platform,https://www.googleapis.com/auth/cloud-platform.read-only,https://www.googleapis.com/auth/compute,https://www.googleapis.com/auth/compute.readonly" }, "methods": { + "CreateSshPublicKey": { + "requestType": "CreateSshPublicKeyRequest", + "responseType": "google.cloud.oslogin.common.SshPublicKey", + "options": { + "(google.api.http).post": "/v1beta/{parent=users/*}/sshPublicKeys", + "(google.api.http).body": "ssh_public_key", + "(google.api.method_signature)": "parent,ssh_public_key" + }, + "parsedOptions": [ + { + "(google.api.http)": { + "post": "/v1beta/{parent=users/*}/sshPublicKeys", + "body": "ssh_public_key" + } + }, + { + "(google.api.method_signature)": "parent,ssh_public_key" + } + ] + }, "DeletePosixAccount": { "requestType": "DeletePosixAccountRequest", "responseType": "google.protobuf.Empty", @@ -540,6 +603,30 @@ "keyType": "string", "type": "google.cloud.oslogin.common.SshPublicKey", "id": 3 + }, + "securityKeys": { + "rule": "repeated", + "type": "SecurityKey", + "id": 5 + } + } + }, + "CreateSshPublicKeyRequest": { + "fields": { + "parent": { + "type": "string", + "id": 1, + "options": { + "(google.api.field_behavior)": "REQUIRED", + "(google.api.resource_reference).child_type": "oslogin.googleapis.com/SshPublicKey" + } + }, + "sshPublicKey": { + "type": "google.cloud.oslogin.common.SshPublicKey", + "id": 2, + "options": { + "(google.api.field_behavior)": "REQUIRED" + } } } }, @@ -584,6 +671,10 @@ "systemId": { "type": "string", "id": 3 + }, + "view": { + "type": "LoginProfileView", + "id": 4 } } }, @@ -618,6 +709,10 @@ "projectId": { "type": "string", "id": 3 + }, + "view": { + "type": "LoginProfileView", + "id": 4 } } }, @@ -626,6 +721,10 @@ "loginProfile": { "type": "LoginProfile", "id": 1 + }, + "details": { + "type": "string", + "id": 2 } } }, @@ -651,6 +750,57 @@ "id": 3 } } + }, + "SecurityKey": { + "oneofs": { + "protocolType": { + "oneof": [ + "universalTwoFactor", + "webAuthn" + ] + } + }, + "fields": { + "publicKey": { + "type": "string", + "id": 1 + }, + "privateKey": { + "type": "string", + "id": 2 + }, + "universalTwoFactor": { + "type": "UniversalTwoFactor", + "id": 3 + }, + "webAuthn": { + "type": "WebAuthn", + "id": 4 + } + } + }, + "UniversalTwoFactor": { + "fields": { + "appId": { + "type": "string", + "id": 1 + } + } + }, + "WebAuthn": { + "fields": { + "rpId": { + "type": "string", + "id": 1 + } + } + }, + "LoginProfileView": { + "values": { + "LOGIN_PROFILE_VIEW_UNSPECIFIED": 0, + "BASIC": 1, + "SECURITY_KEY": 2 + } } } } diff --git a/packages/google-cloud-oslogin/samples/README.md b/packages/google-cloud-oslogin/samples/README.md index d30af6f0f6a..3dc20ff6749 100644 --- a/packages/google-cloud-oslogin/samples/README.md +++ b/packages/google-cloud-oslogin/samples/README.md @@ -12,12 +12,14 @@ * [Before you begin](#before-you-begin) * [Samples](#samples) + * [Os_login_service.create_ssh_public_key](#os_login_service.create_ssh_public_key) * [Os_login_service.delete_posix_account](#os_login_service.delete_posix_account) * [Os_login_service.delete_ssh_public_key](#os_login_service.delete_ssh_public_key) * [Os_login_service.get_login_profile](#os_login_service.get_login_profile) * [Os_login_service.get_ssh_public_key](#os_login_service.get_ssh_public_key) * [Os_login_service.import_ssh_public_key](#os_login_service.import_ssh_public_key) * [Os_login_service.update_ssh_public_key](#os_login_service.update_ssh_public_key) + * [Os_login_service.create_ssh_public_key](#os_login_service.create_ssh_public_key) * [Os_login_service.delete_posix_account](#os_login_service.delete_posix_account) * [Os_login_service.delete_ssh_public_key](#os_login_service.delete_ssh_public_key) * [Os_login_service.get_login_profile](#os_login_service.get_login_profile) @@ -42,6 +44,23 @@ Before running the samples, make sure you've followed the steps outlined in +### Os_login_service.create_ssh_public_key + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.create_ssh_public_key.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1/os_login_service.create_ssh_public_key.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-oslogin/samples/generated/v1/os_login_service.create_ssh_public_key.js` + + +----- + + + + ### Os_login_service.delete_posix_account View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.delete_posix_account.js). @@ -144,6 +163,23 @@ __Usage:__ +### Os_login_service.create_ssh_public_key + +View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.create_ssh_public_key.js). + +[![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/google-cloud-node&page=editor&open_in_editor=packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.create_ssh_public_key.js,samples/README.md) + +__Usage:__ + + +`node packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.create_ssh_public_key.js` + + +----- + + + + ### Os_login_service.delete_posix_account View the [source code](https://github.com/googleapis/google-cloud-node/blob/main/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.delete_posix_account.js). diff --git a/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.create_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.create_ssh_public_key.js new file mode 100644 index 00000000000..1ad7dcb2467 --- /dev/null +++ b/packages/google-cloud-oslogin/samples/generated/v1/os_login_service.create_ssh_public_key.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, sshPublicKey) { + // [START oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The unique ID for the user in format `users/{user}`. + */ + // const parent = 'abc123' + /** + * Required. The SSH public key and expiration time. + */ + // const sshPublicKey = {} + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callCreateSshPublicKey() { + // Construct request + const request = { + parent, + sshPublicKey, + }; + + // Run request + const response = await osloginClient.createSshPublicKey(request); + console.log(response); + } + + callCreateSshPublicKey(); + // [END oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-oslogin/samples/generated/v1/snippet_metadata.google.cloud.oslogin.v1.json b/packages/google-cloud-oslogin/samples/generated/v1/snippet_metadata.google.cloud.oslogin.v1.json index c2069880555..f2a4dcdab33 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1/snippet_metadata.google.cloud.oslogin.v1.json +++ b/packages/google-cloud-oslogin/samples/generated/v1/snippet_metadata.google.cloud.oslogin.v1.json @@ -11,6 +11,50 @@ ] }, "snippets": [ + { + "regionTag": "oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async", + "title": "OsLoginService createSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Create an SSH public key", + "canonical": true, + "file": "os_login_service.create_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.CreateSshPublicKey", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "ssh_public_key", + "type": ".google.cloud.oslogin.common.SshPublicKey" + } + ], + "resultType": ".google.cloud.oslogin.common.SshPublicKey", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1.OsLoginServiceClient" + }, + "method": { + "shortName": "CreateSshPublicKey", + "fullName": "google.cloud.oslogin.v1.OsLoginService.CreateSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1.OsLoginService" + } + } + } + }, { "regionTag": "oslogin_v1_generated_OsLoginService_DeletePosixAccount_async", "title": "OsLoginService deletePosixAccount Sample", diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.create_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.create_ssh_public_key.js new file mode 100644 index 00000000000..ec94480c743 --- /dev/null +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.create_ssh_public_key.js @@ -0,0 +1,66 @@ +// Copyright 2022 Google LLC +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +// ** This file is automatically generated by gapic-generator-typescript. ** +// ** https://github.com/googleapis/gapic-generator-typescript ** +// ** All changes to this file may be overwritten. ** + + + +'use strict'; + +function main(parent, sshPublicKey) { + // [START oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async] + /** + * This snippet has been automatically generated and should be regarded as a code template only. + * It will require modifications to work. + * It may require correct/in-range values for request initialization. + * TODO(developer): Uncomment these variables before running the sample. + */ + /** + * Required. The unique ID for the user in format `users/{user}`. + */ + // const parent = 'abc123' + /** + * Required. The SSH public key and expiration time. + */ + // const sshPublicKey = {} + + // Imports the Oslogin library + const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; + + // Instantiates a client + const osloginClient = new OsLoginServiceClient(); + + async function callCreateSshPublicKey() { + // Construct request + const request = { + parent, + sshPublicKey, + }; + + // Run request + const response = await osloginClient.createSshPublicKey(request); + console.log(response); + } + + callCreateSshPublicKey(); + // [END oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async] +} + +process.on('unhandledRejection', err => { + console.error(err.message); + process.exitCode = 1; +}); +main(...process.argv.slice(2)); diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js index 97028d9fcd4..ed9ae4af370 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.get_login_profile.js @@ -40,6 +40,10 @@ function main(name) { * A system ID for filtering the results of the request. */ // const systemId = 'abc123' + /** + * The view configures whether to retrieve security keys information. + */ + // const view = {} // Imports the Oslogin library const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.import_ssh_public_key.js b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.import_ssh_public_key.js index d1af96117a4..d3bb62a2ab4 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.import_ssh_public_key.js +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/os_login_service.import_ssh_public_key.js @@ -40,6 +40,10 @@ function main(sshPublicKey) { * The project ID of the Google Cloud Platform project. */ // const projectId = 'abc123' + /** + * The view configures whether to retrieve security keys information. + */ + // const view = {} // Imports the Oslogin library const {OsLoginServiceClient} = require('@google-cloud/os-login').v1beta; diff --git a/packages/google-cloud-oslogin/samples/generated/v1beta/snippet_metadata.google.cloud.oslogin.v1beta.json b/packages/google-cloud-oslogin/samples/generated/v1beta/snippet_metadata.google.cloud.oslogin.v1beta.json index a101e659acd..b82dbdbc81c 100644 --- a/packages/google-cloud-oslogin/samples/generated/v1beta/snippet_metadata.google.cloud.oslogin.v1beta.json +++ b/packages/google-cloud-oslogin/samples/generated/v1beta/snippet_metadata.google.cloud.oslogin.v1beta.json @@ -11,6 +11,50 @@ ] }, "snippets": [ + { + "regionTag": "oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async", + "title": "OsLoginService createSshPublicKey Sample", + "origin": "API_DEFINITION", + "description": " Create an SSH public key", + "canonical": true, + "file": "os_login_service.create_ssh_public_key.js", + "language": "JAVASCRIPT", + "segments": [ + { + "start": 25, + "end": 58, + "type": "FULL" + } + ], + "clientMethod": { + "shortName": "CreateSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.CreateSshPublicKey", + "async": true, + "parameters": [ + { + "name": "parent", + "type": "TYPE_STRING" + }, + { + "name": "ssh_public_key", + "type": ".google.cloud.oslogin.common.SshPublicKey" + } + ], + "resultType": ".google.cloud.oslogin.common.SshPublicKey", + "client": { + "shortName": "OsLoginServiceClient", + "fullName": "google.cloud.oslogin.v1beta.OsLoginServiceClient" + }, + "method": { + "shortName": "CreateSshPublicKey", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService.CreateSshPublicKey", + "service": { + "shortName": "OsLoginService", + "fullName": "google.cloud.oslogin.v1beta.OsLoginService" + } + } + } + }, { "regionTag": "oslogin_v1beta_generated_OsLoginService_DeletePosixAccount_async", "title": "OsLoginService deletePosixAccount Sample", @@ -102,7 +146,7 @@ "segments": [ { "start": 25, - "end": 61, + "end": 65, "type": "FULL" } ], @@ -122,6 +166,10 @@ { "name": "system_id", "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.oslogin.v1beta.LoginProfileView" } ], "resultType": ".google.cloud.oslogin.v1beta.LoginProfile", @@ -190,7 +238,7 @@ "segments": [ { "start": 25, - "end": 61, + "end": 65, "type": "FULL" } ], @@ -210,6 +258,10 @@ { "name": "project_id", "type": "TYPE_STRING" + }, + { + "name": "view", + "type": ".google.cloud.oslogin.v1beta.LoginProfileView" } ], "resultType": ".google.cloud.oslogin.v1beta.ImportSshPublicKeyResponse", diff --git a/packages/google-cloud-oslogin/src/v1/gapic_metadata.json b/packages/google-cloud-oslogin/src/v1/gapic_metadata.json index f89ea9a8605..fc08cf26063 100644 --- a/packages/google-cloud-oslogin/src/v1/gapic_metadata.json +++ b/packages/google-cloud-oslogin/src/v1/gapic_metadata.json @@ -10,6 +10,11 @@ "grpc": { "libraryClient": "OsLoginServiceClient", "rpcs": { + "CreateSshPublicKey": { + "methods": [ + "createSshPublicKey" + ] + }, "DeletePosixAccount": { "methods": [ "deletePosixAccount" @@ -45,6 +50,11 @@ "grpc-fallback": { "libraryClient": "OsLoginServiceClient", "rpcs": { + "CreateSshPublicKey": { + "methods": [ + "createSshPublicKey" + ] + }, "DeletePosixAccount": { "methods": [ "deletePosixAccount" diff --git a/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts b/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts index 7d4b6790c93..646d45d18ce 100644 --- a/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts +++ b/packages/google-cloud-oslogin/src/v1/os_login_service_client.ts @@ -121,6 +121,9 @@ export class OsLoginServiceClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; @@ -235,6 +238,7 @@ export class OsLoginServiceClient { // Iterate over each of the methods that the service provides // and create an API call method for each. const osLoginServiceStubMethods = [ + 'createSshPublicKey', 'deletePosixAccount', 'deleteSshPublicKey', 'getLoginProfile', @@ -304,7 +308,9 @@ export class OsLoginServiceClient { static get scopes() { return [ 'https://www.googleapis.com/auth/cloud-platform', + 'https://www.googleapis.com/auth/cloud-platform.read-only', 'https://www.googleapis.com/auth/compute', + 'https://www.googleapis.com/auth/compute.readonly', ]; } @@ -327,6 +333,99 @@ export class OsLoginServiceClient { // ------------------- // -- Service calls -- // ------------------- + /** + * Create an SSH public key + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique ID for the user in format `users/{user}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1/os_login_service.create_ssh_public_key.js + * region_tag:oslogin_v1_generated_OsLoginService_CreateSshPublicKey_async + */ + createSshPublicKey( + request?: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest | undefined, + {} | undefined + ] + >; + createSshPublicKey( + request: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + | protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createSshPublicKey( + request: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + | protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createSshPublicKey( + request?: protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + | protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + | protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1.ICreateSshPublicKeyRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSshPublicKey(request, options, callback); + } /** * Deletes a POSIX account. * diff --git a/packages/google-cloud-oslogin/src/v1/os_login_service_client_config.json b/packages/google-cloud-oslogin/src/v1/os_login_service_client_config.json index fc7cef92246..afdd4ec0a35 100644 --- a/packages/google-cloud-oslogin/src/v1/os_login_service_client_config.json +++ b/packages/google-cloud-oslogin/src/v1/os_login_service_client_config.json @@ -20,6 +20,10 @@ } }, "methods": { + "CreateSshPublicKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "DeletePosixAccount": { "timeout_millis": 10000, "retry_codes_name": "idempotent", diff --git a/packages/google-cloud-oslogin/src/v1beta/gapic_metadata.json b/packages/google-cloud-oslogin/src/v1beta/gapic_metadata.json index 10c49f7afb6..ad42910537d 100644 --- a/packages/google-cloud-oslogin/src/v1beta/gapic_metadata.json +++ b/packages/google-cloud-oslogin/src/v1beta/gapic_metadata.json @@ -10,6 +10,11 @@ "grpc": { "libraryClient": "OsLoginServiceClient", "rpcs": { + "CreateSshPublicKey": { + "methods": [ + "createSshPublicKey" + ] + }, "DeletePosixAccount": { "methods": [ "deletePosixAccount" @@ -45,6 +50,11 @@ "grpc-fallback": { "libraryClient": "OsLoginServiceClient", "rpcs": { + "CreateSshPublicKey": { + "methods": [ + "createSshPublicKey" + ] + }, "DeletePosixAccount": { "methods": [ "deletePosixAccount" diff --git a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts index 1a09589b039..2649fe6ae63 100644 --- a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts +++ b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client.ts @@ -121,6 +121,9 @@ export class OsLoginServiceClient { (typeof window !== 'undefined' && typeof window?.fetch === 'function'); opts = Object.assign({servicePath, port, clientConfig, fallback}, opts); + // Request numeric enum values if REST transport is used. + opts.numericEnums = true; + // If scopes are unset in options and we're connecting to a non-default endpoint, set scopes just in case. if (servicePath !== staticMembers.servicePath && !('scopes' in opts)) { opts['scopes'] = staticMembers.scopes; @@ -235,6 +238,7 @@ export class OsLoginServiceClient { // Iterate over each of the methods that the service provides // and create an API call method for each. const osLoginServiceStubMethods = [ + 'createSshPublicKey', 'deletePosixAccount', 'deleteSshPublicKey', 'getLoginProfile', @@ -329,6 +333,99 @@ export class OsLoginServiceClient { // ------------------- // -- Service calls -- // ------------------- + /** + * Create an SSH public key + * + * @param {Object} request + * The request object that will be sent. + * @param {string} request.parent + * Required. The unique ID for the user in format `users/{user}`. + * @param {google.cloud.oslogin.common.SshPublicKey} request.sshPublicKey + * Required. The SSH public key and expiration time. + * @param {object} [options] + * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. + * @returns {Promise} - The promise which resolves to an array. + * The first element of the array is an object representing [SshPublicKey]{@link google.cloud.oslogin.common.SshPublicKey}. + * Please see the + * [documentation](https://github.com/googleapis/gax-nodejs/blob/master/client-libraries.md#regular-methods) + * for more details and examples. + * @example include:samples/generated/v1beta/os_login_service.create_ssh_public_key.js + * region_tag:oslogin_v1beta_generated_OsLoginService_CreateSshPublicKey_async + */ + createSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, + options?: CallOptions + ): Promise< + [ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest | undefined, + {} | undefined + ] + >; + createSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, + options: CallOptions, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + | protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createSshPublicKey( + request: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, + callback: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + | protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest + | null + | undefined, + {} | null | undefined + > + ): void; + createSshPublicKey( + request?: protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest, + optionsOrCallback?: + | CallOptions + | Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + | protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest + | null + | undefined, + {} | null | undefined + >, + callback?: Callback< + protos.google.cloud.oslogin.common.ISshPublicKey, + | protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest + | null + | undefined, + {} | null | undefined + > + ): Promise< + [ + protos.google.cloud.oslogin.common.ISshPublicKey, + protos.google.cloud.oslogin.v1beta.ICreateSshPublicKeyRequest | undefined, + {} | undefined + ] + > | void { + request = request || {}; + let options: CallOptions; + if (typeof optionsOrCallback === 'function' && callback === undefined) { + callback = optionsOrCallback; + options = {}; + } else { + options = optionsOrCallback as CallOptions; + } + options = options || {}; + options.otherArgs = options.otherArgs || {}; + options.otherArgs.headers = options.otherArgs.headers || {}; + options.otherArgs.headers['x-goog-request-params'] = + this._gaxModule.routingHeader.fromParams({ + parent: request.parent ?? '', + }); + this.initialize(); + return this.innerApiCalls.createSshPublicKey(request, options, callback); + } /** * Deletes a POSIX account. * @@ -527,6 +624,8 @@ export class OsLoginServiceClient { * The project ID of the Google Cloud Platform project. * @param {string} request.systemId * A system ID for filtering the results of the request. + * @param {google.cloud.oslogin.v1beta.LoginProfileView} request.view + * The view configures whether to retrieve security keys information. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. @@ -717,6 +816,8 @@ export class OsLoginServiceClient { * Required. The SSH public key and expiration time. * @param {string} request.projectId * The project ID of the Google Cloud Platform project. + * @param {google.cloud.oslogin.v1beta.LoginProfileView} request.view + * The view configures whether to retrieve security keys information. * @param {object} [options] * Call options. See {@link https://googleapis.dev/nodejs/google-gax/latest/interfaces/CallOptions.html|CallOptions} for more details. * @returns {Promise} - The promise which resolves to an array. diff --git a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client_config.json b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client_config.json index 6dba4859a32..d45946b5241 100644 --- a/packages/google-cloud-oslogin/src/v1beta/os_login_service_client_config.json +++ b/packages/google-cloud-oslogin/src/v1beta/os_login_service_client_config.json @@ -20,6 +20,10 @@ } }, "methods": { + "CreateSshPublicKey": { + "retry_codes_name": "non_idempotent", + "retry_params_name": "default" + }, "DeletePosixAccount": { "timeout_millis": 10000, "retry_codes_name": "idempotent", diff --git a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts index 782c2f881cd..0e5e028af8f 100644 --- a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts +++ b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1.ts @@ -164,6 +164,137 @@ describe('v1.OsLoginServiceClient', () => { }); }); + describe('createSshPublicKey', () => { + it('invokes createSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.createSshPublicKey = + stubSimpleCall(expectedResponse); + const [response] = await client.createSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.createSshPublicKey = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSshPublicKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oslogin.common.ISshPublicKey | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSshPublicKey = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createSshPublicKey(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1.CreateSshPublicKeyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oslogin.v1.CreateSshPublicKeyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createSshPublicKey(request), expectedError); + }); + }); + describe('deletePosixAccount', () => { it('invokes deletePosixAccount without error', async () => { const client = new osloginserviceModule.v1.OsLoginServiceClient({ diff --git a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts index 2569ed64caa..beb2206e3c7 100644 --- a/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts +++ b/packages/google-cloud-oslogin/test/gapic_os_login_service_v1beta.ts @@ -164,6 +164,137 @@ describe('v1beta.OsLoginServiceClient', () => { }); }); + describe('createSshPublicKey', () => { + it('invokes createSshPublicKey without error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.createSshPublicKey = + stubSimpleCall(expectedResponse); + const [response] = await client.createSshPublicKey(request); + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey without error using callback', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedResponse = generateSampleMessage( + new protos.google.cloud.oslogin.common.SshPublicKey() + ); + client.innerApiCalls.createSshPublicKey = + stubSimpleCallWithCallback(expectedResponse); + const promise = new Promise((resolve, reject) => { + client.createSshPublicKey( + request, + ( + err?: Error | null, + result?: protos.google.cloud.oslogin.common.ISshPublicKey | null + ) => { + if (err) { + reject(err); + } else { + resolve(result); + } + } + ); + }); + const response = await promise; + assert.deepStrictEqual(response, expectedResponse); + const actualRequest = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey with error', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedHeaderRequestParams = `parent=${defaultValue1}`; + const expectedError = new Error('expected'); + client.innerApiCalls.createSshPublicKey = stubSimpleCall( + undefined, + expectedError + ); + await assert.rejects(client.createSshPublicKey(request), expectedError); + const actualRequest = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[0]; + assert.deepStrictEqual(actualRequest, request); + const actualHeaderRequestParams = ( + client.innerApiCalls.createSshPublicKey as SinonStub + ).getCall(0).args[1].otherArgs.headers['x-goog-request-params']; + assert(actualHeaderRequestParams.includes(expectedHeaderRequestParams)); + }); + + it('invokes createSshPublicKey with closed client', async () => { + const client = new osloginserviceModule.v1beta.OsLoginServiceClient({ + credentials: {client_email: 'bogus', private_key: 'bogus'}, + projectId: 'bogus', + }); + client.initialize(); + const request = generateSampleMessage( + new protos.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest() + ); + const defaultValue1 = getTypeDefaultValue( + '.google.cloud.oslogin.v1beta.CreateSshPublicKeyRequest', + ['parent'] + ); + request.parent = defaultValue1; + const expectedError = new Error('The client has already been closed.'); + client.close(); + await assert.rejects(client.createSshPublicKey(request), expectedError); + }); + }); + describe('deletePosixAccount', () => { it('invokes deletePosixAccount without error', async () => { const client = new osloginserviceModule.v1beta.OsLoginServiceClient({