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

Commit 93a383f

Browse files
feat: add support for google.cloud.artifactregistry.__version__ (#199)
* chore: update to gapic-generator-python 1.5.0 feat: add support for `google.cloud.<api>.__version__` PiperOrigin-RevId: 484665853 Source-Link: googleapis/googleapis@8eb249a Source-Link: https://github.com/googleapis/googleapis-gen/commit/c8aa327b5f478865fc3fd91e3c2768e54e26ad44 Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiYzhhYTMyN2I1ZjQ3ODg2NWZjM2ZkOTFlM2MyNzY4ZTU0ZTI2YWQ0NCJ9 * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md * update version in gapic_version.py * add .release-please-manifest.json with correct version * add owlbot.py to exclude generated gapic_version.py * set manifest to true in .github/release-please.yml * add release-please-config.json * use autogenerated setup.py * add replacement to fix testing/constraints-3.7.txt Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com> Co-authored-by: Anthonios Partheniou <[email protected]>
1 parent c48da96 commit 93a383f

File tree

18 files changed

+212
-47
lines changed

18 files changed

+212
-47
lines changed

.github/release-please.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
releaseType: python
22
handleGHRelease: true
3+
manifest: true
34
# NOTE: this section is generated by synthtool.languages.python
45
# See https://github.com/googleapis/synthtool/blob/master/synthtool/languages/python.py
56
branches:

.release-please-manifest.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
".": "1.3.3"
3+
}

google/cloud/artifactregistry/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from google.cloud.artifactregistry import gapic_version as package_version
17+
18+
__version__ = package_version.__version__
19+
1620

