Skip to content
Permalink
Browse files
fix: resolve issue importing library (#64)
Fixes #63 πŸ¦•
  • Loading branch information
parthea committed Aug 20, 2021
1 parent 367aca0 commit cfa166e9b9024920bd00b5994d2638ab7716c2d1
File renamed without changes.
@@ -1,7 +1,7 @@
Types for Google Cloud Gkehub Configmanagement v1 API
=====================================================

.. automodule:: google.cloud.gkehub.configmanagement_v1.types
.. automodule:: google.cloud.gkehub_v1.configmanagement_v1.types
:members:
:undoc-members:
:show-inheritance:
File renamed without changes.
@@ -1,7 +1,7 @@
Types for Google Cloud Gkehub Multiclusteringress v1 API
========================================================

.. automodule:: google.cloud.gkehub.multiclusteringress_v1.types
.. automodule:: google.cloud.gkehub_v1.multiclusteringress_v1.types
:members:
:undoc-members:
:show-inheritance:
@@ -9,10 +9,10 @@ API Reference

gkehub_v1/services
gkehub_v1/types
configmanagement_v1/services
configmanagement_v1/types
multiclusteringress_v1/services
multiclusteringress_v1/types
gkehub_v1/configmanagement_v1/services
gkehub_v1/configmanagement_v1/types
gkehub_v1/multiclusteringress_v1/services
gkehub_v1/multiclusteringress_v1/types

API Reference
-------------
@@ -15,8 +15,8 @@
#
import proto # type: ignore

from google.cloud.gkehub import configmanagement_v1 as configmanagement_pb2 # type: ignore
from google.cloud.gkehub import multiclusteringress_v1 as multiclusteringress_pb2 # type: ignore
from google.cloud.gkehub_v1 import configmanagement_v1 # type: ignore
from google.cloud.gkehub_v1 import multiclusteringress_v1 # type: ignore
from google.protobuf import timestamp_pb2 # type: ignore


@@ -175,15 +175,15 @@ class CommonFeatureSpec(proto.Message):
r"""CommonFeatureSpec contains Hub-wide configuration informatio.
Attributes:
multiclusteringress (google.cloud.gkehub.multiclusteringress.v1.multiclusteringress_pb2.FeatureSpec):
multiclusteringress (google.cloud.gkehub_v1.multiclusteringress_v1.FeatureSpec):
Multicluster Ingress-specific spec.
"""

multiclusteringress = proto.Field(
proto.MESSAGE,
number=102,
oneof="feature_spec",
message=multiclusteringress_pb2.FeatureSpec,
message=multiclusteringress_v1.FeatureSpec,
)


@@ -205,15 +205,15 @@ class MembershipFeatureSpec(proto.Message):
a single Membership.
Attributes:
configmanagement (google.cloud.gkehub.configmanagement.v1.configmanagement_pb2.MembershipSpec):
configmanagement (google.cloud.gkehub_v1.configmanagement_v1.MembershipSpec):
Config Management-specific spec.
"""

configmanagement = proto.Field(
proto.MESSAGE,
number=106,
oneof="feature_spec",
message=configmanagement_pb2.MembershipSpec,
message=configmanagement_v1.MembershipSpec,
)


@@ -222,7 +222,7 @@ class MembershipFeatureState(proto.Message):
for a single Membership.
Attributes:
configmanagement (google.cloud.gkehub.configmanagement.v1.configmanagement_pb2.MembershipState):
configmanagement (google.cloud.gkehub_v1.configmanagement_v1.MembershipState):
Config Management-specific state.
state (google.cloud.gkehub_v1.types.FeatureState):
The high-level state of this Feature for a
@@ -233,7 +233,7 @@ class MembershipFeatureState(proto.Message):
proto.MESSAGE,
number=106,
oneof="feature_state",
message=configmanagement_pb2.MembershipState,
message=configmanagement_v1.MembershipState,
)
state = proto.Field(proto.MESSAGE, number=1, message="FeatureState",)

@@ -25,21 +25,45 @@
default_version = "v1"

for library in s.get_staging_dirs(default_version):
dependencies = [
submodules = [
"configmanagement",
"multiclusteringress",
]

# rename dependencies google.cloud.gkehub.dep.vX to google.cloud.gkehub.dep_vX
for dep in dependencies:
for submodule in submodules:
# Move v1 submodule namespace from google.cloud.gkehub.{submodule}_v1 to google.cloud.gkehub_vX.{submodule}_v1
s.move(library / f"google/cloud/gkehub/{submodule}_v1", library / f"google/cloud/gkehub_{library.name}/{submodule}_v1")

# Adjust docs based on new submodule namespace google.cloud.gkehub_vX.{submodule}_v1.types"
s.replace(
library / f"docs/{submodule}_v1/types.rst",
f"google.cloud.gkehub.{submodule}_v1.types",
f"google.cloud.gkehub_{library.name}.{submodule}_v1.types",
)

# Move docs to correct location /docs/gkehub_vX/{submodule}_v1
s.move(library / f"docs/{submodule}_v1", library / f"docs/gkehub_{library.name}/{submodule}_v1")

# Rename v1 submodule imports from google.cloud.gkehub.submodule.v1 to google.cloud.gkehub_vX.submodule_v1
s.replace(
[
library / f"google/cloud/gkehub_{library.name}/**/*.py",
library / f"tests/unit/gapic/gkehub_{library.name}/**/*.py",
library / f"google/cloud/gkehub/{dep}_{library.name}/**/*.py",
],
f"from google.cloud.gkehub.{dep}.{library.name} import",
f"from google.cloud.gkehub import {dep}_{library.name} as"
f"from google.cloud.gkehub.{submodule}.v1 import {submodule}_pb2",
f"from google.cloud.gkehub_{library.name} import {submodule}_v1"
)

s.replace(
library / f"google/cloud/gkehub_{library.name}/types/feature.py",
f"google.cloud.gkehub.{submodule}.v1.{submodule}_pb2",
f"google.cloud.gkehub_v1.{submodule}_v1"
)

s.replace(
library / f"google/cloud/gkehub_{library.name}/types/feature.py",
f"{submodule}_pb2",
f"{submodule}_v1"
)

# Work around gapic generator bug https://github.com/googleapis/gapic-generator-python/issues/902
@@ -64,7 +88,18 @@
//container.googleapis.com/projects/my-"""
)

