Skip to content

Commit 1028946

Browse files
authored
feat: add v1 api for google-cloud-maintenance-api (#14998)
PR created by the Librarian CLI to onboard a new Cloud Client Library. BEGIN_COMMIT feat: onboard a new library PiperOrigin-RevId: 845900064 Library-IDs: google-cloud-maintenance-api END_COMMIT Librarian Version: v0.7.0 Language Image: us-central1-docker.pkg.dev/cloud-sdk-librarian-prod/images-prod/python-librarian-generator@sha256:b8058df4c45e9a6e07f6b4d65b458d0d059241dd34c814f151c8bf6b89211209
1 parent b3cb4de commit 1028946

35 files changed

+12310
-6
lines changed

.librarian/generator-input/packages/google-cloud-maintenance-api/.repo-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"repo": "googleapis/google-cloud-python",
1212
"distribution_name": "google-cloud-maintenance-api",
1313
"api_id": "api.googleapis.com",
14-
"default_version": "v1beta",
14+
"default_version": "v1",
1515
"api_shortname": "api"
1616
}

.librarian/state.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2227,10 +2227,12 @@ libraries:
22272227
tag_format: '{id}-v{version}'
22282228
- id: google-cloud-maintenance-api
22292229
version: 0.2.0
2230-
last_generated_commit: effe5c4fa816021e724ca856d5640f2e55b14a8b
2230+
last_generated_commit: 211d22fa6dfabfa52cbda04d1aee852a01301edf
22312231
apis:
22322232
- path: google/cloud/maintenance/api/v1beta
22332233
service_config: maintenance_v1beta.yaml
2234+
- path: google/cloud/maintenance/api/v1
2235+
service_config: maintenance_v1.yaml
22342236
source_roots:
22352237
- packages/google-cloud-maintenance-api
22362238
preserve_regex:

packages/google-cloud-maintenance-api/.repo-metadata.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,6 @@
1111
"repo": "googleapis/google-cloud-python",
1212
"distribution_name": "google-cloud-maintenance-api",
1313
"api_id": "api.googleapis.com",
14-
"default_version": "v1beta",
14+
"default_version": "v1",
1515
"api_shortname": "api"
1616
}

packages/google-cloud-maintenance-api/docs/index.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,17 @@
22

33
.. include:: multiprocessing.rst
44

5+
This package includes clients for multiple versions of Maintenance API.
6+
By default, you will get version ``maintenance_api_v1``.
7+
8+
9+
API Reference
10+
-------------
11+
.. toctree::
12+
:maxdepth: 2
13+
14+
maintenance_api_v1/services_
15+
maintenance_api_v1/types_
516

617
API Reference
718
-------------
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
Maintenance
2+
-----------------------------
3+
4+
.. automodule:: google.cloud.maintenance_api_v1.services.maintenance
5+
:members:
6+
:inherited-members:
7+
8+
.. automodule:: google.cloud.maintenance_api_v1.services.maintenance.pagers
9+
:members:
10+
:inherited-members:
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Services for Google Cloud Maintenance Api v1 API
2+
================================================
3+
.. toctree::
4+
:maxdepth: 2
5+
6+
maintenance
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Types for Google Cloud Maintenance Api v1 API
2+
=============================================
3+
4+
.. automodule:: google.cloud.maintenance_api_v1.types
5+
:members:
6+
:show-inheritance:

packages/google-cloud-maintenance-api/google/cloud/maintenance_api/__init__.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,13 @@
1818
__version__ = package_version.__version__
1919

2020

