|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +# |
| 3 | +# Copyright 2018 Google LLC |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# https://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +import google.api_core.grpc_helpers |
| 18 | + |
| 19 | +from google.cloud.oslogin_v1.proto import oslogin_pb2_grpc |
| 20 | + |
| 21 | + |
| 22 | +class OsLoginServiceGrpcTransport(object): |
| 23 | + """gRPC transport class providing stubs for |
| 24 | + google.cloud.oslogin.v1 OsLoginService API. |
| 25 | +
|
| 26 | + The transport provides access to the raw gRPC stubs, |
| 27 | + which can be used to take advantage of advanced |
| 28 | + features of gRPC. |
| 29 | + """ |
| 30 | + # The scopes needed to make gRPC calls to all of the methods defined |
| 31 | + # in this service. |
| 32 | + _OAUTH_SCOPES = ( |
| 33 | + 'https://www.googleapis.com/auth/cloud-platform', |
| 34 | + 'https://www.googleapis.com/auth/cloud-platform.read-only', |
| 35 | + 'https://www.googleapis.com/auth/compute', |
| 36 | + 'https://www.googleapis.com/auth/compute.readonly', |
| 37 | + ) |
| 38 | + |
| 39 | + def __init__(self, |
| 40 | + channel=None, |
| 41 | + credentials=None, |
| 42 | + address='oslogin.googleapis.com:443'): |
| 43 | + """Instantiate the transport class. |
| 44 | +
|
| 45 | + Args: |
| 46 | + channel (grpc.Channel): A ``Channel`` instance through |
| 47 | + which to make calls. This argument is mutually exclusive |
| 48 | + with ``credentials``; providing both will raise an exception. |
| 49 | + credentials (google.auth.credentials.Credentials): The |
| 50 | + authorization credentials to attach to requests. These |
| 51 | + credentials identify this application to the service. If none |
| 52 | + are specified, the client will attempt to ascertain the |
| 53 | + credentials from the environment. |
| 54 | + address (str): The address where the service is hosted. |
| 55 | + """ |
| 56 | + # If both `channel` and `credentials` are specified, raise an |
| 57 | + # exception (channels come with credentials baked in already). |
| 58 | + if channel is not None and credentials is not None: |
| 59 | + raise ValueError( |
| 60 | + 'The `channel` and `credentials` arguments are mutually ' |
| 61 | + 'exclusive.', ) |
| 62 | + |
| 63 | + # Create the channel. |
| 64 | + if channel is None: |
| 65 | + channel = self.create_channel( |
| 66 | + address=address, |
| 67 | + credentials=credentials, |
| 68 | + ) |
| 69 | + |
| 70 | + # gRPC uses objects called "stubs" that are bound to the |
| 71 | + # channel and provide a basic method for each RPC. |
| 72 | + self._stubs = { |
| 73 | + 'os_login_service_stub': |
| 74 | + oslogin_pb2_grpc.OsLoginServiceStub(channel), |
| 75 | + } |
| 76 | + |
| 77 | + @classmethod |
| 78 | + def create_channel(cls, |
| 79 | + address='oslogin.googleapis.com:443', |
| 80 | + credentials=None): |
| 81 | + """Create and return a gRPC channel object. |
| 82 | +
|
| 83 | + Args: |
| 84 | + address (str): The host for the channel to use. |
| 85 | + credentials (~.Credentials): The |
| 86 | + authorization credentials to attach to requests. These |
| 87 | + credentials identify this application to the service. If |
| 88 | + none are specified, the client will attempt to ascertain |
| 89 | + the credentials from the environment. |
| 90 | +
|
| 91 | + Returns: |
| 92 | + grpc.Channel: A gRPC channel object. |
| 93 | + """ |
| 94 | + return google.api_core.grpc_helpers.create_channel( |
| 95 | + address, |
| 96 | + credentials=credentials, |
| 97 | + scopes=cls._OAUTH_SCOPES, |
| 98 | + ) |
| 99 | + |
| 100 | + @property |
| 101 | + def delete_posix_account(self): |
| 102 | + """Return the gRPC stub for {$apiMethod.name}. |
| 103 | +
|
| 104 | + Deletes a POSIX account. |
| 105 | +
|
| 106 | + Returns: |
| 107 | + Callable: A callable which accepts the appropriate |
| 108 | + deserialized request object and returns a |
| 109 | + deserialized response object. |
| 110 | + """ |
| 111 | + return self._stubs['os_login_service_stub'].DeletePosixAccount |
| 112 | + |
| 113 | + @property |
| 114 | + def delete_ssh_public_key(self): |
| 115 | + """Return the gRPC stub for {$apiMethod.name}. |
| 116 | +
|
| 117 | + Deletes an SSH public key. |
| 118 | +
|
| 119 | + Returns: |
| 120 | + Callable: A callable which accepts the appropriate |
| 121 | + deserialized request object and returns a |
| 122 | + deserialized response object. |
| 123 | + """ |
| 124 | + return self._stubs['os_login_service_stub'].DeleteSshPublicKey |
| 125 | + |
| 126 | + @property |
| 127 | + def get_login_profile(self): |
| 128 | + """Return the gRPC stub for {$apiMethod.name}. |
| 129 | +
|
| 130 | + Retrieves the profile information used for logging in to a virtual machine |
| 131 | + on Google Compute Engine. |
| 132 | +
|
| 133 | + Returns: |
| 134 | + Callable: A callable which accepts the appropriate |
| 135 | + deserialized request object and returns a |
| 136 | + deserialized response object. |
| 137 | + """ |
| 138 | + return self._stubs['os_login_service_stub'].GetLoginProfile |
| 139 | + |
| 140 | + @property |
| 141 | + def get_ssh_public_key(self): |
| 142 | + """Return the gRPC stub for {$apiMethod.name}. |
| 143 | +
|
| 144 | + Retrieves an SSH public key. |
| 145 | +
|
| 146 | + Returns: |
| 147 | + Callable: A callable which accepts the appropriate |
| 148 | + deserialized request object and returns a |
| 149 | + deserialized response object. |
| 150 | + """ |
| 151 | + return self._stubs['os_login_service_stub'].GetSshPublicKey |
| 152 | + |
| 153 | + @property |
| 154 | + def import_ssh_public_key(self): |
| 155 | + """Return the gRPC stub for {$apiMethod.name}. |
| 156 | +
|
| 157 | + Adds an SSH public key and returns the profile information. Default POSIX |
| 158 | + account information is set when no username and UID exist as part of the |
| 159 | + login profile. |
| 160 | +
|
| 161 | + Returns: |
| 162 | + Callable: A callable which accepts the appropriate |
| 163 | + deserialized request object and returns a |
| 164 | + deserialized response object. |
| 165 | + """ |
| 166 | + return self._stubs['os_login_service_stub'].ImportSshPublicKey |
| 167 | + |
| 168 | + @property |
| 169 | + def update_ssh_public_key(self): |
| 170 | + """Return the gRPC stub for {$apiMethod.name}. |
| 171 | +
|
| 172 | + Updates an SSH public key and returns the profile information. This method |
| 173 | + supports patch semantics. |
| 174 | +
|
| 175 | + Returns: |
| 176 | + Callable: A callable which accepts the appropriate |
| 177 | + deserialized request object and returns a |
| 178 | + deserialized response object. |
| 179 | + """ |
| 180 | + return self._stubs['os_login_service_stub'].UpdateSshPublicKey |
0 commit comments