s.move(library, excludes=["setup.py", "README.rst", "docs/index.rst", "google/cloud/gkehub/configmanagement", "google/cloud/gkehub/multiclusteringress"])
excludes=[
"setup.py",
"README.rst",
"docs/index.rst",
"docs/configmanagement_v1/**",
"docs/multiclusteringress_v1/**",
"google/cloud/gkehub/configmanagement/**",
"google/cloud/gkehub/configmanagement_v1/**",
"google/cloud/gkehub/multiclusteringress/**",
"google/cloud/gkehub/multiclusteringress_v1/**"
]
s.move(library, excludes=excludes)

s.remove_staging_dirs()

@@ -34,8 +34,8 @@
from google.api_core import operations_v1
from google.auth import credentials as ga_credentials
from google.auth.exceptions import MutualTLSChannelError
from google.cloud.gkehub import configmanagement_v1 as configmanagement_pb2 # type: ignore
from google.cloud.gkehub import multiclusteringress_v1 as multiclusteringress_pb2 # type: ignore
from google.cloud.gkehub_v1 import configmanagement_v1 # type: ignore
from google.cloud.gkehub_v1 import multiclusteringress_v1 # type: ignore
from google.cloud.gkehub_v1.services.gke_hub import GkeHubAsyncClient
from google.cloud.gkehub_v1.services.gke_hub import GkeHubClient
from google.cloud.gkehub_v1.services.gke_hub import pagers

0 comments on commit cfa166e

Please sign in to comment.