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

Commit

Permalink
Browse files Browse the repository at this point in the history
feat: add state field in resources (#8)
* chore: upgrade gapic-generator-python to 0.40.5

PiperOrigin-RevId: 354996675

Source-Author: Google APIs <noreply@google.com>
Source-Date: Mon Feb 1 12:11:49 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 20712b8fe95001b312f62c6c5f33e3e3ec92cfaf
Source-Link: googleapis/googleapis@20712b8

* feat: Add state field in resources

PiperOrigin-RevId: 355488930

Source-Author: Google APIs <noreply@google.com>
Source-Date: Wed Feb 3 14:55:32 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 5e27c5cafe0952f50ff81552526b3e3d333ef2c3
Source-Link: googleapis/googleapis@5e27c5c

* chore: update gapic-generator-python

PiperOrigin-RevId: 355923884

Source-Author: Google APIs <noreply@google.com>
Source-Date: Fri Feb 5 14:04:52 2021 -0800
Source-Repo: googleapis/googleapis
Source-Sha: 5e3dacee19405529b841b53797df799c2383536c
Source-Link: googleapis/googleapis@5e3dace

* chore(python): include py.typed files in release

A py.typed file must be included in the released package for it to be considered typed by type checkers. https://www.python.org/dev/peps/pep-0561/#packaging-type-information. See googleapis/python-secret-manager#79

Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
Source-Date: Fri Feb 5 17:32:06 2021 -0700
Source-Repo: googleapis/synthtool
Source-Sha: 33366574ffb9e11737b3547eb6f020ecae0536e8
Source-Link: googleapis/synthtool@3336657

* docs: update python contributing guide

Adds details about blacken, updates version for system tests,
and shows how to pass through pytest arguments.

Source-Author: Chris Cotter <cjcotter@google.com>
Source-Date: Mon Feb 8 17:13:36 2021 -0500
Source-Repo: googleapis/synthtool
Source-Sha: 4679e7e415221f03ff2a71e3ffad75b9ec41d87e
Source-Link: googleapis/synthtool@4679e7e

* build(python): enable flakybot on library unit and system tests

Source-Author: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
Source-Date: Wed Feb 17 14:10:46 2021 -0700
Source-Repo: googleapis/synthtool
Source-Sha: d17674372e27fb8f23013935e794aa37502071aa
Source-Link: googleapis/synthtool@d176743

Co-authored-by: Bu Sun Kim <8822365+busunkim96@users.noreply.github.com>
  • Loading branch information
yoshi-automation and busunkim96 committed Feb 25, 2021
1 parent b122347 commit edb1e0f
Show file tree
Hide file tree
Showing 16 changed files with 290 additions and 156 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Expand Up @@ -50,8 +50,10 @@ docs.metadata

# Virtual environment
env/

# Test logs
coverage.xml
sponge_log.xml
*sponge_log.xml

# System test environment variables.
system_tests/local_test_setup
Expand Down
10 changes: 10 additions & 0 deletions .kokoro/build.sh
Expand Up @@ -40,6 +40,16 @@ python3 -m pip uninstall --yes --quiet nox-automation
python3 -m pip install --upgrade --quiet nox
python3 -m nox --version

# If this is a continuous build, send the test log to the FlakyBot.
# See https://github.com/googleapis/repo-automation-bots/tree/master/packages/flakybot.
if [[ $KOKORO_BUILD_ARTIFACTS_SUBDIR = *"continuous"* ]]; then
cleanup() {
chmod +x $KOKORO_GFILE_DIR/linux_amd64/flakybot
$KOKORO_GFILE_DIR/linux_amd64/flakybot
}
trap cleanup EXIT HUP
fi

# If NOX_SESSION is set, it only runs the specified session,
# otherwise run all the sessions.
if [[ -n "${NOX_SESSION:-}" ]]; then
Expand Down
22 changes: 18 additions & 4 deletions CONTRIBUTING.rst
Expand Up @@ -70,9 +70,14 @@ We use `nox <https://nox.readthedocs.io/en/latest/>`__ to instrument our tests.
- To test your changes, run unit tests with ``nox``::

$ nox -s unit-2.7
$ nox -s unit-3.7
$ nox -s unit-3.8
$ ...

- Args to pytest can be passed through the nox command separated by a `--`. For
example, to run a single test::

$ nox -s unit-3.8 -- -k <name of test>

.. note::

The unit tests and system tests are described in the
Expand All @@ -93,8 +98,12 @@ On Debian/Ubuntu::
************
Coding Style
************
- We use the automatic code formatter ``black``. You can run it using
the nox session ``blacken``. This will eliminate many lint errors. Run via::

$ nox -s blacken

- PEP8 compliance, with exceptions defined in the linter configuration.
- PEP8 compliance is required, with exceptions defined in the linter configuration.
If you have ``nox`` installed, you can test that you have not introduced
any non-compliant code via::

Expand Down Expand Up @@ -133,13 +142,18 @@ Running System Tests

- To run system tests, you can execute::

$ nox -s system-3.7
# Run all system tests
$ nox -s system-3.8
$ nox -s system-2.7

# Run a single system test
$ nox -s system-3.8 -- -k <name of test>


.. note::

System tests are only configured to run under Python 2.7 and
Python 3.7. For expediency, we do not run them in older versions
Python 3.8. For expediency, we do not run them in older versions
of Python 3.

This alone will not run the tests. You'll need to change some local
Expand Down
4 changes: 2 additions & 2 deletions MANIFEST.in
Expand Up @@ -16,10 +16,10 @@

# Generated by synthtool. DO NOT EDIT!
include README.rst LICENSE
recursive-include google *.json *.proto
recursive-include google *.json *.proto py.typed
recursive-include tests *
global-exclude *.py[co]
global-exclude __pycache__

# Exclude scripts for samples readmegen
prune scripts/readme-gen
prune scripts/readme-gen
2 changes: 2 additions & 0 deletions google/cloud/networkconnectivity/__init__.py
Expand Up @@ -35,6 +35,7 @@
from google.cloud.networkconnectivity_v1alpha1.types.hub import ListSpokesResponse
from google.cloud.networkconnectivity_v1alpha1.types.hub import RouterApplianceInstance
from google.cloud.networkconnectivity_v1alpha1.types.hub import Spoke
from google.cloud.networkconnectivity_v1alpha1.types.hub import State
from google.cloud.networkconnectivity_v1alpha1.types.hub import UpdateHubRequest
from google.cloud.networkconnectivity_v1alpha1.types.hub import UpdateSpokeRequest

Expand All @@ -55,6 +56,7 @@
"OperationMetadata",
"RouterApplianceInstance",
"Spoke",
"State",
"UpdateHubRequest",
"UpdateSpokeRequest",
)
2 changes: 2 additions & 0 deletions google/cloud/networkconnectivity_v1alpha1/__init__.py
Expand Up @@ -30,6 +30,7 @@
from .types.hub import ListSpokesResponse
from .types.hub import RouterApplianceInstance
from .types.hub import Spoke
from .types.hub import State
from .types.hub import UpdateHubRequest
from .types.hub import UpdateSpokeRequest