21-
from google.cloud.maintenance_api_v1beta.services.maintenance.async_client import (
21+
from google.cloud.maintenance_api_v1.services.maintenance.async_client import (
2222
MaintenanceAsyncClient,
2323
)
24-
from google.cloud.maintenance_api_v1beta.services.maintenance.client import (
24+
from google.cloud.maintenance_api_v1.services.maintenance.client import (
2525
MaintenanceClient,
2626
)
27-
from google.cloud.maintenance_api_v1beta.types.maintenance_service import (
27+
from google.cloud.maintenance_api_v1.types.maintenance_service import (
2828
GetResourceMaintenanceRequest,
2929
ListResourceMaintenancesRequest,
3030
ListResourceMaintenancesResponse,
Lines changed: 150 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,150 @@
1+
# -*- coding: utf-8 -*-
2+
# Copyright 2025 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+
import sys
17+
18+
import google.api_core as api_core
19+
20+
from google.cloud.maintenance_api_v1 import gapic_version as package_version
21+
22+
__version__ = package_version.__version__
23+
24+
if sys.version_info >= (3, 8): # pragma: NO COVER
25+
from importlib import metadata
26+
else: # pragma: NO COVER
27+
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
28+
# this code path once we drop support for Python 3.7
29+
import importlib_metadata as metadata
30+
31+
from .services.maintenance import MaintenanceAsyncClient, MaintenanceClient
32+
from .types.maintenance_service import (
33+
GetResourceMaintenanceRequest,
34+
ListResourceMaintenancesRequest,
35+
ListResourceMaintenancesResponse,
36+
MaintenanceCategory,
37+
MaintenanceControl,
38+
MaintenanceSummary,
39+
ResourceMaintenance,
40+
SummarizeMaintenancesRequest,
41+
SummarizeMaintenancesResponse,
42+
)
43+
44+
if hasattr(api_core, "check_python_version") and hasattr(
45+
api_core, "check_dependency_versions"
46+
): # pragma: NO COVER
47+
api_core.check_python_version("google.cloud.maintenance_api_v1") # type: ignore
48+
api_core.check_dependency_versions("google.cloud.maintenance_api_v1") # type: ignore
49+
else: # pragma: NO COVER
50+
# An older version of api_core is installed which does not define the
51+
# functions above. We do equivalent checks manually.
52+
try:
53+
import sys
54+
import warnings
55+
56+
_py_version_str = sys.version.split()[0]
57+
_package_label = "google.cloud.maintenance_api_v1"
58+
if sys.version_info < (3, 9):
59+
warnings.warn(
60+
"You are using a non-supported Python version "
61+
+ f"({_py_version_str}). Google will not post any further "
62+
+ f"updates to {_package_label} supporting this Python version. "
63+
+ "Please upgrade to the latest Python version, or at "
64+
+ f"least to Python 3.9, and then update {_package_label}.",
65+
FutureWarning,
66+
)
67+
if sys.version_info[:2] == (3, 9):
68+
warnings.warn(
69+
f"You are using a Python version ({_py_version_str}) "
70+
+ f"which Google will stop supporting in {_package_label} in "
71+
+ "January 2026. Please "
72+
+ "upgrade to the latest Python version, or at "
73+
+ "least to Python 3.10, before then, and "
74+
+ f"then update {_package_label}.",
75+
FutureWarning,
76+
)
77+
78+
def parse_version_to_tuple(version_string: str):
79+
"""Safely converts a semantic version string to a comparable tuple of integers.
80+
Example: "4.25.8" -> (4, 25, 8)
81+
Ignores non-numeric parts and handles common version formats.
82+
Args:
83+
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
84+
Returns:
85+
Tuple of integers for the parsed version string.
86+
"""
87+
parts = []
88+
for part in version_string.split("."):
89+
try:
90+
parts.append(int(part))
91+
except ValueError:
92+
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
93+
# This is a simplification compared to 'packaging.parse_version', but sufficient
94+
# for comparing strictly numeric semantic versions.
95+
break
96+
return tuple(parts)
97+
98+
def _get_version(dependency_name):
99+
try:
100+
version_string: str = metadata.version(dependency_name)
101+
parsed_version = parse_version_to_tuple(version_string)
102+
return (parsed_version, version_string)
103+
except Exception:
104+
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
105+
# or errors during parse_version_to_tuple
106+
return (None, "--")
107+
108+
_dependency_package = "google.protobuf"
109+
_next_supported_version = "4.25.8"
110+
_next_supported_version_tuple = (4, 25, 8)
111+
_recommendation = " (we recommend 6.x)"
112+
(_version_used, _version_used_string) = _get_version(_dependency_package)
113+
if _version_used and _version_used < _next_supported_version_tuple:
114+
warnings.warn(
115+
f"Package {_package_label} depends on "
116+
+ f"{_dependency_package}, currently installed at version "
117+
+ f"{_version_used_string}. Future updates to "
118+
+ f"{_package_label} will require {_dependency_package} at "
119+
+ f"version {_next_supported_version} or higher{_recommendation}."
120+
+ " Please ensure "
121+
+ "that either (a) your Python environment doesn't pin the "
122+
+ f"version of {_dependency_package}, so that updates to "
123+
+ f"{_package_label} can require the higher version, or "
124+
+ "(b) you manually update your Python environment to use at "
125+
+ f"least version {_next_supported_version} of "
126+
+ f"{_dependency_package}.",
127+
FutureWarning,
128+
)
129+
except Exception:
130+
warnings.warn(
131+
"Could not determine the version of Python "
132+
+ "currently being used. To continue receiving "
133+
+ "updates for {_package_label}, ensure you are "
134+
+ "using a supported version of Python; see "
135+
+ "https://devguide.python.org/versions/"
136+
)
137+
138+
__all__ = (
139+
"MaintenanceAsyncClient",
140+
"GetResourceMaintenanceRequest",
141+
"ListResourceMaintenancesRequest",
142+
"ListResourceMaintenancesResponse",
143+
"MaintenanceCategory",
144+
"MaintenanceClient",
145+
"MaintenanceControl",
146+
"MaintenanceSummary",
147+
"ResourceMaintenance",
148+
"SummarizeMaintenancesRequest",
149+
"SummarizeMaintenancesResponse",
150+
)
Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
{
2+
"comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
3+
"language": "python",
4+
"libraryPackage": "google.cloud.maintenance_api_v1",
5+
"protoPackage": "google.cloud.maintenance.api.v1",
6+
"schema": "1.0",
7+
"services": {
8+
"Maintenance": {
9+
"clients": {
10+
"grpc": {
11+
"libraryClient": "MaintenanceClient",
12+
"rpcs": {
13+
"GetResourceMaintenance": {
14+
"methods": [
15+
"get_resource_maintenance"
16+
]
17+
},
18+
"ListResourceMaintenances": {
19+
"methods": [
20+
"list_resource_maintenances"
21+
]
22+
},
23+
"SummarizeMaintenances": {
24+
"methods": [
25+
"summarize_maintenances"
26+
]
27+
}
28+
}
29+
},
30+
"grpc-async": {
31+
"libraryClient": "MaintenanceAsyncClient",
32+
"rpcs": {
33+
"GetResourceMaintenance": {
34+
"methods": [
35+
"get_resource_maintenance"
36+
]
37+
},
38+
"ListResourceMaintenances": {
39+
"methods": [
40+
"list_resource_maintenances"
41+
]
42+
},
43+
"SummarizeMaintenances": {
44+
"methods": [
45+
"summarize_maintenances"
46+
]
47+
}
48+
}
49+
},
50+
"rest": {
51+
"libraryClient": "MaintenanceClient",
52+
"rpcs": {
53+
"GetResourceMaintenance": {
54+
"methods": [
55+
"get_resource_maintenance"
56+
]
57+
},
58+
"ListResourceMaintenances": {
59+
"methods": [
60+
"list_resource_maintenances"
61+
]
62+
},
63+
"SummarizeMaintenances": {
64+
"methods": [
65+
"summarize_maintenances"
66+
]
67+
}
68+
}
69+
}
70+
}
71+
}
72+
}
73+
}

0 commit comments

Comments
 (0)