Esempio n. 1
0
library = gapic.py_library(
    "bigquery_storage",
    version,
    config_path="/google/cloud/bigquery/storage/"
    "artman_bigquerystorage_v1beta1.yaml",
    artman_output_name="bigquerystorage-v1beta1",
    include_protos=True,
)

s.move(
    library,
    excludes=[
        "docs/conf.py",
        "docs/index.rst",
        "google/cloud/bigquery_storage_v1beta1/__init__.py",
        "README.rst",
        "nox*.py",
        "setup.py",
        "setup.cfg",
    ],
)

s.replace(
    [
        "google/cloud/bigquery_storage_v1beta1/proto/storage_pb2.py",
        "google/cloud/bigquery_storage_v1beta1/proto/storage_pb2_grpc.py",
    ],
    "from google.cloud.bigquery.storage_v1beta1.proto",
    "from google.cloud.bigquery_storage_v1beta1.proto",
)
Esempio n. 2
0
    ("v1", "artman_firestore_v1.yaml"),
]

# ----------------------------------------------------------------------------
# Generate firestore GAPIC layer
# ----------------------------------------------------------------------------
for version, artman_config in versions:
    library = gapic.py_library(
        "firestore",
        version,
        config_path=f"/google/firestore/{artman_config}",
        artman_output_name=f"firestore-{version}",
        include_protos=True,
    )

    s.move(library / f"google/cloud/firestore_{version}/proto")
    s.move(library / f"google/cloud/firestore_{version}/gapic")
    s.move(library / f"tests/unit/gapic/{version}")

    s.replace(
        f"tests/unit/gapic/{version}/test_firestore_client_{version}.py",
        f"from google.cloud import firestore_{version}",
        f"from google.cloud.firestore_{version}.gapic import firestore_client",
    )

    s.replace(
        f"tests/unit/gapic/{version}/test_firestore_client_{version}.py",
        f"client = firestore_{version}.FirestoreClient",
        "client = firestore_client.FirestoreClient",
    )
Esempio n. 3
0
gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate bigtable and bigtable_admin GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    "bigtable",
    "v2",
    config_path="/google/bigtable/artman_bigtable.yaml",
    artman_output_name="bigtable-v2",
    include_protos=True,
)

s.move(library / "google/cloud/bigtable_v2")
s.move(library / "tests")

# Generate admin client
library = gapic.py_library(
    "bigtable_admin",
    "v2",
    config_path="/google/bigtable/admin/artman_bigtableadmin.yaml",
    artman_output_name="bigtable-admin-v2",
    include_protos=True,
)

s.move(library / "google/cloud/bigtable_admin_v2")
s.move(library / "tests")

