Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"repo": "googleapis/google-cloud-python",
"distribution_name": "google-cloud-maintenance-api",
"api_id": "api.googleapis.com",
"default_version": "v1beta",
"default_version": "v1",
"api_shortname": "api"
}
4 changes: 3 additions & 1 deletion .librarian/state.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2227,10 +2227,12 @@ libraries:
tag_format: '{id}-v{version}'
- id: google-cloud-maintenance-api
version: 0.2.0
last_generated_commit: effe5c4fa816021e724ca856d5640f2e55b14a8b
last_generated_commit: 211d22fa6dfabfa52cbda04d1aee852a01301edf
apis:
- path: google/cloud/maintenance/api/v1beta
service_config: maintenance_v1beta.yaml
- path: google/cloud/maintenance/api/v1
service_config: maintenance_v1.yaml
source_roots:
- packages/google-cloud-maintenance-api
preserve_regex:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,6 @@
"repo": "googleapis/google-cloud-python",
"distribution_name": "google-cloud-maintenance-api",
"api_id": "api.googleapis.com",
"default_version": "v1beta",
"default_version": "v1",
"api_shortname": "api"
}
11 changes: 11 additions & 0 deletions packages/google-cloud-maintenance-api/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,17 @@

.. include:: multiprocessing.rst

This package includes clients for multiple versions of Maintenance API.
By default, you will get version ``maintenance_api_v1``.


API Reference
-------------
.. toctree::
:maxdepth: 2

maintenance_api_v1/services_
maintenance_api_v1/types_

API Reference
-------------
Comment on lines +5 to 18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

The addition of a new API Reference section has resulted in a duplicate header, as the old one on lines 17-18 was not removed. This should be fixed to avoid confusion in the rendered documentation.

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Maintenance
-----------------------------

.. automodule:: google.cloud.maintenance_api_v1.services.maintenance
:members:
:inherited-members:

.. automodule:: google.cloud.maintenance_api_v1.services.maintenance.pagers
:members:
:inherited-members:
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Services for Google Cloud Maintenance Api v1 API
================================================
.. toctree::
:maxdepth: 2

maintenance
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
Types for Google Cloud Maintenance Api v1 API
=============================================

.. automodule:: google.cloud.maintenance_api_v1.types
:members:
:show-inheritance:
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
__version__ = package_version.__version__


