Skip to content
This repository has been archived by the owner on Dec 31, 2023. It is now read-only.

Commit

Permalink
feat(oslogin)!: rename fingerprint_path to ssh_public_key_path; r…
Browse files Browse the repository at this point in the history
…ename `project_path` to `posix_account_path`; add `OperatingSystemType` enum; make `ssh_public_key` optional param to `import_ssh_public_key`; annotate protos (via synth) (#9431)
  • Loading branch information
yoshi-automation authored and busunkim96 committed Oct 25, 2019
1 parent 8082da5 commit f903af4
Show file tree
Hide file tree
Showing 23 changed files with 495 additions and 1,570 deletions.
9 changes: 8 additions & 1 deletion docs/conf.py
Expand Up @@ -45,6 +45,7 @@
autodoc_default_flags = ["members"]
autosummary_generate = True


# Add any paths that contain templates here, relative to this directory.
templates_path = ["_templates"]

Expand Down Expand Up @@ -121,6 +122,7 @@
# If true, `todo` and `todoList` produce output, else they produce nothing.
todo_include_todos = True


# -- Options for HTML output ----------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
Expand Down Expand Up @@ -229,6 +231,7 @@

# -- Options for warnings ------------------------------------------------------


suppress_warnings = [
# Temporarily suppress this to avoid "more than one target found for
# cross-reference" warning, which are intractable for us to avoid while in
Expand Down Expand Up @@ -284,6 +287,7 @@
# If false, no module index is generated.
# latex_domain_indices = True


# -- Options for manual page output ---------------------------------------

# One entry per manual page. List of tuples
Expand All @@ -301,6 +305,7 @@
# If true, show URL addresses after external links.
# man_show_urls = False


# -- Options for Texinfo output -------------------------------------------

# Grouping the document tree into Texinfo files. List of tuples
Expand Down Expand Up @@ -330,6 +335,7 @@
# If true, do not generate a @detailmenu in the "Top" node's menu.
# texinfo_no_detailmenu = False


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {
"python": ("http://python.readthedocs.org/en/latest/", None),
Expand All @@ -338,11 +344,12 @@
"google-gax": ("https://gax-python.readthedocs.io/en/latest/", None),
"google.api_core": ("https://googleapis.dev/python/google-api-core/latest", None),
"grpc": ("https://grpc.io/grpc/python/", None),
"requests": ("https://requests.kennethreitz.org/en/stable/", None),
"requests": ("https://requests.kennethreitz.org/en/master/", None),
"fastavro": ("https://fastavro.readthedocs.io/en/stable/", None),
"pandas": ("https://pandas.pydata.org/pandas-docs/stable/", None),
}


# Napoleon settings
napoleon_google_docstring = True
napoleon_numpy_docstring = True
Expand Down
4 changes: 2 additions & 2 deletions docs/gapic/v1/api.rst
@@ -1,5 +1,5 @@
Client for Google Cloud OS Login API
====================================
Client for Cloud OS Login API
=============================

.. automodule:: google.cloud.oslogin_v1
:members:
Expand Down
4 changes: 2 additions & 2 deletions docs/gapic/v1/types.rst
@@ -1,5 +1,5 @@
Types for Google Cloud OS Login API Client
==========================================
Types for Cloud OS Login API Client
===================================

.. automodule:: google.cloud.oslogin_v1.types
:members:
4 changes: 3 additions & 1 deletion google/__init__.py
@@ -1,4 +1,6 @@
# Copyright 2018 Google LLC
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
4 changes: 3 additions & 1 deletion google/cloud/__init__.py
@@ -1,4 +1,6 @@
# Copyright 2018 Google LLC
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down
9 changes: 7 additions & 2 deletions google/cloud/oslogin.py
@@ -1,4 +1,6 @@
# Copyright 2018 Google LLC
# -*- coding: utf-8 -*-
#
# Copyright 2019 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -12,9 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.


from __future__ import absolute_import

from google.cloud.oslogin_v1 import OsLoginServiceClient
from google.cloud.oslogin_v1 import enums
from google.cloud.oslogin_v1 import types

__all__ = ("types", "OsLoginServiceClient")

__all__ = ("enums", "types", "OsLoginServiceClient")
4 changes: 3 additions & 1 deletion google/cloud/oslogin_v1/__init__.py
Expand Up @@ -18,11 +18,13 @@
from __future__ import absolute_import

from google.cloud.oslogin_v1 import types
from google.cloud.oslogin_v1.gapic import enums
from google.cloud.oslogin_v1.gapic import os_login_service_client


class OsLoginServiceClient(os_login_service_client.OsLoginServiceClient):
__doc__ = os_login_service_client.OsLoginServiceClient.__doc__
enums = enums


__all__ = ("types", "OsLoginServiceClient")
__all__ = ("enums", "types", "OsLoginServiceClient")
35 changes: 35 additions & 0 deletions google/cloud/oslogin_v1/gapic/enums.py
@@ -0,0 +1,35 @@
# -*- coding: utf-8 -*-
#
# Copyright 2019 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.

"""Wrappers for protocol buffer enum types."""

import enum


class OperatingSystemType(enum.IntEnum):
"""
The operating system options for account entries.
Attributes:
OPERATING_SYSTEM_TYPE_UNSPECIFIED (int): The operating system type associated with the user account information is
unspecified.
LINUX (int): Linux user account information.
WINDOWS (int): Windows user account information.
"""

OPERATING_SYSTEM_TYPE_UNSPECIFIED = 0
LINUX = 1
WINDOWS = 2
64 changes: 34 additions & 30 deletions google/cloud/oslogin_v1/gapic/os_login_service_client.py
Expand Up @@ -29,6 +29,7 @@
import google.api_core.path_template
import grpc

from google.cloud.oslogin_v1.gapic import enums
from google.cloud.oslogin_v1.gapic import os_login_service_client_config
from google.cloud.oslogin_v1.gapic.transports import os_login_service_grpc_transport
from google.cloud.oslogin_v1.proto import common_pb2
Expand Down Expand Up @@ -77,19 +78,19 @@ def from_service_account_file(cls, filename, *args, **kwargs):
from_service_account_json = from_service_account_file

@classmethod
def fingerprint_path(cls, user, fingerprint):
"""Return a fully-qualified fingerprint string."""
def posix_account_path(cls, user, project):
"""Return a fully-qualified posix_account string."""
return google.api_core.path_template.expand(
"users/{user}/sshPublicKeys/{fingerprint}",
user=user,
fingerprint=fingerprint,
"users/{user}/projects/{project}", user=user, project=project
)

@classmethod
def project_path(cls, user, project):
"""Return a fully-qualified project string."""
def ssh_public_key_path(cls, user, fingerprint):
"""Return a fully-qualified ssh_public_key string."""
return google.api_core.path_template.expand(
"users/{user}/projects/{project}", user=user, project=project
"users/{user}/sshPublicKeys/{fingerprint}",
user=user,
fingerprint=fingerprint,
)

@classmethod
Expand Down Expand Up @@ -225,12 +226,12 @@ def delete_posix_account(
>>>
>>> client = oslogin_v1.OsLoginServiceClient()
>>>
>>> name = client.project_path('[USER]', '[PROJECT]')
>>> name = client.posix_account_path('[USER]', '[PROJECT]')
>>>
>>> client.delete_posix_account(name)
Args:
name (str): A reference to the POSIX account to update. POSIX accounts are
name (str): Required. A reference to the POSIX account to update. POSIX accounts are
identified by the project ID they are associated with. A reference to
the POSIX account is in format ``users/{user}/projects/{project}``.
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -293,14 +294,14 @@ def delete_ssh_public_key(
>>>
>>> client = oslogin_v1.OsLoginServiceClient()
>>>
>>> name = client.fingerprint_path('[USER]', '[FINGERPRINT]')
>>> name = client.ssh_public_key_path('[USER]', '[FINGERPRINT]')
>>>
>>> client.delete_ssh_public_key(name)
Args:
name (str): The fingerprint of the public key to update. Public keys are identified
by their SHA-256 fingerprint. The fingerprint of the public key is in
format ``users/{user}/sshPublicKeys/{fingerprint}``.
name (str): Required. The fingerprint of the public key to update. Public keys are
identified by their SHA-256 fingerprint. The fingerprint of the public
key is in format ``users/{user}/sshPublicKeys/{fingerprint}``.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
Expand Down Expand Up @@ -349,6 +350,8 @@ def delete_ssh_public_key(
def get_login_profile(
self,
name,
project_id=None,
system_id=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
metadata=None,
Expand All @@ -367,7 +370,9 @@ def get_login_profile(
>>> response = client.get_login_profile(name)
Args:
name (str): The unique ID for the user in format ``users/{user}``.
name (str): Required. The unique ID for the user in format ``users/{user}``.
project_id (str): The project ID of the Google Cloud Platform project.
system_id (str): A system ID for filtering the results of the request.
retry (Optional[google.api_core.retry.Retry]): A retry object used
to retry requests. If ``None`` is specified, requests will
be retried using a default configuration.
Expand Down Expand Up @@ -398,7 +403,9 @@ def get_login_profile(
client_info=self._client_info,
)

request = oslogin_pb2.GetLoginProfileRequest(name=name)
request = oslogin_pb2.GetLoginProfileRequest(
name=name, project_id=project_id, system_id=system_id
)
if metadata is None:
metadata = []
metadata = list(metadata)
Expand Down Expand Up @@ -431,12 +438,12 @@ def get_ssh_public_key(
>>>
>>> client = oslogin_v1.OsLoginServiceClient()
>>>
>>> name = client.fingerprint_path('[USER]', '[FINGERPRINT]')
>>> name = client.ssh_public_key_path('[USER]', '[FINGERPRINT]')
>>>
>>> response = client.get_ssh_public_key(name)
Args:
name (str): The fingerprint of the public key to retrieve. Public keys are
name (str): Required. The fingerprint of the public key to retrieve. Public keys are
identified by their SHA-256 fingerprint. The fingerprint of the public
key is in format ``users/{user}/sshPublicKeys/{fingerprint}``.
retry (Optional[google.api_core.retry.Retry]): A retry object used
Expand Down Expand Up @@ -490,7 +497,7 @@ def get_ssh_public_key(
def import_ssh_public_key(
self,
parent,
ssh_public_key,
ssh_public_key=None,
project_id=None,
retry=google.api_core.gapic_v1.method.DEFAULT,
timeout=google.api_core.gapic_v1.method.DEFAULT,
Expand All @@ -508,14 +515,11 @@ def import_ssh_public_key(
>>>
>>> parent = client.user_path('[USER]')
>>>
>>> # TODO: Initialize `ssh_public_key`:
>>> ssh_public_key = {}
>>>
>>> response = client.import_ssh_public_key(parent, ssh_public_key)
>>> response = client.import_ssh_public_key(parent)
Args:
parent (str): The unique ID for the user in format ``users/{user}``.
ssh_public_key (Union[dict, ~google.cloud.oslogin_v1.types.SshPublicKey]): The SSH public key and expiration time.
parent (str): Required. The unique ID for the user in format ``users/{user}``.
ssh_public_key (Union[dict, ~google.cloud.oslogin_v1.types.SshPublicKey]): Optional. The SSH public key and expiration time.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.oslogin_v1.types.SshPublicKey`
Expand Down Expand Up @@ -588,18 +592,18 @@ def update_ssh_public_key(
>>>
>>> client = oslogin_v1.OsLoginServiceClient()
>>>
>>> name = client.fingerprint_path('[USER]', '[FINGERPRINT]')
>>> name = client.ssh_public_key_path('[USER]', '[FINGERPRINT]')
>>>
>>> # TODO: Initialize `ssh_public_key`:
>>> ssh_public_key = {}
>>>
>>> response = client.update_ssh_public_key(name, ssh_public_key)
Args:
name (str): The fingerprint of the public key to update. Public keys are identified
by their SHA-256 fingerprint. The fingerprint of the public key is in
format ``users/{user}/sshPublicKeys/{fingerprint}``.
ssh_public_key (Union[dict, ~google.cloud.oslogin_v1.types.SshPublicKey]): The SSH public key and expiration time.
name (str): Required. The fingerprint of the public key to update. Public keys are
identified by their SHA-256 fingerprint. The fingerprint of the public
key is in format ``users/{user}/sshPublicKeys/{fingerprint}``.
ssh_public_key (Union[dict, ~google.cloud.oslogin_v1.types.SshPublicKey]): Required. The SSH public key and expiration time.
If a dict is provided, it must be of the same form as the protobuf
message :class:`~google.cloud.oslogin_v1.types.SshPublicKey`
Expand Down
24 changes: 12 additions & 12 deletions google/cloud/oslogin_v1/gapic/os_login_service_client_config.py
Expand Up @@ -10,41 +10,41 @@
"initial_retry_delay_millis": 100,
"retry_delay_multiplier": 1.3,
"max_retry_delay_millis": 60000,
"initial_rpc_timeout_millis": 10000,
"initial_rpc_timeout_millis": 20000,
"rpc_timeout_multiplier": 1.0,
"max_rpc_timeout_millis": 10000,
"max_rpc_timeout_millis": 20000,
"total_timeout_millis": 600000,
}
},
"methods": {
"DeletePosixAccount": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"DeleteSshPublicKey": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"GetLoginProfile": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"GetSshPublicKey": {
"timeout_millis": 10000,
"timeout_millis": 60000,
"retry_codes_name": "idempotent",
"retry_params_name": "default",
},
"ImportSshPublicKey": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
"UpdateSshPublicKey": {
"timeout_millis": 10000,
"retry_codes_name": "idempotent",
"timeout_millis": 60000,
"retry_codes_name": "non_idempotent",
"retry_params_name": "default",
},
},
Expand Down
Expand Up @@ -33,9 +33,7 @@ class OsLoginServiceGrpcTransport(object):
# in this service.
_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",
)

def __init__(
Expand Down

0 comments on commit f903af4

Please sign in to comment.