s.replace(
Esempio n. 4
0
logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()

for version in ['V1', 'V1beta1']:
    lower_version = version.lower()

    library = gapic.php_library(
        service='asset',
        version=lower_version,
        config_path=f'artman_cloudasset_{lower_version}.yaml',
        artman_output_name=f'google-cloud-asset-{lower_version}')

    # copy all src including partial veneer classes
    s.move(library / 'src')

    # copy proto files to src also
    s.move(library / f'proto/src/Google/Cloud/Asset', f'src/')
    s.move(library / f'tests/')

    # copy GPBMetadata file to metadata
    s.move(library / f'proto/src/GPBMetadata/Google/Cloud/Asset', f'metadata/')

# fix year
s.replace(
    'src/V1beta1/**/*.php',
    r'Copyright \d{4}',
    r'Copyright 2018')
s.replace(
    'tests/*/V1beta1/*Test.php',
Esempio n. 5
0
gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate dlp GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    "irm",
    "v1alpha2",
    config_path="/google/cloud/irm/artman_irm_v1alpha2.yaml",
    include_protos=True,
)

excludes = ["README.rst", "nox*.py", "setup.py", "docs/index.rst"]
s.move(library, excludes=excludes)

# Fix docstrings
s.replace("google/**/*.py", r"\\_", "_")
s.replace("google/**/incidents_service_pb2.py", r"""\\\*""", r"""*""")
s.replace("google/**/incident_service_client.py", r"""\\\*""", r"""*""")
s.replace(
    "google/**/incident_service_client.py",
    r"""        This will fail if:
           a\. there are too many \(50\) subscriptions in the incident already
           b\. a subscription using the given channel already exists""",
    r"""        This will fail if:
        a. there are too many (50) subscriptions in the incident already
        b. a subscription using the given channel already exists""",
)
Esempio n. 6
0
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

library = gapic.php_library(
    service='pubsub',
    version='v1',
    config_path='/google/pubsub/artman_pubsub.yaml',
    artman_output_name='google-cloud-pubsub-v1')

# copy all src including partial veneer classes
s.move(library / 'src')

# copy proto files to src also
s.move(library / 'proto/src/Google/Cloud/PubSub', 'src/')
s.move(library / 'tests/')

# copy GPBMetadata file to metadata
s.move(library / 'proto/src/GPBMetadata/Google/Pubsub', 'metadata/')

# fix year
s.replace(
    '**/Gapic/*GapicClient.php',
    r'Copyright \d{4}',
    'Copyright 2016')
for client in ['Publisher', 'Subscriber']:
    s.replace(
Esempio n. 7
0
import re

import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()
versions = ["v1beta1"]


# ----------------------------------------------------------------------------
# Generate automl GAPIC layer
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("automl", version, include_protos=True)
    s.move(library / f"google/cloud/automl_{version}")
    s.move(library / f"tests/unit/gapic/{version}")
    s.move(library / f"docs/gapic/{version}")

s.move(library / f"docs/conf.py")

# Use the highest version library to generate import alias.
s.move(library / "google/cloud/automl.py")

# Fixup issues in generated code
s.replace(
    "**/gapic/*_client.py",
    r"metadata_type=operations_pb2.OperationMetadata",
    r"metadata_type=proto_operations_pb2.OperationMetadata",
)
Esempio n. 8
0
common = gcp.CommonTemplates()

default_version = "v1"

for library in s.get_staging_dirs(default_version):
    # rename to google-cloud-os-config
    s.replace([library / "google/**/*.py", library / "tests/**/*.py"], 
               "google-cloud-osconfig", 
               "google-cloud-os-config")

    # Add newline after last item in list
    s.replace(library / "google/cloud/**/*client.py",
    "(-  Must be unique within the project\.)",
    "\g<1>\n")

    s.move(library, excludes=["nox.py", "setup.py", "README.rst", "docs/index.rst"])

s.remove_staging_dirs()

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(
    samples=False,
    microgenerator=True,
    cov_level=98,
)
s.move(
    templated_files, excludes=[".coveragerc"]
)  # the microgenerator has a good coveragerc file
Esempio n. 9
0
import synthtool as s
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

library = gapic.php_library(service='iot',
                            version='v1',
                            config_path='artman_cloudiot.yaml',
                            artman_output_name='google-cloud-iot-v1')

# copy all src except partial veneer classes
s.move(library / f'src/V1/Gapic')
s.move(library / f'src/V1/resources')

# copy proto files to src also
s.move(library / f'proto/src/Google/Cloud/Iot', f'src/')
s.move(library / f'tests/')

# copy GPBMetadata file to metadata
s.move(library / f'proto/src/GPBMetadata/Google/Cloud/Iot', f'metadata/')

# document and utilize apiEndpoint instead of serviceAddress
s.replace("**/Gapic/*GapicClient.php", r"'serviceAddress' =>",
          r"'apiEndpoint' =>")
s.replace(
    "**/Gapic/*GapicClient.php", r"@type string \$serviceAddress",
    r"""@type string $serviceAddress
Esempio n. 10
0
# 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.
"""This script is used to synthesize generated parts of this library."""

import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()

versions = ['v1', 'v1p1beta1', 'v1p2beta1', 'v1p3beta1']

for version in versions:
    library = gapic.py_library('vision', version)

    s.move(library / f'google/cloud/vision_{version}/gapic')
    s.move(library / f'google/cloud/vision_{version}/__init__.py')
    s.move(library / f'google/cloud/vision_{version}/types.py')
    s.move(library / f'google/cloud/vision_{version}/proto')
    s.move(library / f'tests/unit/gapic/{version}')
    # don't publish docs for these versions
    if version not in ['v1p1beta1']:
        s.move(library / f'docs/gapic/{version}')

    # Add vision helpers to each version
    s.replace(
        f'google/cloud/vision_{version}/__init__.py',
        f'from __future__ import absolute_import', f'\g<0>\n\n'
        f'from google.cloud.vision_helpers.decorators import '
        f'add_single_feature_methods\n'
        f'from google.cloud.vision_helpers import VisionHelpers')
logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICBazel()
common = gcp.CommonTemplates()

for version in ['v1', 'v1beta1']:
    library = gapic.php_library(
        service='webrisk',
        version=version,
        bazel_target=
        f'//google/cloud/webrisk/{version}:google-cloud-webrisk-{version}-php',
    )

    # copy all src including partial veneer classes
    s.move(library / 'src')

    # copy proto files to src also
    s.move(library / 'proto/src/Google/Cloud/WebRisk', 'src/')
    s.move(library / 'tests/')

    # copy GPBMetadata file to metadata
    s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Webrisk', 'metadata/')

# document and utilize apiEndpoint instead of serviceAddress
s.replace("**/Gapic/*GapicClient.php", r"'serviceAddress' =>",
          r"'apiEndpoint' =>")
s.replace(
    "**/Gapic/*GapicClient.php",
    r"@type string \$serviceAddress\n\s+\*\s+The address",
    r"""@type string $serviceAddress
Esempio n. 12
0
import synthtool as s
from synthtool import gcp
from synthtool.sources import git

DISCOVERY_ARTIFACT_MANAGER_REPO = "googleapis/discovery-artifact-manager"

common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library()

# Copy kokoro configs.
# Docs are excluded as repo docs cannot currently be generated using sphinx.
s.move(templated_files / '.kokoro', excludes=['**/docs/*', 'publish-docs.sh'])

# Also move issue templates
s.move(templated_files / '.github')

# ----------------------------------------------------------------------------
# Copy discoveries folder from discovery-artifact-manager repo
# ----------------------------------------------------------------------------

discovery_artifact_manager_url = git.make_repo_clone_url(DISCOVERY_ARTIFACT_MANAGER_REPO)
discovery_artifacts = git.clone(discovery_artifact_manager_url) / "discoveries"

excludes = [
    "**/BUILD.bazel",
]
s.copy(discovery_artifacts,
Esempio n. 13
0
# ----------------------------------------------------------------------------
# Generate pubsub GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    service="pubsub",
    version=version,
    bazel_target="//google/pubsub/v1:pubsub-v1-py",
    include_protos=True,
)
s.move(
    library,
    excludes=[
        "docs/**/*",
        "nox.py",
        "README.rst",
        "setup.py",
        "google/cloud/pubsub_v1/__init__.py",
        "google/cloud/pubsub_v1/types.py",
    ],
)

# DEFAULT SCOPES and SERVICE_ADDRESS are being used. so let's force them in.
s.replace(
    "google/pubsub_v1/services/*er/*client.py",
    r"DEFAULT_ENDPOINT = 'pubsub\.googleapis\.com'",
    """
    # The scopes needed to make gRPC calls to all of the methods defined in
    # this service
    _DEFAULT_SCOPES = (
        'https://www.googleapis.com/auth/cloud-platform',
Esempio n. 14
0
        "request = image_annotator.AsyncBatchAnnotateImagesRequest(request)\n"
        "            if requests is not None:\n"
        "                for i in range(len(requests)):\n"
        "                    requests[i] = image_annotator.AnnotateImageRequest(requests[i])"
    )

    s.replace(
        library / f"google/cloud/vision_{library.name}/services/image_annotator/client.py",
        "request = image_annotator.AsyncBatchAnnotateFilesRequest\(request\)",
        "request = image_annotator.AsyncBatchAnnotateFilesRequest(request)\n"
        "            if requests is not None:\n"
        "                for i in range(len(requests)):\n"
        "                    requests[i] = image_annotator.AsyncAnnotateFileRequest(requests[i])"
    )

    s.move(library / f"google/cloud/vision_{library.name}/proto")
    s.move(library / f"google/cloud/vision_{library.name}/services")
    s.move(library / f"google/cloud/vision_{library.name}/types")
    s.move(library / f"google/cloud/vision_{library.name}/__init__.py")
    s.move(library / f"google/cloud/vision_{library.name}/py.typed")
    s.move(library / f"tests/unit/gapic/vision_{library.name}")

    # don't publish docs for these versions
    if library.name != "v1p1beta1":
        s.move(library / f"docs/vision_{library.name}")

    # Move docs configuration
    s.move(library / f"docs/conf.py")

s.remove_staging_dirs()
Esempio n. 15
0
"""This script is used to synthesize generated parts of this library."""
import re

import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()
versions = ["v1beta1", "v1"]

# ----------------------------------------------------------------------------
# Generate texttospeech GAPIC layer
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("texttospeech", version, include_protos=True)
    s.move(library / f"google/cloud/texttospeech_{version}")
    s.move(library / f"tests/unit/gapic/{version}")
    s.move(library / f"docs/gapic/{version}")

# Use the highest version library to generate import alias.
s.move(library / "google/cloud/texttospeech.py")

# Fix bad docstrings.
s.replace("**/gapic/*_client.py", r'\\"(.+?)-\*\\"', r'"\1-\\*"')

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files)
Esempio n. 16
0
        library / f"google/devtools/**/*.py",
        f"google.devtools.cloudbuild_{library.name}",
        f"google.cloud.devtools.cloudbuild_{library.name}",
    )
    s.replace(
        library / f"tests/unit/gapic/**/*.py",
        f"google.devtools.cloudbuild_{library.name}",
        f"google.cloud.devtools.cloudbuild_{library.name}",
    )
    s.replace(
        library / f"docs/**/*.rst",
        f"google.devtools.cloudbuild_{library.name}",
        f"google.cloud.devtools.cloudbuild_{library.name}",
    )

    s.move(library / "google/devtools/cloudbuild",
           "google/cloud/devtools/cloudbuild")
    s.move(library / f"google/devtools/cloudbuild_{library.name}",
           f"google/cloud/devtools/cloudbuild_{library.name}")
    s.move(library / "tests")
    s.move(library / "scripts")
    s.move(library / "docs", excludes=["index.rst"])

s.remove_staging_dirs()

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(
    samples=False,  # set to True only if there are samples
    microgenerator=True,
    cov_level=99,
Esempio n. 17
0
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

library = gapic.php_library(
    service='spanner',
    version='v1',
    config_path='/google/spanner/artman_spanner.yaml',
    artman_output_name='google-cloud-spanner-v1')

# copy all src except handwritten partial veneers
s.move(library / f'src/V1/Gapic')
s.move(library / f'src/V1/resources')

# copy proto files to src also
s.move(library / f'proto/src/Google/Cloud/Spanner', f'src/')
s.move(library / f'tests/')

# copy GPBMetadata file to metadata
s.move(library / f'proto/src/GPBMetadata/Google/Spanner', f'metadata/')

# fix year
s.replace(
    '**/Gapic/*GapicClient.php',
    r'Copyright \d{4}',
    r'Copyright 2017')
s.replace(
Esempio n. 18
0
gapic = gcp.GAPICBazel()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate document AI GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    service="documentai",
    version="v1beta2",
    bazel_target="//google/cloud/documentai/v1beta2:documentai-v1beta2-py",
)

library = gapic.py_library("documentai", "v1beta2")

excludes = ["README.rst", "nox.py", "docs/index.rst", "setup.py"]
s.move(library, excludes=excludes)

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(cov_level=73)
s.move(templated_files)

# Remove 2.7 and 3.5 tests from noxfile.py
s.replace("noxfile.py", '''\["2\.7", ''', '[')
s.replace("noxfile.py", '''"3.5", ''', '')

# Expand flake errors permitted to accomodate the Microgenerator
# TODO: remove extra error codes once issues below are resolved
# F401: https://github.com/googleapis/gapic-generator-python/issues/324
# F841: local variable 'client'/'response' is assigned to but never use
Esempio n. 19
0
# limitations under the License.

"""This script is used to synthesize generated parts of this library."""
import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate datastore GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    "datastore",
    "v1",
    config_path="/google/datastore/artman_datastore.yaml",
    artman_output_name="datastore-v1",
    include_protos=True,
)

s.move(library / "google/cloud/datastore_v1/proto")
s.move(library / "google/cloud/datastore_v1/gapic")

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
Esempio n. 20
0
import re

import synthtool as s
from synthtool import gcp
from synthtool.languages import python

gapic = gcp.GAPICBazel()
versions = ["v1beta1", "v1"]
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate Cloud Recommender
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("recommender", version)
    s.move(library,
           excludes=["nox.py", "docs/index.rst", "README.rst", "setup.py"])

# Fix docstring with regex pattern that breaks docgen
s.replace("google/**/recommender_client.py", "(/\^.*\$/)", "``\g<1>``")

# Fix more regex in docstrings
s.replace("google/**/*_pb2.py", ":math:`(/)", "\g<1>")
s.replace("google/**/*_pb2.py", "`/\.", "/.")
s.replace(
    "google/**/*_pb2.py",
    "(regex\s+)(/.*?/)\.",
    "\g<1>``\g<2>``.",
    flags=re.MULTILINE | re.DOTALL,
)

# Fix docstring with JSON example by wrapping with backticks
Esempio n. 21
0
import re

import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()

version = 'v1'


library = gapic.py_library(
    'pubsub', version, config_path='/google/pubsub/artman_pubsub.yaml')
s.move(
    library,
    excludes=[
        'docs/**/*', 'nox.py', 'README.rst', 'setup.py',
        'google/cloud/pubsub_v1/__init__.py', 'google/cloud/pubsub_v1/types.py'])

# Adjust tests to import the clients directly.
s.replace(
    'tests/unit/gapic/v1/test_publisher_client_v1.py',
    'from google.cloud import pubsub_v1',
    'from google.cloud.pubsub_v1.gapic import publisher_client')

s.replace(
    'tests/unit/gapic/v1/test_publisher_client_v1.py',
    ' pubsub_v1',
    ' publisher_client')

s.replace(
Esempio n. 22
0
import synthtool as s
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

v1beta1_library = gapic.php_library(
    service='redis',
    version='v1beta1',
    artman_output_name='google-cloud-redis-v1beta1')

# copy all src except partial veneer classes
s.move(v1beta1_library / f'src/V1beta1/Gapic')
s.move(v1beta1_library / f'src/V1beta1/resources')

# copy proto files to src also
s.move(v1beta1_library / f'proto/src/Google/Cloud/Redis', f'src/')
s.move(v1beta1_library / f'tests/')

# copy GPBMetadata file to metadata
s.move(v1beta1_library / f'proto/src/GPBMetadata/Google/Cloud/Redis',
       f'metadata/')

v1_library = gapic.php_library(service='redis',
                               version='v1',
                               artman_output_name='google-cloud-redis-v1')

# copy all src except partial veneer classes
Esempio n. 23
0
import synthtool as s
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

library = gapic.php_library(
    service='dialogflow',
    version='v2',
    artman_output_name='google-cloud-dialogflow-v2')

# copy all src including partial veneer classes
s.move(library / 'src')

# copy proto files to src also
s.move(library / 'proto/src/Google/Cloud/Dialogflow', 'src/')
s.move(library / 'tests/')

# copy GPBMetadata file to metadata
s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Dialogflow', 'metadata/')

# fix year
s.replace(
    '**/Gapic/*GapicClient.php',
    r'Copyright \d{4}',
    'Copyright 2018')
for client in ['Agents', 'Contexts', 'EntityTypes', 'Intents', 'SessionEntityTypes', 'Sessions']:
    s.replace(
Esempio n. 24
0
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

v1_library = gapic.php_library(
    service='container',
    version='v1',
    config_path='/google/container/artman_container_v1.yaml',
    artman_output_name='google-cloud-container-v1')

# copy all src including partial veneer classes
s.move(v1_library / 'src')

# copy proto files to src also
s.move(v1_library / 'proto/src/Google/Cloud/Container', 'src/')
s.move(v1_library / 'tests/')

# copy GPBMetadata file to metadata
s.move(v1_library / 'proto/src/GPBMetadata/Google/Container', 'metadata/')

# document and utilize apiEndpoint instead of serviceAddress
s.replace(
    "**/Gapic/*GapicClient.php",
    r"'serviceAddress' =>",
    r"'apiEndpoint' =>")
s.replace(
    "**/Gapic/*GapicClient.php",
Esempio n. 25
0
# limitations under the License.

"""This script is used to synthesize generated parts of this library."""
import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate iot GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    "iot",
    "v1",
    config_path="/google/cloud/iot/artman_cloudiot.yaml",
    artman_output_name="iot-v1",
)

s.move(library / "google/cloud/iot_v1")
s.move(library / "tests/unit/gapic")
s.move(library / "tests/system/gapic")

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=80, cov_level=80)
s.move(templated_files)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
Esempio n. 26
0
library = gapic.py_library(
    'datacatalog',
    version,
    config_path=
    '/google/cloud/datacatalog/v1beta1/artman_datacatalog_v1beta1.yaml',
    artman_output_name='datacatalog-v1beta1',
    include_protos=True,
    generator_args=["--dev_samples"],
)

s.move(
    library,
    excludes=[
        'docs/conf.py',
        'docs/index.rst',
        'google/cloud/datacatalog_v1beta1/__init__.py',
        'README.rst',
        'nox*.py',
        'setup.py',
        'setup.cfg',
    ],
)

# Fix docstring issue for classes with no summary line
s.replace(
    "google/cloud/**/proto/*_pb2.py",
    '''__doc__ = """Attributes:''',
    '''__doc__ = """
    Attributes:''',
)

# ----------------------------------------------------------------------------
Esempio n. 27
0
version = 'v1'

library = gapic.py_library(
    'bigquery-datatransfer',
    version,
    config_path='/google/cloud/bigquery/storage/'
                'artman_bigquerystorage_v1beta1.yaml',
    artman_output_name='bigquerystorage-v1beta1'
)

s.move(
    library,
    excludes=[
        'docs/conf.py',
        'docs/index.rst',
        'google/cloud/bigquery_storage_v1beta1/__init__.py',
        'README.rst',
        'nox*.py',
        'setup.py',
        'setup.cfg',
    ],
)

s.replace(
    ['google/cloud/bigquery_storage_v1beta1/proto/storage_pb2.py',
     'google/cloud/bigquery_storage_v1beta1/proto/storage_pb2_grpc.py'],
    'from google.cloud.bigquery.storage_v1beta1.proto',
    'from google.cloud.bigquery_storage_v1beta1.proto',
)

s.replace(
    'google/cloud/bigquery_storage_v1beta1/gapic/'
Esempio n. 28
0
import synthtool as s
from synthtool import gcp

common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(
    microgenerator=True,
    cov_level=99,
    unit_test_external_dependencies=["click"],
    unit_test_python_versions=["3.6", "3.7", "3.8", "3.9"],
)
s.move(templated_files, excludes=[
    "docs/multiprocessing.rst"
])

# Change black paths
s.replace(
    "noxfile.py",
    """BLACK_PATHS =.*""",
    """BLACK_PATHS = ["docs", "google_auth_oauthlib", "tests", "noxfile.py", "setup.py"]""",
)

# Change flake8 paths
s.replace(
    "noxfile.py",
    'session.run\("flake8", "google", "tests"\)',
    'session.run("flake8", *BLACK_PATHS)',
)
Esempio n. 29
0
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()
versions = ["v1p1beta1", "v1"]


# ----------------------------------------------------------------------------
# Generate speech GAPIC layer
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("speech", version)

    # Don't move over __init__.py, as we modify it to make the generated client
    # use helpers.py.
    s.move(library / f"google/cloud/speech_{version}/types.py")
    s.move(library / f"google/cloud/speech_{version}/gapic")
    s.move(library / f"google/cloud/speech_{version}/proto")
    s.move(library / f"tests/unit/gapic/{version}")
    s.move(library / f"docs/gapic/{version}")


# Use the highest version library to generate documentation import alias.
s.move(library / "google/cloud/speech.py")

# Issues exist where python files should define the source encoding
# https://github.com/googleapis/gapic-generator/issues/2097
s.replace("**/proto/*_pb2.py", r"(^.*$\n)*", r"# -*- coding: utf-8 -*-\n\g<0>")


# Fix tests to use the direct gapic client instead of the wrapped helper
Esempio n. 30
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.
"""This script is used to synthesize generated parts of this library."""
import re

import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
versions = ["v1beta1"]
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate Cloud Recommender
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("recommender", version, include_protos=True)
    s.move(library,
           excludes=['nox.py', 'docs/index.rst', 'README.rst', 'setup.py'])

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files, excludes=['noxfile.py'])

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
Esempio n. 31
0
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

library = gapic.php_library(
    service='clouderrorreporting',
    version='v1beta1',
    config_path='/google/devtools/clouderrorreporting/artman_errorreporting.yaml',
    artman_output_name='google-cloud-error-reporting-v1beta1')

# copy all src including partial veneer classes
s.move(library / 'src')

# copy proto files to src also
s.move(library / 'proto/src/Google/Cloud/ErrorReporting', 'src/')
s.move(library / 'tests/')

# copy GPBMetadata file to metadata
s.move(library / 'proto/src/GPBMetadata/Google/Devtools/Clouderrorreporting', 'metadata/')

# fix year
s.replace(
    '**/Gapic/*GapicClient.php',
    r'Copyright \d{4}',
    'Copyright 2017')
for client in ['ErrorGroupService', 'ErrorStatsService', 'ReportErrorsService']:
    s.replace(
Esempio n. 32
0
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()

for version in ['V2', 'V2beta2', 'V2beta3']:
    lower_version = version.lower()
    library = gapic.php_library(
        service='tasks',
        version=lower_version,
        config_path=f'artman_cloudtasks_{lower_version}.yaml',
        artman_output_name=f'google-cloud-tasks-{lower_version}')

    # copy all src including partial veneer classes
    s.move(library / 'src')

    # copy proto files to src also
    s.move(library / f'proto/src/Google/Cloud/Tasks', f'src/')
    s.move(library / f'tests/')

    # copy GPBMetadata file to metadata
    s.move(library / f'proto/src/GPBMetadata/Google/Cloud/Tasks', f'metadata/')

# fix year
s.replace(
    'src/V2beta*/**/*.php',
    r'Copyright \d{4}',
    r'Copyright 2018')
s.replace(
    'tests/*/V2beta*/*Test.php',
Esempio n. 33
0
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

library = gapic.php_library(
    service='datastore',
    version='v1',
    config_path='/google/datastore/artman_datastore.yaml',
    artman_output_name='google-cloud-datastore-v1')

# copy all src including partial veneer classes
s.move(library / 'src')

# copy proto files to src also
s.move(library / 'proto/src/Google/Cloud/Datastore', 'src/')
s.move(library / 'tests/')

# copy GPBMetadata file to metadata
s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Datastore', 'metadata/')

# fix year
s.replace(
    '**/Gapic/*GapicClient.php',
    r'Copyright \d{4}',
    'Copyright 2018')
s.replace(
    '**/V1/DatastoreClient.php',
Esempio n. 34
0
import synthtool as s
import synthtool.gcp as gcp
import logging
import os

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

library = gapic.php_library(
    service='automl',
    version='v1beta1',
    config_path='/google/cloud/automl/artman_automl_v1beta1.yaml',
    artman_output_name='google-cloud-automl-v1beta1')

# copy all src including partial veneer classes
s.move(library / 'src')

# copy proto files to src also
s.move(library / 'proto/src/Google/Cloud/AutoMl', 'src/')
s.move(library / 'tests/')

# copy GPBMetadata file to metadata
s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Automl', 'metadata/')

# fix year
s.replace('**/Gapic/*GapicClient.php', r'Copyright \d{4}', r'Copyright 2019')
s.replace('tests/**/V1beta1/*Test.php', r'Copyright \d{4}', r'Copyright 2019')
Esempio n. 35
0
gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate spanner GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    "spanner",
    "v1",
    config_path="/google/spanner/artman_spanner.yaml",
    artman_output_name="spanner-v1",
    include_protos=True,
)

s.move(library / "google/cloud/spanner_v1/proto")
s.move(library / "google/cloud/spanner_v1/gapic")
s.move(library / "tests")

# Add grpcio-gcp options
s.replace(
    "google/cloud/spanner_v1/gapic/transports/spanner_grpc_transport.py",
    "# limitations under the License.\n" "\n" "import google.api_core.grpc_helpers\n",
    "# limitations under the License.\n"
    "\n"
    "import pkg_resources\n"
    "import grpc_gcp\n"
    "\n"
    "import google.api_core.grpc_helpers\n",
)
s.replace(
Esempio n. 36
0
            name \(str\): Required. Redis instance resource name using the form:
                ::

                    `projects/{project_id}/locations/{location_id}/instances/{instance_id}`
                where ``location_id`` refers to a GCP region""",
    r"""
            name (str): Required. Redis instance resource name using the form ``projects/{project_id}/locations/{location_id}/instances/{instance_id}```
                where ``location_id`` refers to a GCP region""",
)

s.replace(
    "google/cloud/**/cloud_redis_client.py",
    r"""
                fields from ``Instance``:

                 \*   ``displayName``
                 \*   ``labels``
                 \*   ``memorySizeGb``
                 \*   ``redisConfig``""",
    r"""
                fields from ``Instance``: ``displayName``, ``labels``, ``memorySizeGb``, and ``redisConfig``.""",
)

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=87)
s.move(templated_files)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
Esempio n. 37
0
# Restore updated example from PR #7025.
s.replace(
    "google/cloud/tasks_v2beta3/gapic/cloud_tasks_client.py",
    ">>> # TODO: Initialize `queue`:",
    ">>> # Initialize `queue`:",
)
s.replace(
    "google/cloud/tasks_v2beta3/gapic/cloud_tasks_client.py",
    "^(\s+)>>> queue = {}\n",
    "\g<1>>>> queue = {\n"
    "\g<1>...     # The fully qualified path to the queue\n"
    "\g<1>...     'name': client.queue_path('[PROJECT]', '[LOCATION]', '[NAME]'),\n"
    "\g<1>...     'app_engine_http_queue': {\n"
    "\g<1>...         'app_engine_routing_override': {\n"
    "\g<1>...             # The App Engine service that will receive the tasks.\n"
    "\g<1>...             'service': 'default',\n"
    "\g<1>...         },\n"
    "\g<1>...     },\n"
    "\g<1>... }\n",
)


# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
Esempio n. 38
0
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

library = gapic.php_library(
    service='dlp',
    version='v2',
    config_path='/google/privacy/dlp/artman_dlp_v2.yaml',
    artman_output_name='google-cloud-dlp-v2')

# copy all src including partial veneer classes
s.move(library / 'src')

# copy proto files to src also
s.move(library / 'proto/src/Google/Cloud/Dlp', 'src/')
s.move(library / 'tests/')

# copy GPBMetadata file to metadata
s.move(library / 'proto/src/GPBMetadata/Google/Privacy/Dlp', 'metadata/')

# document and utilize apiEndpoint instead of serviceAddress
s.replace("**/Gapic/*GapicClient.php", r"'serviceAddress' =>",
          r"'apiEndpoint' =>")
s.replace(
    "**/Gapic/*GapicClient.php",
    r"@type string \$serviceAddress\n\s+\*\s+The address",
    r"""@type string $serviceAddress
Esempio n. 39
0
gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate trace GAPIC layer
# ----------------------------------------------------------------------------
for version in ["v1", "v2"]:
    library = gapic.py_library(
        "trace",
        version,
        config_path=f"/google/devtools/cloudtrace" f"/artman_cloudtrace_{version}.yaml",
        artman_output_name=f"trace-{version}",
    )

    s.move(library / f"google/cloud/trace_{version}")
    s.move(library / f"tests/unit/gapic/{version}")

    # Fix up imports
    s.replace(
        "google/**/*.py",
        f"from google.devtools.cloudtrace_{version}.proto import ",
        f"from google.cloud.trace_{version}.proto import ",
    )

# Issues exist where python files should define the source encoding
# https://github.com/googleapis/gapic-generator/issues/2097
s.replace("google/**/proto/*_pb2.py", r"(^.*$\n)*", r"# -*- coding: utf-8 -*-\n\g<0>")

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
# Generate transcoder GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    service="transcoder",
    version="v1beta1",
    bazel_target=
    "//google/cloud/video/transcoder/v1beta1:video-transcoder-v1beta1-py",
)

s.move(
    library,
    excludes=[
        "setup.py",
        "docs/index.rst",
        "noxfile.py",
        "scripts/fixup_transcoder_v1beta1_keywords.py",
    ],
)

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(cov_level=99, microgenerator=True)
s.move(templated_files,
       excludes=[".coveragerc"
                 ])  # the microgenerator has a good coveragerc file

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
Esempio n. 41
0
# limitations under the License.

"""This script is used to synthesize generated parts of this library."""
import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()
versions = ["v1beta1", "v1"]

# ----------------------------------------------------------------------------
# Generate securitycenter GAPIC layer
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("securitycenter", version, include_protos=True)
    s.move(library / f"google/cloud/securitycenter_{version}")
    s.move(library / f"tests/unit/gapic/{version}")
    s.move(library / f"docs/gapic/{version}")

# Use the highest version library to generate import alias.
s.move(library / "google/cloud/securitycenter.py")

# Add encoding header to protoc-generated files.
# See: https://github.com/googleapis/gapic-generator/issues/2097
s.replace("**/proto/*_pb2.py", r"(^.*$\n)*", r"# -*- coding: utf-8 -*-\n\g<0>")

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files, excludes=['noxfile.py'])
Esempio n. 42
0
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICBazel()
common = gcp.CommonTemplates()

library = gapic.php_library(
    service='policytroubleshooter',
    version='V1',
    bazel_target=
    '//google/cloud/policytroubleshooter/v1:google-cloud-policytroubleshooter-v1-php',
)

# copy all src including partial veneer classes
s.move(library / 'src')

# copy proto files to src also
s.move(library / 'proto/src/Google/Cloud/PolicyTroubleshooter', 'src/')
s.move(library / 'tests/')

# copy GPBMetadata file to metadata
s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Policytroubleshooter',
       'metadata/')

# document and utilize apiEndpoint instead of serviceAddress
s.replace("**/Gapic/*GapicClient.php", r"'serviceAddress' =>",
          r"'apiEndpoint' =>")
s.replace(
    "**/Gapic/*GapicClient.php",
    r"@type string \$serviceAddress\n\s+\*\s+The address",
Esempio n. 43
0
# ----------------------------------------------------------------------------
# Generate websecurityscanner GAPIC layer
# ----------------------------------------------------------------------------
versions = ["v1alpha", "v1beta"]

for version in versions:
	library = gapic.py_library(
	    "websecurityscanner",
	    version,
	    config_path=f"/google/cloud/websecurityscanner"
	    f"/artman_websecurityscanner_{version}.yaml",
	    artman_output_name=f"websecurityscanner-{version}",
	    include_protos=True,
	)

	s.move(library / f"google/cloud/websecurityscanner_{version}/proto")
	s.move(library / f"google/cloud/websecurityscanner_{version}/gapic")
	s.move(library / f"google/cloud/websecurityscanner_{version}/*.py")
	s.move(library / f"docs/gapic/{version}")
	s.move(library / f"tests/unit/gapic/{version}")

s.move(library / "google/cloud/websecurityscanner.py")

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
Esempio n. 44
0
gapic = gcp.GAPICBazel()
common = gcp.CommonTemplates()

for ver in ['V1', 'V1beta1']:
    lower_version = ver.lower()

    library = gapic.php_library(
        service='firestore',
        version=lower_version,
        bazel_target=
        f'//google/firestore/{lower_version}:google-cloud-firestore-{lower_version}-php',
    )

    # copy all src except partial veneer classes
    s.move(library / f'src/{ver}/Gapic')
    s.move(library / f'src/{ver}/resources')

    # copy proto files to src also
    s.move(library / f'proto/src/Google/Cloud/Firestore', f'src/')
    s.move(library / f'tests/')

    # copy GPBMetadata file to metadata
    s.move(library / f'proto/src/GPBMetadata/Google/Firestore', f'metadata/')

# Firestore Admin also lives here
admin_library = gapic.php_library(
    service='firestore-admin',
    version='v1',
    bazel_target=
    f'//google/firestore/admin/v1:google-cloud-firestore-admin-v1-php',
Esempio n. 45
0
import re

import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()
versions = ["v1beta2", "v1"]

# ----------------------------------------------------------------------------
# Generate dataproc GAPIC layer
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("dataproc", version)
    s.move(library, excludes=["docs/index.rst", "nox.py", "README.rst", "setup.py"])

    s.replace(
        f"google/cloud/dataproc_{version}/gapic/cluster_controller_client.py",
        "metadata_type=operations_pb2.ClusterOperationMetadata,",
        "metadata_type=proto_operations_pb2.ClusterOperationMetadata,",
    )

    s.replace(
        f"google/cloud/dataproc_{version}/gapic/cluster_controller_client.py",
        "\s+<strong>Note:</strong>.*\n(.*\n)+?.*types.FieldMask.",
        f"""


                .. note::
Esempio n. 46
0
library = gapic.py_library(
    service="bigquery",
    version=version,
    bazel_target=f"//google/cloud/bigquery/{version}:bigquery-{version}-py",
    include_protos=True,
)

s.move(
    library,
    excludes=[
        "docs/index.rst",
        "README.rst",
        "noxfile.py",
        "setup.py",
        library / f"google/cloud/bigquery/__init__.py",
        library / f"google/cloud/bigquery/py.typed",
        # There are no public API endpoints for the generated ModelServiceClient,
        # thus there's no point in generating it and its tests.
        library / f"google/cloud/bigquery_{version}/services/**",
        library / f"tests/unit/gapic/bigquery_{version}/**",
    ],
)

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(
    cov_level=100,
    samples=True,
    microgenerator=True,
Esempio n. 47
0
excludes = ["setup.py", "nox*.py", "README.rst", "docs/conf.py", "docs/index.rst", 
            "translation.py"]

# ----------------------------------------------------------------------------
# Generate asset GAPIC layer
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library(
        "translate",
        version,
        include_protos=True,
    )

    #s.move(library / f'google/cloud/translation_{version}', f'google/cloud/translate_{version}', excludes=excludes)
    s.move(library / f'google/cloud/translate_{version}', excludes=excludes)
    s.move(library / 'tests')
    s.move(library / f"docs/gapic/{version}")

# translation -> translate
s.replace(
    "google/**/translation_service_pb2_grpc.py",
    "google.cloud.translation_v3beta1.proto",
    "google.cloud.translate_v3beta1.proto",
)

s.replace(
    "google/cloud/**/translation_service_pb2.py",
    r"""record delimiters are ':raw-latex:`\\n`' instead of
          ':raw-latex:`\\r`:raw-latex:`\\n`'.""",
    r"""record delimiters are ``\\\\\\\\n`` instead of
Esempio n. 48
0
import re

import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()

version = 'v1'

library = gapic.py_library('pubsub',
                           version,
                           config_path='/google/pubsub/artman_pubsub.yaml')
s.move(library,
       excludes=[
           'docs/**/*', 'nox.py', 'README.rst', 'setup.py',
           'google/cloud/pubsub_v1/__init__.py',
           'google/cloud/pubsub_v1/types.py'
       ])

# Adjust tests to import the clients directly.
s.replace('tests/unit/gapic/v1/test_publisher_client_v1.py',
          'from google.cloud import pubsub_v1',
          'from google.cloud.pubsub_v1.gapic import publisher_client')

s.replace('tests/unit/gapic/v1/test_publisher_client_v1.py', ' pubsub_v1',
          ' publisher_client')

s.replace('tests/unit/gapic/v1/test_subscriber_client_v1.py',
          'from google.cloud import pubsub_v1',
          'from google.cloud.pubsub_v1.gapic import subscriber_client')
Esempio n. 49
0
import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()
versions = ["v1", "v1p1beta1", "v1p2beta1", "v1p3beta1", "v1p4beta1"]


# ----------------------------------------------------------------------------
# Generate vision GAPIC layer
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("vision", version, include_protos=True)

    s.move(library / f"google/cloud/vision_{version}/gapic")
    s.move(library / f"google/cloud/vision_{version}/__init__.py")
    s.move(library / f"google/cloud/vision_{version}/types.py")
    s.move(library / f"google/cloud/vision_{version}/proto")
    s.move(library / f"tests/unit/gapic/{version}")
    # don't publish docs for these versions
    if version not in ["v1p1beta1"]:
        s.move(library / f"docs/gapic/{version}")

    # Add vision helpers to each version
    s.replace(
        f"google/cloud/vision_{version}/__init__.py",
        f"from __future__ import absolute_import",
        f"\g<0>\n\n"
        f"from google.cloud.vision_helpers.decorators import "
        f"add_single_feature_methods\n"
Esempio n. 50
0
# 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.

"""This script is used to synthesize generated parts of this library."""
import synthtool as s
from synthtool import gcp
from synthtool.languages import python

common = gcp.CommonTemplates()

default_version = "v1beta1"

for library in s.get_staging_dirs(default_version):
    s.move(library, excludes=["nox.py", "setup.py", "README.rst", "docs/index.rst", "google/cloud/errorreporting/"])

s.remove_staging_dirs()

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(
    samples=True,  # set to True only if there are samples
    microgenerator=True,
    cov_level=98,
)
s.move(templated_files, excludes=[".coveragerc"])  # microgenerator has a good .coveragerc file

# ----------------------------------------------------------------------------
# Samples templates
Esempio n. 51
0
"""This script is used to synthesize generated parts of this library."""
import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate iot GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    "iot",
    "v1",
    config_path="/google/cloud/iot/artman_cloudiot.yaml",
    artman_output_name="iot-v1",
    include_protos=True,
)

s.move(library / "google/cloud/iot_v1")
s.move(library / "tests/unit/gapic")
s.move(library / "tests/system/gapic")
s.move(library / "docs", excludes="index.rst")

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=80, cov_level=80)
s.move(templated_files)

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
Esempio n. 52
0
logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

v1beta = gapic.php_library(service='oslogin',
                           version='v1beta',
                           artman_output_name='google-cloud-os-login-v1beta')

v1 = gapic.php_library(service='oslogin',
                       version='v1',
                       artman_output_name='google-cloud-os-login-v1')

# copy all src
s.move(v1beta / f'src/V1beta')
s.move(v1 / f'src/V1')

# copy proto files to src also
s.move(v1beta / f'proto/src/Google/Cloud/OsLogin', f'src/')
s.move(v1 / f'proto/src/Google/Cloud/OsLogin', f'src/')

s.move(v1beta / f'tests/')
s.move(v1 / f'tests/')

# copy GPBMetadata file to metadata
s.move(v1beta / f'proto/src/GPBMetadata/Google/Cloud/Oslogin', f'metadata/')
s.move(v1 / f'proto/src/GPBMetadata/Google/Cloud/Oslogin', f'metadata/')

# fix copyright year
s.replace('src/V1beta/**/*.php', r'Copyright \d{4}', r'Copyright 2017')
Esempio n. 53
0
version = "v1beta1"

library = gapic.py_library(
    "bigquery_storage",
    version,
    config_path="/google/cloud/bigquery/storage/" "artman_bigquerystorage_v1beta1.yaml",
    artman_output_name="bigquerystorage-v1beta1",
    include_protos=True,
)

s.move(
    library,
    excludes=[
        "docs/conf.py",
        "docs/index.rst",
        "google/cloud/bigquery_storage_v1beta1/__init__.py",
        "README.rst",
        "nox*.py",
        "setup.py",
        "setup.cfg",
    ],
)

s.replace(
    [
        "google/cloud/bigquery_storage_v1beta1/proto/storage_pb2.py",
        "google/cloud/bigquery_storage_v1beta1/proto/storage_pb2_grpc.py",
    ],
    "from google.cloud.bigquery.storage_v1beta1.proto",
    "from google.cloud.bigquery_storage_v1beta1.proto",
)
Esempio n. 54
0
gapic = gcp.GAPICBazel()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate dlp GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    service="dlp",
    version="v2",
    bazel_target="//google/privacy/dlp/v2:privacy-dlp-v2-py",
    include_protos=True,
    proto_output_path=f"google/cloud/dlp_v2/proto",
)

excludes = ["README.rst", "nox.py", "setup.py", "docs/index.rst"]
s.move(library, excludes=excludes)

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(system_test_dependencies=["test_utils"],
                                    samples=True,
                                    microgenerator=True,
                                    cov_level=98)
s.move(templated_files,
       excludes=[".coveragerc"])  # microgenerator has a good .coveragerc file

# ----------------------------------------------------------------------------
# Samples templates
# ----------------------------------------------------------------------------
python.py_samples()
Esempio n. 55
0
import synthtool.gcp as gcp
import logging

logging.basicConfig(level=logging.DEBUG)

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

library = gapic.php_library(
    service='bigquerydatatransfer',
    version='v1',
    config_path='/google/cloud/bigquery/datatransfer/artman_bigquerydatatransfer.yaml',
    artman_output_name='google-cloud-bigquerydatatransfer-v1')

# copy all src including partial veneer classes
s.move(library / 'src')

# copy proto files to src also
s.move(library / 'proto/src/Google/Cloud/BigQuery/DataTransfer', 'src/')
s.move(library / 'tests/')

# copy GPBMetadata file to metadata
s.move(library / 'proto/src/GPBMetadata/Google/Cloud/Bigquery/Datatransfer', 'metadata/')

# fix year
s.replace(
    '**/Gapic/*GapicClient.php',
    r'Copyright \d{4}',
    'Copyright 2017')
s.replace(
    '**/V1/DataTransferServiceClient.php',
Esempio n. 56
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.
"""This script is used to synthesize generated parts of this library."""
import synthtool as s
from synthtool import gcp

gapic = gcp.GAPICGenerator()

#----------------------------------------------------------------------------
# Generate oslogin client
#----------------------------------------------------------------------------
library = gapic.py_library(
    'oslogin',
    'v1',
    config_path='/google/cloud/oslogin/artman_oslogin_v1.yaml',
    artman_output_name='os-login-v1')

s.move(library / 'google/cloud/oslogin_v1')
s.move(library / 'tests/unit/gapic/v1')

# Fix up imports
s.replace(
    'google/**/proto/*.py',
    'from google.cloud.oslogin.common import common_pb2',
    'from google.cloud.oslogin_v1.proto import common_pb2',
)
Esempio n. 57
0
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()
versions = ["v1beta1"]

# ----------------------------------------------------------------------------
# Generate webrisk GAPIC layer
# ----------------------------------------------------------------------------
for version in versions:
    library = gapic.py_library("webrisk", version, include_protos=True)
    s.copy(library, excludes=["docs/index.rst", "nox.py", "README.rst", "setup.py"])


# Fix docstring issue for classes with no summary line
s.replace(
    "google/cloud/**/proto/webrisk_pb2.py",
    '''__doc__ = """Attributes:''',
    '''__doc__ = """
    Attributes:''',
)


# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files, excludes=["noxfile.py"])

s.shell.run(["nox", "-s", "blacken"], hide_output=False)
Esempio n. 58
0
from synthtool import gcp

gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate bigtable and bigtable_admin GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    "bigtable",
    "v2",
    config_path="/google/bigtable/artman_bigtable.yaml",
    artman_output_name="bigtable-v2",
)

s.move(library / "google/cloud/bigtable_v2")
s.move(library / "tests")

# Generate admin client
library = gapic.py_library(
    "bigtable_admin",
    "v2",
    config_path="/google/bigtable/admin/artman_bigtableadmin.yaml",
    artman_output_name="bigtable-admin-v2",
)

s.move(library / "google/cloud/bigtable_admin_v2")
s.move(library / "tests")

s.replace(
    [
Esempio n. 59
0
gapic = gcp.GAPICGenerator()
common = gcp.CommonTemplates()

# ----------------------------------------------------------------------------
# Generate oslogin GAPIC layer
# ----------------------------------------------------------------------------
library = gapic.py_library(
    "oslogin",
    "v1",
    config_path="/google/cloud/oslogin/artman_oslogin_v1.yaml",
    artman_output_name="os-login-v1",
    include_protos=True,
)

s.move(library / "google/cloud/oslogin_v1")
s.move(library / "tests/unit/gapic/v1")

# Fix up imports
s.replace(
    "google/**/proto/*.py",
    "from google.cloud.oslogin.common import common_pb2",
    "from google.cloud.oslogin_v1.proto import common_pb2",
)

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------
templated_files = common.py_library(unit_cov_level=97, cov_level=100)
s.move(templated_files)
Esempio n. 60
0
        f"tests/unit/gapic/aiplatform_{library.name}/test_prediction_service.py",
        """def test_explain_flattened.*?def test_explain_flattened_error""",
        "def test_explain_flattened_error",
        flags=re.MULTILINE | re.DOTALL,
    )

    s.move(
        library,
        excludes=[
            ".pre-commit-config.yaml",
            "setup.py",
            "README.rst",
            "docs/index.rst",
            f"docs/definition_{library.name}/services.rst",
            f"docs/instance_{library.name}/services.rst",
            f"docs/params_{library.name}/services.rst",
            f"docs/prediction_{library.name}/services.rst",
            f"scripts/fixup_aiplatform_{library.name}_keywords.py",
            f"scripts/fixup_definition_{library.name}_keywords.py",
            f"scripts/fixup_instance_{library.name}_keywords.py",
            f"scripts/fixup_params_{library.name}_keywords.py",
            f"scripts/fixup_prediction_{library.name}_keywords.py",
            "google/cloud/aiplatform/__init__.py",
            f"google/cloud/aiplatform/{library.name}/schema/**/services/",
        ],
    )

s.remove_staging_dirs()

# ----------------------------------------------------------------------------
# Add templated files
# ----------------------------------------------------------------------------