from google.cloud.maintenance_api_v1beta.services.maintenance.async_client import (
from google.cloud.maintenance_api_v1.services.maintenance.async_client import (
MaintenanceAsyncClient,
)
from google.cloud.maintenance_api_v1beta.services.maintenance.client import (
from google.cloud.maintenance_api_v1.services.maintenance.client import (
MaintenanceClient,
)
from google.cloud.maintenance_api_v1beta.types.maintenance_service import (
from google.cloud.maintenance_api_v1.types.maintenance_service import (
GetResourceMaintenanceRequest,
ListResourceMaintenancesRequest,
ListResourceMaintenancesResponse,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,150 @@
# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.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.
#
import sys

import google.api_core as api_core

from google.cloud.maintenance_api_v1 import gapic_version as package_version

__version__ = package_version.__version__

if sys.version_info >= (3, 8): # pragma: NO COVER
from importlib import metadata
else: # pragma: NO COVER
# TODO(https://github.com/googleapis/python-api-core/issues/835): Remove
# this code path once we drop support for Python 3.7
import importlib_metadata as metadata

from .services.maintenance import MaintenanceAsyncClient, MaintenanceClient
from .types.maintenance_service import (
GetResourceMaintenanceRequest,
ListResourceMaintenancesRequest,
ListResourceMaintenancesResponse,
MaintenanceCategory,
MaintenanceControl,
MaintenanceSummary,
ResourceMaintenance,
SummarizeMaintenancesRequest,
SummarizeMaintenancesResponse,
)

if hasattr(api_core, "check_python_version") and hasattr(
api_core, "check_dependency_versions"
): # pragma: NO COVER
api_core.check_python_version("google.cloud.maintenance_api_v1") # type: ignore
api_core.check_dependency_versions("google.cloud.maintenance_api_v1") # type: ignore
else: # pragma: NO COVER
# An older version of api_core is installed which does not define the
# functions above. We do equivalent checks manually.
try:
import sys
import warnings

_py_version_str = sys.version.split()[0]
_package_label = "google.cloud.maintenance_api_v1"
if sys.version_info < (3, 9):
warnings.warn(
"You are using a non-supported Python version "
+ f"({_py_version_str}). Google will not post any further "
+ f"updates to {_package_label} supporting this Python version. "
+ "Please upgrade to the latest Python version, or at "
+ f"least to Python 3.9, and then update {_package_label}.",
FutureWarning,
)
if sys.version_info[:2] == (3, 9):
warnings.warn(
f"You are using a Python version ({_py_version_str}) "
+ f"which Google will stop supporting in {_package_label} in "
+ "January 2026. Please "
+ "upgrade to the latest Python version, or at "
+ "least to Python 3.10, before then, and "
+ f"then update {_package_label}.",
FutureWarning,
)

def parse_version_to_tuple(version_string: str):
"""Safely converts a semantic version string to a comparable tuple of integers.
Example: "4.25.8" -> (4, 25, 8)
Ignores non-numeric parts and handles common version formats.
Args:
version_string: Version string in the format "x.y.z" or "x.y.z<suffix>"
Returns:
Tuple of integers for the parsed version string.
"""
parts = []
for part in version_string.split("."):
try:
parts.append(int(part))
except ValueError:
# If it's a non-numeric part (e.g., '1.0.0b1' -> 'b1'), stop here.
# This is a simplification compared to 'packaging.parse_version', but sufficient
# for comparing strictly numeric semantic versions.
break
return tuple(parts)

def _get_version(dependency_name):
try:
version_string: str = metadata.version(dependency_name)
parsed_version = parse_version_to_tuple(version_string)
return (parsed_version, version_string)
except Exception:
# Catch exceptions from metadata.version() (e.g., PackageNotFoundError)
# or errors during parse_version_to_tuple
return (None, "--")

_dependency_package = "google.protobuf"
_next_supported_version = "4.25.8"
_next_supported_version_tuple = (4, 25, 8)
_recommendation = " (we recommend 6.x)"
(_version_used, _version_used_string) = _get_version(_dependency_package)
if _version_used and _version_used < _next_supported_version_tuple:
warnings.warn(
f"Package {_package_label} depends on "
+ f"{_dependency_package}, currently installed at version "
+ f"{_version_used_string}. Future updates to "
+ f"{_package_label} will require {_dependency_package} at "
+ f"version {_next_supported_version} or higher{_recommendation}."
+ " Please ensure "
+ "that either (a) your Python environment doesn't pin the "
+ f"version of {_dependency_package}, so that updates to "
+ f"{_package_label} can require the higher version, or "
+ "(b) you manually update your Python environment to use at "
+ f"least version {_next_supported_version} of "
+ f"{_dependency_package}.",
FutureWarning,
)
except Exception:
warnings.warn(
"Could not determine the version of Python "
+ "currently being used. To continue receiving "
+ "updates for {_package_label}, ensure you are "
+ "using a supported version of Python; see "
+ "https://devguide.python.org/versions/"
)

__all__ = (
"MaintenanceAsyncClient",
"GetResourceMaintenanceRequest",
"ListResourceMaintenancesRequest",
"ListResourceMaintenancesResponse",
"MaintenanceCategory",
"MaintenanceClient",
"MaintenanceControl",
"MaintenanceSummary",
"ResourceMaintenance",
"SummarizeMaintenancesRequest",
"SummarizeMaintenancesResponse",
)
Comment on lines +138 to +150
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better maintainability and consistency, the __all__ list should be sorted alphabetically.

Suggested change
__all__ = (
"MaintenanceAsyncClient",
"GetResourceMaintenanceRequest",
"ListResourceMaintenancesRequest",
"ListResourceMaintenancesResponse",
"MaintenanceCategory",
"MaintenanceClient",
"MaintenanceControl",
"MaintenanceSummary",
"ResourceMaintenance",
"SummarizeMaintenancesRequest",
"SummarizeMaintenancesResponse",
)
__all__ = (
"GetResourceMaintenanceRequest",
"ListResourceMaintenancesRequest",
"ListResourceMaintenancesResponse",
"MaintenanceAsyncClient",
"MaintenanceCategory",
"MaintenanceClient",
"MaintenanceControl",
"MaintenanceSummary",
"ResourceMaintenance",
"SummarizeMaintenancesRequest",
"SummarizeMaintenancesResponse",
)

Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"comment": "This file maps proto services/RPCs to the corresponding library clients/methods",
"language": "python",
"libraryPackage": "google.cloud.maintenance_api_v1",
"protoPackage": "google.cloud.maintenance.api.v1",
"schema": "1.0",
"services": {
"Maintenance": {
"clients": {
"grpc": {
"libraryClient": "MaintenanceClient",
"rpcs": {
"GetResourceMaintenance": {
"methods": [
"get_resource_maintenance"
]
},
"ListResourceMaintenances": {
"methods": [
"list_resource_maintenances"
]
},
"SummarizeMaintenances": {
"methods": [
"summarize_maintenances"
]
}
}
},
"grpc-async": {
"libraryClient": "MaintenanceAsyncClient",
"rpcs": {
"GetResourceMaintenance": {
"methods": [
"get_resource_maintenance"
]
},
"ListResourceMaintenances": {
"methods": [
"list_resource_maintenances"
]
},
"SummarizeMaintenances": {
"methods": [
"summarize_maintenances"
]
}
}
},
"rest": {
"libraryClient": "MaintenanceClient",
"rpcs": {
"GetResourceMaintenance": {
"methods": [
"get_resource_maintenance"
]
},
"ListResourceMaintenances": {
"methods": [
"list_resource_maintenances"
]
},
"SummarizeMaintenances": {
"methods": [
"summarize_maintenances"
]
}
}
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.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.
#
__version__ = "0.2.0" # {x-release-please-version}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-maintenance-api package uses inline types.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.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.
#
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# -*- coding: utf-8 -*-
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.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.
#
from .async_client import MaintenanceAsyncClient
from .client import MaintenanceClient

__all__ = (
"MaintenanceClient",
"MaintenanceAsyncClient",
)
Loading
Loading