1721
from google.cloud.artifactregistry_v1.services.artifact_registry.async_client import (
1822
ArtifactRegistryAsyncClient,
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2022 Google LLC
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
#
16+
__version__ = "1.3.3" # {x-release-please-version}

google/cloud/artifactregistry_v1/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from google.cloud.artifactregistry import gapic_version as package_version
17+
18+
__version__ = package_version.__version__
19+
1620

1721
from .services.artifact_registry import (
1822
ArtifactRegistryAsyncClient,

google/cloud/artifactregistry_v1/services/artifact_registry/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from collections import OrderedDict
1717
import os
1818
import re
19-
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
19+
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union, cast
2020

2121
from google.api_core import client_options as client_options_lib
2222
from google.api_core import exceptions as core_exceptions
@@ -527,7 +527,7 @@ def __init__(
527527
*,
528528
credentials: Optional[ga_credentials.Credentials] = None,
529529
transport: Union[str, ArtifactRegistryTransport, None] = None,
530-
client_options: Optional[client_options_lib.ClientOptions] = None,
530+
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
531531
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
532532
) -> None:
533533
"""Instantiates the artifact registry client.
@@ -541,7 +541,7 @@ def __init__(
541541
transport (Union[str, ArtifactRegistryTransport]): The
542542
transport to use. If set to None, a transport is chosen
543543
automatically.
544-
client_options (google.api_core.client_options.ClientOptions): Custom options for the
544+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
545545
client. It won't take effect if a ``transport`` instance is provided.
546546
(1) The ``api_endpoint`` property can be used to override the
547547
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
@@ -571,6 +571,7 @@ def __init__(
571571
client_options = client_options_lib.from_dict(client_options)
572572
if client_options is None:
573573
client_options = client_options_lib.ClientOptions()
574+
client_options = cast(client_options_lib.ClientOptions, client_options)
574575

575576
api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(
576577
client_options

google/cloud/artifactregistry_v1beta2/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,10 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515
#
16+
from google.cloud.artifactregistry import gapic_version as package_version
17+
18+
__version__ = package_version.__version__
19+
1620

1721
from .services.artifact_registry import (
1822
ArtifactRegistryAsyncClient,

google/cloud/artifactregistry_v1beta2/services/artifact_registry/client.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from collections import OrderedDict
1717
import os
1818
import re
19-
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
19+
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union, cast
2020

2121
from google.api_core import client_options as client_options_lib
2222
from google.api_core import exceptions as core_exceptions
@@ -503,7 +503,7 @@ def __init__(
503503
*,
504504
credentials: Optional[ga_credentials.Credentials] = None,
505505
transport: Union[str, ArtifactRegistryTransport, None] = None,
506-
client_options: Optional[client_options_lib.ClientOptions] = None,
506+
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
507507
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
508508
) -> None:
509509
"""Instantiates the artifact registry client.
@@ -517,7 +517,7 @@ def __init__(
517517
transport (Union[str, ArtifactRegistryTransport]): The
518518
transport to use. If set to None, a transport is chosen
519519
automatically.
520-
client_options (google.api_core.client_options.ClientOptions): Custom options for the
520+
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
521521
client. It won't take effect if a ``transport`` instance is provided.
522522
(1) The ``api_endpoint`` property can be used to override the
523523
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
@@ -547,6 +547,7 @@ def __init__(
547547
client_options = client_options_lib.from_dict(client_options)
548548
if client_options is None:
549549
client_options = client_options_lib.ClientOptions()
550+
client_options = cast(client_options_lib.ClientOptions, client_options)
550551

551552
api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(
552553
client_options

owlbot.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
# Copyright 2022 Google LLC
2+
#
3+
# Licensed under the Apache License, Version 2.0 (the "License");
4+
# you may not use this file except in compliance with the License.
5+
# You may obtain a copy of the License at
6+
#
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
#
9+
# Unless required by applicable law or agreed to in writing, software
10+
# distributed under the License is distributed on an "AS IS" BASIS,
11+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12+
# See the License for the specific language governing permissions and
13+
# limitations under the License.
14+
15+
import json
16+
from pathlib import Path
17+
import shutil
18+
19+
import synthtool as s
20+
import synthtool.gcp as gcp
21+
from synthtool.languages import python
22+
23+
# ----------------------------------------------------------------------------
24+
# Copy the generated client from the owl-bot staging directory
25+
# ----------------------------------------------------------------------------
26+
27+
clean_up_generated_samples = True
28+
29+
# Load the default version defined in .repo-metadata.json.
30+
default_version = json.load(open(".repo-metadata.json", "rt")).get(
31+
"default_version"
32+
)
33+
34+
for library in s.get_staging_dirs(default_version):
35+
if clean_up_generated_samples:
36+
shutil.rmtree("samples/generated_samples", ignore_errors=True)
37+
clean_up_generated_samples = False
38+
39+
# remove replacement once a new gapic-generator-python version is released
40+
# which includes this fix https://github.com/googleapis/gapic-generator-python/pull/1483
41+
s.replace(
42+
library / "testing/constraints-3.7.txt",
43+
"grpc-google-iam-v1=0",
44+
"grpc-google-iam-v1==0",
45+
)
46+
47+
s.move([library], excludes=["**/gapic_version.py"])
48+
s.remove_staging_dirs()
49+
50+
# ----------------------------------------------------------------------------
51+
# Add templated files
52+
# ----------------------------------------------------------------------------
53+
54+
templated_files = gcp.CommonTemplates().py_library(
55+
cov_level=100,
56+
microgenerator=True,
57+
versions=gcp.common.detect_versions(path="./google", default_first=True),
58+
)
59+
s.move(templated_files, excludes=[".coveragerc", ".github/release-please.yml"])
60+
61+
python.py_samples(skip_readmes=True)
62+
63+
# run format session for all directories which have a noxfile
64+
for noxfile in Path(".").glob("**/noxfile.py"):
65+
s.shell.run(["nox", "-s", "format"], cwd=noxfile.parent, hide_output=False)

release-please-config.json

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "https://raw.githubusercontent.com/googleapis/release-please/main/schemas/config.json",
3+
"packages": {
4+
".": {
5+
"release-type": "python",
6+
"extra-files": [
7+
"google/cloud/artifactregistry/gapic_version.py",
8+
{
9+
"type": "json",
10+
"path": "samples/generated_samples/snippet_metadata_artifactregistry_v1.json",
11+
"jsonpath": "$.clientLibrary.version"
12+
},
13+
{
14+
"type": "json",
15+
"path": "samples/generated_samples/snippet_metadata_artifactregistry_v1beta2.json",
16+
"jsonpath": "$.clientLibrary.version"
17+
}
18+
]
19+
}
20+
},
21+
"release-type": "python",
22+
"plugins": [
23+
{
24+
"type": "sentence-case"
25+
}
26+
],
27+
"initial-version": "0.1.0"
28+
}

0 commit comments

Comments
 (0)