diff --git a/packages/google-cloud-os-login/docs/conf.py b/packages/google-cloud-os-login/docs/conf.py index 1ff2461b145d..f89c52b7fd97 100644 --- a/packages/google-cloud-os-login/docs/conf.py +++ b/packages/google-cloud-os-login/docs/conf.py @@ -18,50 +18,50 @@ # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the # documentation root, use os.path.abspath to make it absolute, like shown here. -sys.path.insert(0, os.path.abspath('..')) +sys.path.insert(0, os.path.abspath("..")) -__version__ = '0.1.0' +__version__ = "0.1.0" # -- General configuration ------------------------------------------------ # If your documentation needs a minimal Sphinx version, state it here. -#needs_sphinx = '1.0' +# needs_sphinx = '1.0' # Add any Sphinx extension module names here, as strings. They can be # extensions coming with Sphinx (named 'sphinx.ext.*') or your custom # ones. extensions = [ - 'sphinx.ext.autodoc', - 'sphinx.ext.autosummary', - 'sphinx.ext.intersphinx', - 'sphinx.ext.coverage', - 'sphinx.ext.napoleon', - 'sphinx.ext.viewcode', + "sphinx.ext.autodoc", + "sphinx.ext.autosummary", + "sphinx.ext.intersphinx", + "sphinx.ext.coverage", + "sphinx.ext.napoleon", + "sphinx.ext.viewcode", ] # autodoc/autosummary flags -autoclass_content = 'both' -autodoc_default_flags = ['members'] +autoclass_content = "both" +autodoc_default_flags = ["members"] autosummary_generate = True # Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] +templates_path = ["_templates"] # The suffix(es) of source filenames. # You can specify multiple suffix as a list of string: # source_suffix = ['.rst', '.md'] -source_suffix = '.rst' +source_suffix = ".rst" # The encoding of source files. -#source_encoding = 'utf-8-sig' +# source_encoding = 'utf-8-sig' # The master toctree document. -master_doc = 'index' +master_doc = "index" # General information about the project. -project = u'google-cloud-os-login' -copyright = u'2018 Google LLC' -author = u'Google APIs' +project = u"google-cloud-os-login" +copyright = u"2018 Google LLC" +author = u"Google APIs" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the @@ -70,7 +70,7 @@ # The full version, including alpha/beta/rc tags. release = __version__ # The short X.Y version. -version = '.'.join(release.split('.')[0:2]) +version = ".".join(release.split(".")[0:2]) # The language for content autogenerated by Sphinx. Refer to documentation # for a list of supported languages. @@ -81,37 +81,37 @@ # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: -#today = '' +# today = '' # Else, today_fmt is used as the format for a strftime call. -#today_fmt = '%B %d, %Y' +# today_fmt = '%B %d, %Y' # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = ['_build'] +exclude_patterns = ["_build"] # The reST default role (used for this markup: `text`) to use for all # documents. -#default_role = None +# default_role = None # If true, '()' will be appended to :func: etc. cross-reference text. -#add_function_parentheses = True +# add_function_parentheses = True # If true, the current module name will be prepended to all description # unit titles (such as .. function::). -#add_module_names = True +# add_module_names = True # If true, sectionauthor and moduleauthor directives will be shown in the # output. They are ignored by default. -#show_authors = False +# show_authors = False # The name of the Pygments (syntax highlighting) style to use. -pygments_style = 'sphinx' +pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -#modindex_common_prefix = [] +# modindex_common_prefix = [] # If true, keep warnings as "system message" paragraphs in the built documents. -#keep_warnings = False +# keep_warnings = False # If true, `todo` and `todoList` produce output, else they produce nothing. todo_include_todos = True @@ -120,31 +120,31 @@ # The theme to use for HTML and HTML Help pages. See the documentation for # a list of builtin themes. -html_theme = 'sphinx_rtd_theme' +html_theme = "sphinx_rtd_theme" # Theme options are theme-specific and customize the look and feel of a theme # further. For a list of options available for each theme, see the # documentation. -#html_theme_options = {} +# html_theme_options = {} # Add any paths that contain custom themes here, relative to this directory. -#html_theme_path = [] +# html_theme_path = [] # The name for this set of Sphinx documents. If None, it defaults to # " v documentation". -#html_title = None +# html_title = None # A shorter title for the navigation bar. Default is the same as html_title. -#html_short_title = None +# html_short_title = None # The name of an image file (relative to this directory) to place at the top # of the sidebar. -#html_logo = None +# html_logo = None # The name of an image file (within the static path) to use as favicon of the # docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 # pixels large. -#html_favicon = None +# html_favicon = None # Add any paths that contain custom static files (such as style sheets) here, # relative to this directory. They are copied after the builtin static files, @@ -154,78 +154,75 @@ # Add any extra paths that contain custom files (such as robots.txt or # .htaccess) here, relative to this directory. These files are copied # directly to the root of the documentation. -#html_extra_path = [] +# html_extra_path = [] # If not '', a 'Last updated on:' timestamp is inserted at every page bottom, # using the given strftime format. -#html_last_updated_fmt = '%b %d, %Y' +# html_last_updated_fmt = '%b %d, %Y' # If true, SmartyPants will be used to convert quotes and dashes to # typographically correct entities. -#html_use_smartypants = True +# html_use_smartypants = True # Custom sidebar templates, maps document names to template names. -#html_sidebars = {} +# html_sidebars = {} # Additional templates that should be rendered to pages, maps page names to # template names. -#html_additional_pages = {} +# html_additional_pages = {} # If false, no module index is generated. -#html_domain_indices = True +# html_domain_indices = True # If false, no index is generated. -#html_use_index = True +# html_use_index = True # If true, the index is split into individual pages for each letter. -#html_split_index = False +# html_split_index = False # If true, links to the reST sources are added to the pages. -#html_show_sourcelink = True +# html_show_sourcelink = True # If true, "Created using Sphinx" is shown in the HTML footer. Default is True. -#html_show_sphinx = True +# html_show_sphinx = True # If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. -#html_show_copyright = True +# html_show_copyright = True # If true, an OpenSearch description file will be output, and all pages will # contain a tag referring to it. The value of this option must be the # base URL from which the finished HTML is served. -#html_use_opensearch = '' +# html_use_opensearch = '' # This is the file name suffix for HTML files (e.g. ".xhtml"). -#html_file_suffix = None +# html_file_suffix = None # Language to be used for generating the HTML full-text search index. # Sphinx supports the following languages: # 'da', 'de', 'en', 'es', 'fi', 'fr', 'hu', 'it', 'ja' # 'nl', 'no', 'pt', 'ro', 'ru', 'sv', 'tr' -#html_search_language = 'en' +# html_search_language = 'en' # A dictionary with options for the search language support, empty by default. # Now only 'ja' uses this config value -#html_search_options = {'type': 'default'} +# html_search_options = {'type': 'default'} # The name of a javascript file (relative to the configuration directory) that # implements a search results scorer. If empty, the default will be used. -#html_search_scorer = 'scorer.js' +# html_search_scorer = 'scorer.js' # Output file base name for HTML help builder. -htmlhelp_basename = 'google-cloud-os-login-doc' +htmlhelp_basename = "google-cloud-os-login-doc" # -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). #'papersize': 'letterpaper', - # The font size ('10pt', '11pt' or '12pt'). #'pointsize': '10pt', - # Additional stuff for the LaTeX preamble. #'preamble': '', - # Latex figure (float) alignment #'figure_align': 'htbp', } @@ -234,39 +231,51 @@ # (source start file, target name, title, # author, documentclass [howto, manual, or own class]). latex_documents = [ - (master_doc, 'google-cloud-os-login.tex', - u'google-cloud-os-login Documentation', author, 'manual'), + ( + master_doc, + "google-cloud-os-login.tex", + u"google-cloud-os-login Documentation", + author, + "manual", + ) ] # The name of an image file (relative to this directory) to place at the top of # the title page. -#latex_logo = None +# latex_logo = None # For "manual" documents, if this is true, then toplevel headings are parts, # not chapters. -#latex_use_parts = False +# latex_use_parts = False # If true, show page references after internal links. -#latex_show_pagerefs = False +# latex_show_pagerefs = False # If true, show URL addresses after external links. -#latex_show_urls = False +# latex_show_urls = False # Documents to append as an appendix to all manuals. -#latex_appendices = [] +# latex_appendices = [] # If false, no module index is generated. -#latex_domain_indices = True +# latex_domain_indices = True # -- Options for manual page output --------------------------------------- # One entry per manual page. List of tuples # (source start file, name, description, authors, manual section). -man_pages = [(master_doc, 'google-cloud-os-login', - u'google-cloud-os-login Documentation', [author], 1)] +man_pages = [ + ( + master_doc, + "google-cloud-os-login", + u"google-cloud-os-login Documentation", + [author], + 1, + ) +] # If true, show URL addresses after external links. -#man_show_urls = False +# man_show_urls = False # -- Options for Texinfo output ------------------------------------------- @@ -274,27 +283,33 @@ # (source start file, target name, title, author, # dir menu entry, description, category) texinfo_documents = [ - (master_doc, 'google-cloud-os-login', - u'google-cloud-os-login Documentation', author, 'google-cloud-os-login', - 'GAPIC library for the {metadata.shortName} v1 service', 'APIs'), + ( + master_doc, + "google-cloud-os-login", + u"google-cloud-os-login Documentation", + author, + "google-cloud-os-login", + "GAPIC library for the {metadata.shortName} v1 service", + "APIs", + ) ] # Documents to append as an appendix to all manuals. -#texinfo_appendices = [] +# texinfo_appendices = [] # If false, no module index is generated. -#texinfo_domain_indices = True +# texinfo_domain_indices = True # How to display URL addresses: 'footnote', 'no', or 'inline'. -#texinfo_show_urls = 'footnote' +# texinfo_show_urls = 'footnote' # If true, do not generate a @detailmenu in the "Top" node's menu. -#texinfo_no_detailmenu = False +# texinfo_no_detailmenu = False # Example configuration for intersphinx: refer to the Python standard library. intersphinx_mapping = { - 'python': ('http://python.readthedocs.org/en/latest/', None), - 'gax': ('https://gax-python.readthedocs.org/en/latest/', None), + "python": ("http://python.readthedocs.org/en/latest/", None), + "gax": ("https://gax-python.readthedocs.org/en/latest/", None), } # Napoleon settings diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/os_login_service_client.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/os_login_service_client.py index 46836f5b176b..fd29cddf1430 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/os_login_service_client.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/os_login_service_client.py @@ -34,8 +34,7 @@ from google.protobuf import empty_pb2 from google.protobuf import field_mask_pb2 -_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution( - 'google-cloud-os-login', ).version +_GAPIC_LIBRARY_VERSION = pkg_resources.get_distribution("google-cloud-os-login").version class OsLoginServiceClient(object): @@ -46,12 +45,12 @@ class OsLoginServiceClient(object): public keys for logging into virtual machines on Google Cloud Platform. """ - SERVICE_ADDRESS = 'oslogin.googleapis.com:443' + SERVICE_ADDRESS = "oslogin.googleapis.com:443" """The default address of the service.""" # The name of the interface for this client. This is the key used to # find the method configuration in the client_config dictionary. - _INTERFACE_NAME = 'google.cloud.oslogin.v1.OsLoginService' + _INTERFACE_NAME = "google.cloud.oslogin.v1.OsLoginService" @classmethod def from_service_account_file(cls, filename, *args, **kwargs): @@ -67,9 +66,8 @@ def from_service_account_file(cls, filename, *args, **kwargs): Returns: OsLoginServiceClient: The constructed client. """ - credentials = service_account.Credentials.from_service_account_file( - filename) - kwargs['credentials'] = credentials + credentials = service_account.Credentials.from_service_account_file(filename) + kwargs["credentials"] = credentials return cls(*args, **kwargs) from_service_account_json = from_service_account_file @@ -77,35 +75,32 @@ def from_service_account_file(cls, filename, *args, **kwargs): @classmethod def user_path(cls, user): """Return a fully-qualified user string.""" - return google.api_core.path_template.expand( - 'users/{user}', - user=user, - ) + return google.api_core.path_template.expand("users/{user}", user=user) @classmethod def project_path(cls, user, project): """Return a fully-qualified project string.""" return google.api_core.path_template.expand( - 'users/{user}/projects/{project}', - user=user, - project=project, + "users/{user}/projects/{project}", user=user, project=project ) @classmethod def fingerprint_path(cls, user, fingerprint): """Return a fully-qualified fingerprint string.""" return google.api_core.path_template.expand( - 'users/{user}/sshPublicKeys/{fingerprint}', + "users/{user}/sshPublicKeys/{fingerprint}", user=user, fingerprint=fingerprint, ) - def __init__(self, - transport=None, - channel=None, - credentials=None, - client_config=None, - client_info=None): + def __init__( + self, + transport=None, + channel=None, + credentials=None, + client_config=None, + client_info=None, + ): """Constructor. Args: @@ -139,18 +134,19 @@ def __init__(self, # Raise deprecation warnings for things we want to go away. if client_config is not None: warnings.warn( - 'The `client_config` argument is deprecated.', + "The `client_config` argument is deprecated.", PendingDeprecationWarning, - stacklevel=2) + stacklevel=2, + ) else: client_config = os_login_service_client_config.config if channel: warnings.warn( - 'The `channel` argument is deprecated; use ' - '`transport` instead.', + "The `channel` argument is deprecated; use " "`transport` instead.", PendingDeprecationWarning, - stacklevel=2) + stacklevel=2, + ) # Instantiate the transport. # The transport is responsible for handling serialization and @@ -159,25 +155,24 @@ def __init__(self, if callable(transport): self.transport = transport( credentials=credentials, - default_class=os_login_service_grpc_transport. - OsLoginServiceGrpcTransport, + default_class=os_login_service_grpc_transport.OsLoginServiceGrpcTransport, ) else: if credentials: raise ValueError( - 'Received both a transport instance and ' - 'credentials; these are mutually exclusive.') + "Received both a transport instance and " + "credentials; these are mutually exclusive." + ) self.transport = transport else: self.transport = os_login_service_grpc_transport.OsLoginServiceGrpcTransport( - address=self.SERVICE_ADDRESS, - channel=channel, - credentials=credentials, + address=self.SERVICE_ADDRESS, channel=channel, credentials=credentials ) if client_info is None: client_info = google.api_core.gapic_v1.client_info.ClientInfo( - gapic_version=_GAPIC_LIBRARY_VERSION, ) + gapic_version=_GAPIC_LIBRARY_VERSION + ) else: client_info.gapic_version = _GAPIC_LIBRARY_VERSION self._client_info = client_info @@ -187,7 +182,8 @@ def __init__(self, # (Ordinarily, these are the defaults specified in the `*_config.py` # file next to this one.) self._method_configs = google.api_core.gapic_v1.config.parse_method_configs( - client_config['interfaces'][self._INTERFACE_NAME], ) + client_config["interfaces"][self._INTERFACE_NAME] + ) # Save a dictionary of cached API call functions. # These are the actual callables which invoke the proper @@ -196,11 +192,13 @@ def __init__(self, self._inner_api_calls = {} # Service calls - def delete_posix_account(self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None): + def delete_posix_account( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): """ Deletes a POSIX account. @@ -234,26 +232,28 @@ def delete_posix_account(self, ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. - if 'delete_posix_account' not in self._inner_api_calls: + if "delete_posix_account" not in self._inner_api_calls: self._inner_api_calls[ - 'delete_posix_account'] = google.api_core.gapic_v1.method.wrap_method( - self.transport.delete_posix_account, - default_retry=self._method_configs['DeletePosixAccount']. - retry, - default_timeout=self._method_configs['DeletePosixAccount']. - timeout, - client_info=self._client_info, - ) + "delete_posix_account" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.delete_posix_account, + default_retry=self._method_configs["DeletePosixAccount"].retry, + default_timeout=self._method_configs["DeletePosixAccount"].timeout, + client_info=self._client_info, + ) - request = oslogin_pb2.DeletePosixAccountRequest(name=name, ) - self._inner_api_calls['delete_posix_account']( - request, retry=retry, timeout=timeout, metadata=metadata) + request = oslogin_pb2.DeletePosixAccountRequest(name=name) + self._inner_api_calls["delete_posix_account"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) - def delete_ssh_public_key(self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None): + def delete_ssh_public_key( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): """ Deletes an SSH public key. @@ -287,26 +287,28 @@ def delete_ssh_public_key(self, ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. - if 'delete_ssh_public_key' not in self._inner_api_calls: + if "delete_ssh_public_key" not in self._inner_api_calls: self._inner_api_calls[ - 'delete_ssh_public_key'] = google.api_core.gapic_v1.method.wrap_method( - self.transport.delete_ssh_public_key, - default_retry=self._method_configs['DeleteSshPublicKey']. - retry, - default_timeout=self._method_configs['DeleteSshPublicKey']. - timeout, - client_info=self._client_info, - ) + "delete_ssh_public_key" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.delete_ssh_public_key, + default_retry=self._method_configs["DeleteSshPublicKey"].retry, + default_timeout=self._method_configs["DeleteSshPublicKey"].timeout, + client_info=self._client_info, + ) - request = oslogin_pb2.DeleteSshPublicKeyRequest(name=name, ) - self._inner_api_calls['delete_ssh_public_key']( - request, retry=retry, timeout=timeout, metadata=metadata) + request = oslogin_pb2.DeleteSshPublicKeyRequest(name=name) + self._inner_api_calls["delete_ssh_public_key"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) - def get_login_profile(self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None): + def get_login_profile( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): """ Retrieves the profile information used for logging in to a virtual machine on Google Compute Engine. @@ -342,26 +344,28 @@ def get_login_profile(self, ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. - if 'get_login_profile' not in self._inner_api_calls: + if "get_login_profile" not in self._inner_api_calls: self._inner_api_calls[ - 'get_login_profile'] = google.api_core.gapic_v1.method.wrap_method( - self.transport.get_login_profile, - default_retry=self._method_configs['GetLoginProfile']. - retry, - default_timeout=self._method_configs['GetLoginProfile']. - timeout, - client_info=self._client_info, - ) + "get_login_profile" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_login_profile, + default_retry=self._method_configs["GetLoginProfile"].retry, + default_timeout=self._method_configs["GetLoginProfile"].timeout, + client_info=self._client_info, + ) - request = oslogin_pb2.GetLoginProfileRequest(name=name, ) - return self._inner_api_calls['get_login_profile']( - request, retry=retry, timeout=timeout, metadata=metadata) + request = oslogin_pb2.GetLoginProfileRequest(name=name) + return self._inner_api_calls["get_login_profile"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) - def get_ssh_public_key(self, - name, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None): + def get_ssh_public_key( + self, + name, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): """ Retrieves an SSH public key. @@ -398,28 +402,30 @@ def get_ssh_public_key(self, ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. - if 'get_ssh_public_key' not in self._inner_api_calls: + if "get_ssh_public_key" not in self._inner_api_calls: self._inner_api_calls[ - 'get_ssh_public_key'] = google.api_core.gapic_v1.method.wrap_method( - self.transport.get_ssh_public_key, - default_retry=self._method_configs['GetSshPublicKey']. - retry, - default_timeout=self._method_configs['GetSshPublicKey']. - timeout, - client_info=self._client_info, - ) + "get_ssh_public_key" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.get_ssh_public_key, + default_retry=self._method_configs["GetSshPublicKey"].retry, + default_timeout=self._method_configs["GetSshPublicKey"].timeout, + client_info=self._client_info, + ) + + request = oslogin_pb2.GetSshPublicKeyRequest(name=name) + return self._inner_api_calls["get_ssh_public_key"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) - request = oslogin_pb2.GetSshPublicKeyRequest(name=name, ) - return self._inner_api_calls['get_ssh_public_key']( - request, retry=retry, timeout=timeout, metadata=metadata) - - def import_ssh_public_key(self, - parent, - ssh_public_key, - project_id=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None): + def import_ssh_public_key( + self, + parent, + ssh_public_key, + project_id=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): """ Adds an SSH public key and returns the profile information. Default POSIX account information is set when no username and UID exist as part of the @@ -464,32 +470,32 @@ def import_ssh_public_key(self, ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. - if 'import_ssh_public_key' not in self._inner_api_calls: + if "import_ssh_public_key" not in self._inner_api_calls: self._inner_api_calls[ - 'import_ssh_public_key'] = google.api_core.gapic_v1.method.wrap_method( - self.transport.import_ssh_public_key, - default_retry=self._method_configs['ImportSshPublicKey']. - retry, - default_timeout=self._method_configs['ImportSshPublicKey']. - timeout, - client_info=self._client_info, - ) + "import_ssh_public_key" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.import_ssh_public_key, + default_retry=self._method_configs["ImportSshPublicKey"].retry, + default_timeout=self._method_configs["ImportSshPublicKey"].timeout, + client_info=self._client_info, + ) request = oslogin_pb2.ImportSshPublicKeyRequest( - parent=parent, - ssh_public_key=ssh_public_key, - project_id=project_id, + parent=parent, ssh_public_key=ssh_public_key, project_id=project_id ) - return self._inner_api_calls['import_ssh_public_key']( - request, retry=retry, timeout=timeout, metadata=metadata) - - def update_ssh_public_key(self, - name, - ssh_public_key, - update_mask=None, - retry=google.api_core.gapic_v1.method.DEFAULT, - timeout=google.api_core.gapic_v1.method.DEFAULT, - metadata=None): + return self._inner_api_calls["import_ssh_public_key"]( + request, retry=retry, timeout=timeout, metadata=metadata + ) + + def update_ssh_public_key( + self, + name, + ssh_public_key, + update_mask=None, + retry=google.api_core.gapic_v1.method.DEFAULT, + timeout=google.api_core.gapic_v1.method.DEFAULT, + metadata=None, + ): """ Updates an SSH public key and returns the profile information. This method supports patch semantics. @@ -538,21 +544,19 @@ def update_ssh_public_key(self, ValueError: If the parameters are invalid. """ # Wrap the transport method to add retry and timeout logic. - if 'update_ssh_public_key' not in self._inner_api_calls: + if "update_ssh_public_key" not in self._inner_api_calls: self._inner_api_calls[ - 'update_ssh_public_key'] = google.api_core.gapic_v1.method.wrap_method( - self.transport.update_ssh_public_key, - default_retry=self._method_configs['UpdateSshPublicKey']. - retry, - default_timeout=self._method_configs['UpdateSshPublicKey']. - timeout, - client_info=self._client_info, - ) + "update_ssh_public_key" + ] = google.api_core.gapic_v1.method.wrap_method( + self.transport.update_ssh_public_key, + default_retry=self._method_configs["UpdateSshPublicKey"].retry, + default_timeout=self._method_configs["UpdateSshPublicKey"].timeout, + client_info=self._client_info, + ) request = oslogin_pb2.UpdateSshPublicKeyRequest( - name=name, - ssh_public_key=ssh_public_key, - update_mask=update_mask, + name=name, ssh_public_key=ssh_public_key, update_mask=update_mask + ) + return self._inner_api_calls["update_ssh_public_key"]( + request, retry=retry, timeout=timeout, metadata=metadata ) - return self._inner_api_calls['update_ssh_public_key']( - request, retry=retry, timeout=timeout, metadata=metadata) diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/os_login_service_client_config.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/os_login_service_client_config.py index 73e359d62fb7..e55e7963358b 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/os_login_service_client_config.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/os_login_service_client_config.py @@ -3,7 +3,7 @@ "google.cloud.oslogin.v1.OsLoginService": { "retry_codes": { "idempotent": ["DEADLINE_EXCEEDED", "UNAVAILABLE"], - "non_idempotent": [] + "non_idempotent": [], }, "retry_params": { "default": { @@ -13,41 +13,41 @@ "initial_rpc_timeout_millis": 10000, "rpc_timeout_multiplier": 1.0, "max_rpc_timeout_millis": 10000, - "total_timeout_millis": 600000 + "total_timeout_millis": 600000, } }, "methods": { "DeletePosixAccount": { "timeout_millis": 10000, "retry_codes_name": "idempotent", - "retry_params_name": "default" + "retry_params_name": "default", }, "DeleteSshPublicKey": { "timeout_millis": 10000, "retry_codes_name": "idempotent", - "retry_params_name": "default" + "retry_params_name": "default", }, "GetLoginProfile": { "timeout_millis": 10000, "retry_codes_name": "idempotent", - "retry_params_name": "default" + "retry_params_name": "default", }, "GetSshPublicKey": { "timeout_millis": 10000, "retry_codes_name": "idempotent", - "retry_params_name": "default" + "retry_params_name": "default", }, "ImportSshPublicKey": { "timeout_millis": 10000, "retry_codes_name": "idempotent", - "retry_params_name": "default" + "retry_params_name": "default", }, "UpdateSshPublicKey": { "timeout_millis": 10000, "retry_codes_name": "idempotent", - "retry_params_name": "default" - } - } + "retry_params_name": "default", + }, + }, } } } diff --git a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/transports/os_login_service_grpc_transport.py b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/transports/os_login_service_grpc_transport.py index e3f5087daeb6..7651fe81f3a5 100644 --- a/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/transports/os_login_service_grpc_transport.py +++ b/packages/google-cloud-os-login/google/cloud/oslogin_v1/gapic/transports/os_login_service_grpc_transport.py @@ -27,19 +27,19 @@ class OsLoginServiceGrpcTransport(object): which can be used to take advantage of advanced features of gRPC. """ + # The scopes needed to make gRPC calls to all of the methods defined # 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', + "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__(self, - channel=None, - credentials=None, - address='oslogin.googleapis.com:443'): + def __init__( + self, channel=None, credentials=None, address="oslogin.googleapis.com:443" + ): """Instantiate the transport class. Args: @@ -57,29 +57,23 @@ def __init__(self, # exception (channels come with credentials baked in already). if channel is not None and credentials is not None: raise ValueError( - 'The `channel` and `credentials` arguments are mutually ' - 'exclusive.', ) + "The `channel` and `credentials` arguments are mutually " "exclusive." + ) # Create the channel. if channel is None: - channel = self.create_channel( - address=address, - credentials=credentials, - ) + channel = self.create_channel(address=address, credentials=credentials) self._channel = channel # gRPC uses objects called "stubs" that are bound to the # channel and provide a basic method for each RPC. self._stubs = { - 'os_login_service_stub': - oslogin_pb2_grpc.OsLoginServiceStub(channel), + "os_login_service_stub": oslogin_pb2_grpc.OsLoginServiceStub(channel) } @classmethod - def create_channel(cls, - address='oslogin.googleapis.com:443', - credentials=None): + def create_channel(cls, address="oslogin.googleapis.com:443", credentials=None): """Create and return a gRPC channel object. Args: @@ -94,9 +88,7 @@ def create_channel(cls, grpc.Channel: A gRPC channel object. """ return google.api_core.grpc_helpers.create_channel( - address, - credentials=credentials, - scopes=cls._OAUTH_SCOPES, + address, credentials=credentials, scopes=cls._OAUTH_SCOPES ) @property @@ -119,7 +111,7 @@ def delete_posix_account(self): deserialized request object and returns a deserialized response object. """ - return self._stubs['os_login_service_stub'].DeletePosixAccount + return self._stubs["os_login_service_stub"].DeletePosixAccount @property def delete_ssh_public_key(self): @@ -132,7 +124,7 @@ def delete_ssh_public_key(self): deserialized request object and returns a deserialized response object. """ - return self._stubs['os_login_service_stub'].DeleteSshPublicKey + return self._stubs["os_login_service_stub"].DeleteSshPublicKey @property def get_login_profile(self): @@ -146,7 +138,7 @@ def get_login_profile(self): deserialized request object and returns a deserialized response object. """ - return self._stubs['os_login_service_stub'].GetLoginProfile + return self._stubs["os_login_service_stub"].GetLoginProfile @property def get_ssh_public_key(self): @@ -159,7 +151,7 @@ def get_ssh_public_key(self): deserialized request object and returns a deserialized response object. """ - return self._stubs['os_login_service_stub'].GetSshPublicKey + return self._stubs["os_login_service_stub"].GetSshPublicKey @property def import_ssh_public_key(self): @@ -174,7 +166,7 @@ def import_ssh_public_key(self): deserialized request object and returns a deserialized response object. """ - return self._stubs['os_login_service_stub'].ImportSshPublicKey + return self._stubs["os_login_service_stub"].ImportSshPublicKey @property def update_ssh_public_key(self): @@ -188,4 +180,4 @@ def update_ssh_public_key(self): deserialized request object and returns a deserialized response object. """ - return self._stubs['os_login_service_stub'].UpdateSshPublicKey + return self._stubs["os_login_service_stub"].UpdateSshPublicKey diff --git a/packages/google-cloud-os-login/tests/unit/gapic/v1/test_os_login_service_client_v1.py b/packages/google-cloud-os-login/tests/unit/gapic/v1/test_os_login_service_client_v1.py index adcc91446e52..eabbc7d46712 100644 --- a/packages/google-cloud-os-login/tests/unit/gapic/v1/test_os_login_service_client_v1.py +++ b/packages/google-cloud-os-login/tests/unit/gapic/v1/test_os_login_service_client_v1.py @@ -52,10 +52,7 @@ def __init__(self, responses=[]): self.responses = responses self.requests = [] - def unary_unary(self, - method, - request_serializer=None, - response_deserializer=None): + def unary_unary(self, method, request_serializer=None, response_deserializer=None): return MultiCallableStub(method, self) @@ -66,13 +63,13 @@ class CustomException(Exception): class TestOsLoginServiceClient(object): def test_delete_posix_account(self): channel = ChannelStub() - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup Request - name = client.project_path('[USER]', '[PROJECT]') + name = client.project_path("[USER]", "[PROJECT]") client.delete_posix_account(name) @@ -84,26 +81,26 @@ def test_delete_posix_account(self): def test_delete_posix_account_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup request - name = client.project_path('[USER]', '[PROJECT]') + name = client.project_path("[USER]", "[PROJECT]") with pytest.raises(CustomException): client.delete_posix_account(name) def test_delete_ssh_public_key(self): channel = ChannelStub() - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup Request - name = client.fingerprint_path('[USER]', '[FINGERPRINT]') + name = client.fingerprint_path("[USER]", "[FINGERPRINT]") client.delete_ssh_public_key(name) @@ -115,33 +112,33 @@ def test_delete_ssh_public_key(self): def test_delete_ssh_public_key_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup request - name = client.fingerprint_path('[USER]', '[FINGERPRINT]') + name = client.fingerprint_path("[USER]", "[FINGERPRINT]") with pytest.raises(CustomException): client.delete_ssh_public_key(name) def test_get_login_profile(self): # Setup Expected Response - name_2 = 'name2-1052831874' + name_2 = "name2-1052831874" suspended = False - expected_response = {'name': name_2, 'suspended': suspended} + expected_response = {"name": name_2, "suspended": suspended} expected_response = oslogin_pb2.LoginProfile(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup Request - name = client.user_path('[USER]') + name = client.user_path("[USER]") response = client.get_login_profile(name) assert expected_response == response @@ -154,38 +151,38 @@ def test_get_login_profile(self): def test_get_login_profile_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup request - name = client.user_path('[USER]') + name = client.user_path("[USER]") with pytest.raises(CustomException): client.get_login_profile(name) def test_get_ssh_public_key(self): # Setup Expected Response - key = 'key106079' + key = "key106079" expiration_time_usec = 2058878882 - fingerprint = 'fingerprint-1375934236' + fingerprint = "fingerprint-1375934236" expected_response = { - 'key': key, - 'expiration_time_usec': expiration_time_usec, - 'fingerprint': fingerprint + "key": key, + "expiration_time_usec": expiration_time_usec, + "fingerprint": fingerprint, } expected_response = common_pb2.SshPublicKey(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup Request - name = client.fingerprint_path('[USER]', '[FINGERPRINT]') + name = client.fingerprint_path("[USER]", "[FINGERPRINT]") response = client.get_ssh_public_key(name) assert expected_response == response @@ -198,13 +195,13 @@ def test_get_ssh_public_key(self): def test_get_ssh_public_key_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup request - name = client.fingerprint_path('[USER]', '[FINGERPRINT]') + name = client.fingerprint_path("[USER]", "[FINGERPRINT]") with pytest.raises(CustomException): client.get_ssh_public_key(name) @@ -212,18 +209,17 @@ def test_get_ssh_public_key_exception(self): def test_import_ssh_public_key(self): # Setup Expected Response expected_response = {} - expected_response = oslogin_pb2.ImportSshPublicKeyResponse( - **expected_response) + expected_response = oslogin_pb2.ImportSshPublicKeyResponse(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup Request - parent = client.user_path('[USER]') + parent = client.user_path("[USER]") ssh_public_key = {} response = client.import_ssh_public_key(parent, ssh_public_key) @@ -231,20 +227,21 @@ def test_import_ssh_public_key(self): assert len(channel.requests) == 1 expected_request = oslogin_pb2.ImportSshPublicKeyRequest( - parent=parent, ssh_public_key=ssh_public_key) + parent=parent, ssh_public_key=ssh_public_key + ) actual_request = channel.requests[0][1] assert expected_request == actual_request def test_import_ssh_public_key_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup request - parent = client.user_path('[USER]') + parent = client.user_path("[USER]") ssh_public_key = {} with pytest.raises(CustomException): @@ -252,25 +249,25 @@ def test_import_ssh_public_key_exception(self): def test_update_ssh_public_key(self): # Setup Expected Response - key = 'key106079' + key = "key106079" expiration_time_usec = 2058878882 - fingerprint = 'fingerprint-1375934236' + fingerprint = "fingerprint-1375934236" expected_response = { - 'key': key, - 'expiration_time_usec': expiration_time_usec, - 'fingerprint': fingerprint + "key": key, + "expiration_time_usec": expiration_time_usec, + "fingerprint": fingerprint, } expected_response = common_pb2.SshPublicKey(**expected_response) # Mock the API response channel = ChannelStub(responses=[expected_response]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup Request - name = client.fingerprint_path('[USER]', '[FINGERPRINT]') + name = client.fingerprint_path("[USER]", "[FINGERPRINT]") ssh_public_key = {} response = client.update_ssh_public_key(name, ssh_public_key) @@ -278,20 +275,21 @@ def test_update_ssh_public_key(self): assert len(channel.requests) == 1 expected_request = oslogin_pb2.UpdateSshPublicKeyRequest( - name=name, ssh_public_key=ssh_public_key) + name=name, ssh_public_key=ssh_public_key + ) actual_request = channel.requests[0][1] assert expected_request == actual_request def test_update_ssh_public_key_exception(self): # Mock the API response channel = ChannelStub(responses=[CustomException()]) - patch = mock.patch('google.api_core.grpc_helpers.create_channel') + patch = mock.patch("google.api_core.grpc_helpers.create_channel") with patch as create_channel: create_channel.return_value = channel client = oslogin_v1.OsLoginServiceClient() # Setup request - name = client.fingerprint_path('[USER]', '[FINGERPRINT]') + name = client.fingerprint_path("[USER]", "[FINGERPRINT]") ssh_public_key = {} with pytest.raises(CustomException):