diff --git a/docs/index.rst b/docs/index.rst index 5eee2f9d..5ef0e009 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -2,55 +2,44 @@ .. include:: multiprocessing.rst -Api Reference -------------- +This package includes clients for multiple versions of Cloud Asset Inventory. +By default, you will get version ``asset_v1``. -This package includes clients for multiple versions of the Cloud Asset API. By default, you will get ``v1`` -the latest stable version. -v1 -~~~~~~~~~ +API Reference +------------- .. toctree:: :maxdepth: 2 asset_v1/services asset_v1/types -Beta releases with additional features over the current stable version. These are expected to move into the stable release soon; -until then, the usual beta admonishment (changes are possible, etc.) applies. - -In order to use it, you will want to import from -``google.cloud.asset_v1p4beta1`` in lieu of ``google.cloud.asset_v1``. - -v1p1beta1 -~~~~~~~~~ +API Reference +------------- .. toctree:: :maxdepth: 2 asset_v1p1beta1/services asset_v1p1beta1/types - -v1p2beta1 -~~~~~~~~~ +API Reference +------------- .. toctree:: :maxdepth: 2 asset_v1p2beta1/services asset_v1p2beta1/types - -v1p4beta1 -~~~~~~~~~ +API Reference +------------- .. toctree:: :maxdepth: 2 asset_v1p4beta1/services asset_v1p4beta1/types - -v1p5beta1 -~~~~~~~~~ +API Reference +------------- .. toctree:: :maxdepth: 2 @@ -61,12 +50,12 @@ v1p5beta1 Migration Guide --------------- -See the guide below for instructions on migrating to the 2.x release of this library. +See the guide below for instructions on migrating to the latest version. .. toctree:: :maxdepth: 2 - UPGRADING +  UPGRADING Changelog @@ -75,6 +64,6 @@ Changelog For a list of all ``google-cloud-asset`` releases: .. toctree:: - :maxdepth: 2 + :maxdepth: 2 - changelog + changelog diff --git a/google/cloud/asset_v1/services/asset_service/async_client.py b/google/cloud/asset_v1/services/asset_service/async_client.py index 692fb57f..d5d2a86d 100644 --- a/google/cloud/asset_v1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1/services/asset_service/async_client.py @@ -70,7 +70,7 @@ class AssetServiceAsyncClient: access_policy_path = staticmethod(AssetServiceClient.access_policy_path) parse_access_policy_path = staticmethod(AssetServiceClient.parse_access_policy_path) asset_path = staticmethod(AssetServiceClient.asset_path) - + parse_asset_path = staticmethod(AssetServiceClient.parse_asset_path) feed_path = staticmethod(AssetServiceClient.feed_path) parse_feed_path = staticmethod(AssetServiceClient.parse_feed_path) inventory_path = staticmethod(AssetServiceClient.inventory_path) diff --git a/google/cloud/asset_v1/services/asset_service/client.py b/google/cloud/asset_v1/services/asset_service/client.py index dbacd132..46e8e2a3 100644 --- a/google/cloud/asset_v1/services/asset_service/client.py +++ b/google/cloud/asset_v1/services/asset_service/client.py @@ -222,6 +222,12 @@ def asset_path() -> str: """Returns a fully-qualified asset string.""" return "*".format() + @staticmethod + def parse_asset_path(path: str) -> Dict[str, str]: + """Parses a asset path into its component segments.""" + m = re.match(r"^.*$", path) + return m.groupdict() if m else {} + @staticmethod def feed_path( project: str, diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py b/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py index 0a5f7ba9..3c24b882 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/async_client.py @@ -64,7 +64,7 @@ class AssetServiceAsyncClient: access_policy_path = staticmethod(AssetServiceClient.access_policy_path) parse_access_policy_path = staticmethod(AssetServiceClient.parse_access_policy_path) asset_path = staticmethod(AssetServiceClient.asset_path) - + parse_asset_path = staticmethod(AssetServiceClient.parse_asset_path) service_perimeter_path = staticmethod(AssetServiceClient.service_perimeter_path) parse_service_perimeter_path = staticmethod( AssetServiceClient.parse_service_perimeter_path diff --git a/google/cloud/asset_v1p5beta1/services/asset_service/client.py b/google/cloud/asset_v1p5beta1/services/asset_service/client.py index 299c6fcf..08ab0a0d 100644 --- a/google/cloud/asset_v1p5beta1/services/asset_service/client.py +++ b/google/cloud/asset_v1p5beta1/services/asset_service/client.py @@ -216,6 +216,12 @@ def asset_path() -> str: """Returns a fully-qualified asset string.""" return "*".format() + @staticmethod + def parse_asset_path(path: str) -> Dict[str, str]: + """Parses a asset path into its component segments.""" + m = re.match(r"^.*$", path) + return m.groupdict() if m else {} + @staticmethod def service_perimeter_path( access_policy: str, diff --git a/owlbot.py b/owlbot.py index 2b474f49..93dc8836 100644 --- a/owlbot.py +++ b/owlbot.py @@ -14,7 +14,6 @@ import json from pathlib import Path -import re import shutil import synthtool as s @@ -36,36 +35,7 @@ if clean_up_generated_samples: shutil.rmtree("samples/generated_samples", ignore_errors=True) clean_up_generated_samples = False - # Remove broken `parse_asset_path` method - # The resource pattern is '*' which breaks the regex match - s.replace( - library / "google/cloud/**/client.py", - """@staticmethod - def parse_asset_path.*?@staticmethod""", - """@staticmethod""", - flags=re.MULTILINE | re.DOTALL - ) - - s.replace( - library / "google/cloud/**/async_client.py", - """parse_asset_path = staticmethod\(AssetServiceClient\.parse_asset_path\)""", - "" - ) - - s.replace( - library / "tests/unit/**/test_asset_service.py", - """def test_parse_asset_path.*?def""", - """def""", - flags=re.MULTILINE | re.DOTALL, - ) - - s.replace( - library / "google/cloud/asset_v*/__init__.py", - "from google.cloud.asset import gapic_version as package_version", - f"from google.cloud.asset_{library.name} import gapic_version as package_version", - ) - - s.move([library], excludes=["**/gapic_version.py", "docs/index.rst", "setup.py", "testing/constraints-3.7.txt"]) + s.move([library], excludes=["**/gapic_version.py"]) s.remove_staging_dirs() # ---------------------------------------------------------------------------- @@ -77,7 +47,7 @@ def parse_asset_path.*?@staticmethod""", microgenerator=True, versions=gcp.common.detect_versions(path="./google", default_first=True), ) -s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml", "docs/index.rst"]) +s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"]) python.py_samples(skip_readmes=True) diff --git a/setup.py b/setup.py index e0fdcc42..f3b4c9ff 100644 --- a/setup.py +++ b/setup.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Copyright 2022 Google LLC +# Copyright 2023 Google LLC # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -37,13 +37,13 @@ dependencies = [ "google-api-core[grpc] >= 1.34.0, <3.0.0dev,!=2.0.*,!=2.1.*,!=2.2.*,!=2.3.*,!=2.4.*,!=2.5.*,!=2.6.*,!=2.7.*,!=2.8.*,!=2.9.*,!=2.10.*", - "grpc-google-iam-v1 >=0.12.4, <1.0.0dev", - "google-cloud-access-context-manager >= 0.1.2, <1.0.0dev", - "google-cloud-org-policy>=0.1.2, <2.0.0", - "google-cloud-os-config >= 1.0.0, <2.0.0dev", "proto-plus >= 1.22.0, <2.0.0dev", "proto-plus >= 1.22.2, <2.0.0dev; python_version>='3.11'", "protobuf>=3.19.5,<5.0.0dev,!=3.20.0,!=3.20.1,!=4.21.0,!=4.21.1,!=4.21.2,!=4.21.3,!=4.21.4,!=4.21.5", + "google-cloud-access-context-manager >= 0.1.2, <1.0.0dev", + "google-cloud-org-policy >= 0.1.2, <2.0.0dev", + "google-cloud-os-config >= 1.0.0, <2.0.0dev", + "grpc-google-iam-v1 >= 0.12.4, <1.0.0dev", ] url = "https://github.com/googleapis/python-asset" @@ -59,9 +59,7 @@ if package.startswith("google") ] -namespaces = ["google"] -if "google.cloud" in packages: - namespaces.append("google.cloud") +namespaces = ["google", "google.cloud"] setuptools.setup( name=name, diff --git a/testing/constraints-3.10.txt b/testing/constraints-3.10.txt index ad3f0fa5..6b5f88ae 100644 --- a/testing/constraints-3.10.txt +++ b/testing/constraints-3.10.txt @@ -4,4 +4,7 @@ google-api-core proto-plus protobuf +google-cloud-access-context-manager +google-cloud-org-policy +google-cloud-os-config grpc-google-iam-v1 diff --git a/testing/constraints-3.11.txt b/testing/constraints-3.11.txt index ad3f0fa5..6b5f88ae 100644 --- a/testing/constraints-3.11.txt +++ b/testing/constraints-3.11.txt @@ -4,4 +4,7 @@ google-api-core proto-plus protobuf +google-cloud-access-context-manager +google-cloud-org-policy +google-cloud-os-config grpc-google-iam-v1 diff --git a/testing/constraints-3.12.txt b/testing/constraints-3.12.txt index ad3f0fa5..6b5f88ae 100644 --- a/testing/constraints-3.12.txt +++ b/testing/constraints-3.12.txt @@ -4,4 +4,7 @@ google-api-core proto-plus protobuf +google-cloud-access-context-manager +google-cloud-org-policy +google-cloud-os-config grpc-google-iam-v1 diff --git a/testing/constraints-3.7.txt b/testing/constraints-3.7.txt index 307e89fe..05de978b 100644 --- a/testing/constraints-3.7.txt +++ b/testing/constraints-3.7.txt @@ -5,9 +5,9 @@ # e.g., if setup.py has "google-cloud-foo >= 1.14.0, < 2.0.0dev", # Then this file should have google-cloud-foo==1.14.0 google-api-core==1.34.0 -grpc-google-iam-v1==0.12.4 +proto-plus==1.22.0 +protobuf==3.19.5 google-cloud-access-context-manager==0.1.2 google-cloud-org-policy==0.1.2 google-cloud-os-config==1.0.0 -proto-plus==1.22.0 -protobuf==3.19.5 +grpc-google-iam-v1==0.12.4 diff --git a/testing/constraints-3.8.txt b/testing/constraints-3.8.txt index ad3f0fa5..6b5f88ae 100644 --- a/testing/constraints-3.8.txt +++ b/testing/constraints-3.8.txt @@ -4,4 +4,7 @@ google-api-core proto-plus protobuf +google-cloud-access-context-manager +google-cloud-org-policy +google-cloud-os-config grpc-google-iam-v1 diff --git a/testing/constraints-3.9.txt b/testing/constraints-3.9.txt index ad3f0fa5..6b5f88ae 100644 --- a/testing/constraints-3.9.txt +++ b/testing/constraints-3.9.txt @@ -4,4 +4,7 @@ google-api-core proto-plus protobuf +google-cloud-access-context-manager +google-cloud-org-policy +google-cloud-os-config grpc-google-iam-v1 diff --git a/tests/unit/gapic/asset_v1/test_asset_service.py b/tests/unit/gapic/asset_v1/test_asset_service.py index cdbb6676..1b20d27d 100644 --- a/tests/unit/gapic/asset_v1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1/test_asset_service.py @@ -14679,6 +14679,15 @@ def test_asset_path(): assert expected == actual +def test_parse_asset_path(): + expected = {} + path = AssetServiceClient.asset_path(**expected) + + # Check that the path construction is reversible. + actual = AssetServiceClient.parse_asset_path(path) + assert expected == actual + + def test_feed_path(): project = "cuttlefish" feed = "mussel" diff --git a/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py b/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py index 81a432c4..d169a712 100644 --- a/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py +++ b/tests/unit/gapic/asset_v1p5beta1/test_asset_service.py @@ -2024,6 +2024,15 @@ def test_asset_path(): assert expected == actual +def test_parse_asset_path(): + expected = {} + path = AssetServiceClient.asset_path(**expected) + + # Check that the path construction is reversible. + actual = AssetServiceClient.parse_asset_path(path) + assert expected == actual + + def test_service_perimeter_path(): access_policy = "cuttlefish" service_perimeter = "mussel"