Expand All @@ -49,6 +50,7 @@
"OperationMetadata",
"RouterApplianceInstance",
"Spoke",
"State",
"UpdateHubRequest",
"UpdateSpokeRequest",
"HubServiceClient",
Expand Down
Expand Up @@ -44,8 +44,8 @@


class HubServiceAsyncClient:
"""Connectivity Hub is a hub-and-spoke abstraction for network
connectivity management in Google Cloud. The Hub aims to reduce
"""Network Connectivity Center is a hub-and-spoke abstraction
for network connectivity management in Google Cloud. It reduces
operational complexity through a simple, centralized
connectivity management model.
"""
Expand Down Expand Up @@ -272,13 +272,13 @@ async def get_hub(
Returns:
google.cloud.networkconnectivity_v1alpha1.types.Hub:
The Connectivity Hub is a hub-and-
poke abstraction for network
Network Connectivity Center is a hub-
nd-spoke abstraction for network
connectivity management in Google Cloud.
It aims to reduce operational complexity
It reduces operational complexity
through a simple, centralized
connectivity management model. Here is
the resource message of a Hub.
connectivity management model. Following
is the resource message of a hub.
"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -369,11 +369,11 @@ async def create_hub(
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.
The result type for the operation will be :class:`google.cloud.networkconnectivity_v1alpha1.types.Hub` The Connectivity Hub is a hub-and-spoke abstraction for network connectivity
management in Google Cloud. It aims to reduce
operational complexity through a simple, centralized
connectivity management model. Here is the resource
message of a Hub.
The result type for the operation will be :class:`google.cloud.networkconnectivity_v1alpha1.types.Hub` Network Connectivity Center is a hub-and-spoke abstraction for
network connectivity management in Google Cloud. It
reduces operational complexity through a simple,
centralized connectivity management model. Following
is the resource message of a hub.
"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -472,11 +472,11 @@ async def update_hub(
google.api_core.operation_async.AsyncOperation:
An object representing a long-running operation.
The result type for the operation will be :class:`google.cloud.networkconnectivity_v1alpha1.types.Hub` The Connectivity Hub is a hub-and-spoke abstraction for network connectivity
management in Google Cloud. It aims to reduce
operational complexity through a simple, centralized
connectivity management model. Here is the resource
message of a Hub.
The result type for the operation will be :class:`google.cloud.networkconnectivity_v1alpha1.types.Hub` Network Connectivity Center is a hub-and-spoke abstraction for
network connectivity management in Google Cloud. It
reduces operational complexity through a simple,
centralized connectivity management model. Following
is the resource message of a hub.
"""
# Create or coerce a protobuf request object.
Expand Down
Expand Up @@ -79,8 +79,8 @@ def get_transport_class(cls, label: str = None,) -> Type[HubServiceTransport]:


class HubServiceClient(metaclass=HubServiceClientMeta):
"""Connectivity Hub is a hub-and-spoke abstraction for network
connectivity management in Google Cloud. The Hub aims to reduce
"""Network Connectivity Center is a hub-and-spoke abstraction
for network connectivity management in Google Cloud. It reduces
operational complexity through a simple, centralized
connectivity management model.
"""
Expand Down Expand Up @@ -359,21 +359,17 @@ def __init__(
util.strtobool(os.getenv("GOOGLE_API_USE_CLIENT_CERTIFICATE", "false"))
)

ssl_credentials = None
client_cert_source_func = None
is_mtls = False
if use_client_cert:
if client_options.client_cert_source:
import grpc # type: ignore

cert, key = client_options.client_cert_source()
ssl_credentials = grpc.ssl_channel_credentials(
certificate_chain=cert, private_key=key
)
is_mtls = True
client_cert_source_func = client_options.client_cert_source
else:
creds = SslCredentials()
is_mtls = creds.is_mtls
ssl_credentials = creds.ssl_credentials if is_mtls else None
is_mtls = mtls.has_default_client_cert_source()
client_cert_source_func = (
mtls.default_client_cert_source() if is_mtls else None
)

# Figure out which api endpoint to use.
if client_options.api_endpoint is not None:
Expand Down Expand Up @@ -416,7 +412,7 @@ def __init__(
credentials_file=client_options.credentials_file,
host=api_endpoint,
scopes=client_options.scopes,
ssl_channel_credentials=ssl_credentials,
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
)
Expand Down Expand Up @@ -536,13 +532,13 @@ def get_hub(
Returns:
google.cloud.networkconnectivity_v1alpha1.types.Hub:
The Connectivity Hub is a hub-and-
poke abstraction for network
Network Connectivity Center is a hub-
nd-spoke abstraction for network
connectivity management in Google Cloud.
It aims to reduce operational complexity
It reduces operational complexity
through a simple, centralized
connectivity management model. Here is
the resource message of a Hub.
connectivity management model. Following
is the resource message of a hub.
"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -634,11 +630,11 @@ def create_hub(
google.api_core.operation.Operation:
An object representing a long-running operation.
The result type for the operation will be :class:`google.cloud.networkconnectivity_v1alpha1.types.Hub` The Connectivity Hub is a hub-and-spoke abstraction for network connectivity
management in Google Cloud. It aims to reduce
operational complexity through a simple, centralized
connectivity management model. Here is the resource
message of a Hub.
The result type for the operation will be :class:`google.cloud.networkconnectivity_v1alpha1.types.Hub` Network Connectivity Center is a hub-and-spoke abstraction for
network connectivity management in Google Cloud. It
reduces operational complexity through a simple,
centralized connectivity management model. Following
is the resource message of a hub.
"""
# Create or coerce a protobuf request object.
Expand Down Expand Up @@ -738,11 +734,11 @@ def update_hub(
google.api_core.operation.Operation:
An object representing a long-running operation.
The result type for the operation will be :class:`google.cloud.networkconnectivity_v1alpha1.types.Hub` The Connectivity Hub is a hub-and-spoke abstraction for network connectivity
management in Google Cloud. It aims to reduce
operational complexity through a simple, centralized
connectivity management model. Here is the resource
message of a Hub.
The result type for the operation will be :class:`google.cloud.networkconnectivity_v1alpha1.types.Hub` Network Connectivity Center is a hub-and-spoke abstraction for
network connectivity management in Google Cloud. It
reduces operational complexity through a simple,
centralized connectivity management model. Following
is the resource message of a hub.
"""
# Create or coerce a protobuf request object.
Expand Down
Expand Up @@ -15,7 +15,16 @@
# limitations under the License.
#

from typing import Any, AsyncIterable, Awaitable, Callable, Iterable, Sequence, Tuple
from typing import (
Any,
AsyncIterable,
Awaitable,
Callable,
Iterable,
Sequence,
Tuple,
Optional,
)

from google.cloud.networkconnectivity_v1alpha1.types import hub

Expand Down
Expand Up @@ -37,8 +37,8 @@
class HubServiceGrpcTransport(HubServiceTransport):
"""gRPC backend transport for HubService.
Connectivity Hub is a hub-and-spoke abstraction for network
connectivity management in Google Cloud. The Hub aims to reduce
Network Connectivity Center is a hub-and-spoke abstraction
for network connectivity management in Google Cloud. It reduces
operational complexity through a simple, centralized
connectivity management model.
Expand All @@ -63,6 +63,7 @@ def __init__(
api_mtls_endpoint: str = None,
client_cert_source: Callable[[], Tuple[bytes, bytes]] = None,
ssl_channel_credentials: grpc.ChannelCredentials = None,
client_cert_source_for_mtls: Callable[[], Tuple[bytes, bytes]] = None,
quota_project_id: Optional[str] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
Expand Down Expand Up @@ -93,6 +94,10 @@ def __init__(
``api_mtls_endpoint`` is None.
ssl_channel_credentials (grpc.ChannelCredentials): SSL credentials
for grpc channel. It is ignored if ``channel`` is provided.
client_cert_source_for_mtls (Optional[Callable[[], Tuple[bytes, bytes]]]):
A callback to provide client certificate bytes and private key bytes,
both in PEM format. It is used to configure mutual TLS channel. It is
ignored if ``channel`` or ``ssl_channel_credentials`` is provided.
quota_project_id (Optional[str]): An optional project to use for billing
and quota.
client_info (google.api_core.gapic_v1.client_info.ClientInfo):
Expand All @@ -109,6 +114,11 @@ def __init__(
"""
self._ssl_channel_credentials = ssl_channel_credentials

if api_mtls_endpoint:
warnings.warn("api_mtls_endpoint is deprecated", DeprecationWarning)
if client_cert_source:
warnings.warn("client_cert_source is deprecated", DeprecationWarning)

if channel:
# Sanity check: Ensure that channel and credentials are not both
# provided.
Expand All @@ -118,11 +128,6 @@ def __init__(
self._grpc_channel = channel
self._ssl_channel_credentials = None
elif api_mtls_endpoint:
warnings.warn(
"api_mtls_endpoint and client_cert_source are deprecated",
DeprecationWarning,
)

host = (
api_mtls_endpoint
if ":" in api_mtls_endpoint
Expand Down Expand Up @@ -166,12 +171,18 @@ def __init__(
scopes=self.AUTH_SCOPES, quota_project_id=quota_project_id
)

if client_cert_source_for_mtls and not ssl_channel_credentials:
cert, key = client_cert_source_for_mtls()
self._ssl_channel_credentials = grpc.ssl_channel_credentials(
certificate_chain=cert, private_key=key
)

# create a new channel. The provided one is ignored.
self._grpc_channel = type(self).create_channel(
host,
credentials=credentials,
credentials_file=credentials_file,
ssl_credentials=ssl_channel_credentials,
ssl_credentials=self._ssl_channel_credentials,
scopes=scopes or self.AUTH_SCOPES,
quota_project_id=quota_project_id,
options=[
Expand Down

0 comments on commit edb1e0f

Please sign in to comment.