Skip to content
This repository was archived by the owner on Nov 14, 2023. It is now read-only.
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
5 changes: 0 additions & 5 deletions .coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,3 @@ exclude_lines =
pragma: NO COVER
# Ignore debug-only repr
def __repr__
# Ignore pkg_resources exceptions.
# This is added at the module level as a safeguard for if someone
# generates the code and tries to run it without pip installing. This
# makes it virtually impossible to test properly.
except pkg_resources.DistributionNotFound
1 change: 1 addition & 0 deletions .github/release-please.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
releaseType: python
handleGHRelease: true
manifest: true
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "1.1.3"
}
1 change: 0 additions & 1 deletion docs/optimization_v1/types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,4 @@ Types for Google Cloud Optimization v1 API

.. automodule:: google.cloud.optimization_v1.types
:members:
:undoc-members:
:show-inheritance:
90 changes: 90 additions & 0 deletions google/cloud/optimization/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
# -*- coding: utf-8 -*-
# Copyright 2022 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 google.cloud.optimization import gapic_version as package_version

__version__ = package_version.__version__


from google.cloud.optimization_v1.services.fleet_routing.client import (
FleetRoutingClient,
)
from google.cloud.optimization_v1.services.fleet_routing.async_client import (
FleetRoutingAsyncClient,
)

from google.cloud.optimization_v1.types.async_model import AsyncModelMetadata
from google.cloud.optimization_v1.types.async_model import GcsDestination
from google.cloud.optimization_v1.types.async_model import GcsSource
from google.cloud.optimization_v1.types.async_model import InputConfig
from google.cloud.optimization_v1.types.async_model import OutputConfig
from google.cloud.optimization_v1.types.async_model import DataFormat
from google.cloud.optimization_v1.types.fleet_routing import AggregatedMetrics
from google.cloud.optimization_v1.types.fleet_routing import BatchOptimizeToursRequest
from google.cloud.optimization_v1.types.fleet_routing import BatchOptimizeToursResponse
from google.cloud.optimization_v1.types.fleet_routing import BreakRule
from google.cloud.optimization_v1.types.fleet_routing import CapacityQuantity
from google.cloud.optimization_v1.types.fleet_routing import CapacityQuantityInterval
from google.cloud.optimization_v1.types.fleet_routing import DistanceLimit
from google.cloud.optimization_v1.types.fleet_routing import InjectedSolutionConstraint
from google.cloud.optimization_v1.types.fleet_routing import Location
from google.cloud.optimization_v1.types.fleet_routing import OptimizeToursRequest
from google.cloud.optimization_v1.types.fleet_routing import OptimizeToursResponse
from google.cloud.optimization_v1.types.fleet_routing import (
OptimizeToursValidationError,
)
from google.cloud.optimization_v1.types.fleet_routing import Shipment
from google.cloud.optimization_v1.types.fleet_routing import ShipmentModel
from google.cloud.optimization_v1.types.fleet_routing import ShipmentRoute
from google.cloud.optimization_v1.types.fleet_routing import ShipmentTypeIncompatibility
from google.cloud.optimization_v1.types.fleet_routing import ShipmentTypeRequirement
from google.cloud.optimization_v1.types.fleet_routing import SkippedShipment
from google.cloud.optimization_v1.types.fleet_routing import TimeWindow
from google.cloud.optimization_v1.types.fleet_routing import TransitionAttributes
from google.cloud.optimization_v1.types.fleet_routing import Vehicle
from google.cloud.optimization_v1.types.fleet_routing import Waypoint

__all__ = (
"FleetRoutingClient",
"FleetRoutingAsyncClient",
"AsyncModelMetadata",
"GcsDestination",
"GcsSource",
"InputConfig",
"OutputConfig",
"DataFormat",
"AggregatedMetrics",
"BatchOptimizeToursRequest",
"BatchOptimizeToursResponse",
"BreakRule",
"CapacityQuantity",
"CapacityQuantityInterval",
"DistanceLimit",
"InjectedSolutionConstraint",
"Location",
"OptimizeToursRequest",
"OptimizeToursResponse",
"OptimizeToursValidationError",
"Shipment",
"ShipmentModel",
"ShipmentRoute",
"ShipmentTypeIncompatibility",
"ShipmentTypeRequirement",
"SkippedShipment",
"TimeWindow",
"TransitionAttributes",
"Vehicle",
"Waypoint",
)
16 changes: 16 additions & 0 deletions google/cloud/optimization/gapic_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2022 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__ = "1.1.3" # {x-release-please-version}
2 changes: 2 additions & 0 deletions google/cloud/optimization/py.typed
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Marker file for PEP 561.
# The google-cloud-optimization package uses inline types.
4 changes: 4 additions & 0 deletions google/cloud/optimization_v1/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
from google.cloud.optimization import gapic_version as package_version

__version__ = package_version.__version__


from .services.fleet_routing import FleetRoutingClient
from .services.fleet_routing import FleetRoutingAsyncClient
Expand Down
16 changes: 16 additions & 0 deletions google/cloud/optimization_v1/gapic_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# -*- coding: utf-8 -*-
# Copyright 2022 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__ = "1.1.3" # {x-release-please-version}
44 changes: 25 additions & 19 deletions google/cloud/optimization_v1/services/fleet_routing/async_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,19 @@
from collections import OrderedDict
import functools
import re
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
import pkg_resources
from typing import (
Dict,
Mapping,
MutableMapping,
MutableSequence,
Optional,
Sequence,
Tuple,
Type,
Union,
)

from google.cloud.optimization_v1 import gapic_version as package_version

from google.api_core.client_options import ClientOptions
from google.api_core import exceptions as core_exceptions
Expand Down Expand Up @@ -177,9 +188,9 @@ def transport(self) -> FleetRoutingTransport:
def __init__(
self,
*,
credentials: ga_credentials.Credentials = None,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, FleetRoutingTransport] = "grpc_asyncio",
client_options: ClientOptions = None,
client_options: Optional[ClientOptions] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the fleet routing client.
Expand Down Expand Up @@ -223,10 +234,10 @@ def __init__(

async def optimize_tours(
self,
request: Union[fleet_routing.OptimizeToursRequest, dict] = None,
request: Optional[Union[fleet_routing.OptimizeToursRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> fleet_routing.OptimizeToursResponse:
r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel``
Expand Down Expand Up @@ -273,7 +284,7 @@ async def sample_optimize_tours():
print(response)

Args:
request (Union[google.cloud.optimization_v1.types.OptimizeToursRequest, dict]):
request (Optional[Union[google.cloud.optimization_v1.types.OptimizeToursRequest, dict]]):
The request object. Request to be given to a tour
optimization solver which defines the shipment model to
solve as well as optimization parameters.
Expand Down Expand Up @@ -331,10 +342,10 @@ async def sample_optimize_tours():

async def batch_optimize_tours(
self,
request: Union[fleet_routing.BatchOptimizeToursRequest, dict] = None,
request: Optional[Union[fleet_routing.BatchOptimizeToursRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation_async.AsyncOperation:
r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest``
Expand Down Expand Up @@ -379,13 +390,13 @@ async def sample_batch_optimize_tours():

print("Waiting for operation to complete...")

response = await operation.result()
response = (await operation).result()

# Handle the response
print(response)

Args:
request (Union[google.cloud.optimization_v1.types.BatchOptimizeToursRequest, dict]):
request (Optional[Union[google.cloud.optimization_v1.types.BatchOptimizeToursRequest, dict]]):
The request object. Request to batch optimize tours as
an asynchronous operation. Each input file should
contain one `OptimizeToursRequest`, and each output file
Expand Down Expand Up @@ -459,14 +470,9 @@ async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-optimization",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


__all__ = ("FleetRoutingAsyncClient",)
44 changes: 26 additions & 18 deletions google/cloud/optimization_v1/services/fleet_routing/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,20 @@
from collections import OrderedDict
import os
import re
from typing import Dict, Mapping, Optional, Sequence, Tuple, Type, Union
import pkg_resources
from typing import (
Dict,
Mapping,
MutableMapping,
MutableSequence,
Optional,
Sequence,
Tuple,
Type,
Union,
cast,
)

from google.cloud.optimization_v1 import gapic_version as package_version

from google.api_core import client_options as client_options_lib
from google.api_core import exceptions as core_exceptions
Expand Down Expand Up @@ -57,7 +69,7 @@ class FleetRoutingClientMeta(type):

def get_transport_class(
cls,
label: str = None,
label: Optional[str] = None,
) -> Type[FleetRoutingTransport]:
"""Returns an appropriate transport class.

Expand Down Expand Up @@ -333,8 +345,8 @@ def __init__(
self,
*,
credentials: Optional[ga_credentials.Credentials] = None,
transport: Union[str, FleetRoutingTransport, None] = None,
client_options: Optional[client_options_lib.ClientOptions] = None,
transport: Optional[Union[str, FleetRoutingTransport]] = None,
client_options: Optional[Union[client_options_lib.ClientOptions, dict]] = None,
client_info: gapic_v1.client_info.ClientInfo = DEFAULT_CLIENT_INFO,
) -> None:
"""Instantiates the fleet routing client.
Expand All @@ -348,7 +360,7 @@ def __init__(
transport (Union[str, FleetRoutingTransport]): The
transport to use. If set to None, a transport is chosen
automatically.
client_options (google.api_core.client_options.ClientOptions): Custom options for the
client_options (Optional[Union[google.api_core.client_options.ClientOptions, dict]]): Custom options for the
client. It won't take effect if a ``transport`` instance is provided.
(1) The ``api_endpoint`` property can be used to override the
default endpoint provided by the client. GOOGLE_API_USE_MTLS_ENDPOINT
Expand Down Expand Up @@ -378,6 +390,7 @@ def __init__(
client_options = client_options_lib.from_dict(client_options)
if client_options is None:
client_options = client_options_lib.ClientOptions()
client_options = cast(client_options_lib.ClientOptions, client_options)

api_endpoint, client_cert_source_func = self.get_mtls_endpoint_and_cert_source(
client_options
Expand Down Expand Up @@ -430,10 +443,10 @@ def __init__(

def optimize_tours(
self,
request: Union[fleet_routing.OptimizeToursRequest, dict] = None,
request: Optional[Union[fleet_routing.OptimizeToursRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> fleet_routing.OptimizeToursResponse:
r"""Sends an ``OptimizeToursRequest`` containing a ``ShipmentModel``
Expand Down Expand Up @@ -530,10 +543,10 @@ def sample_optimize_tours():

def batch_optimize_tours(
self,
request: Union[fleet_routing.BatchOptimizeToursRequest, dict] = None,
request: Optional[Union[fleet_routing.BatchOptimizeToursRequest, dict]] = None,
*,
retry: OptionalRetry = gapic_v1.method.DEFAULT,
timeout: float = None,
timeout: Union[float, object] = gapic_v1.method.DEFAULT,
metadata: Sequence[Tuple[str, str]] = (),
) -> operation.Operation:
r"""Optimizes vehicle tours for one or more ``OptimizeToursRequest``
Expand Down Expand Up @@ -657,14 +670,9 @@ def __exit__(self, type, value, traceback):
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=pkg_resources.get_distribution(
"google-cloud-optimization",
).version,
)
except pkg_resources.DistributionNotFound:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo()
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
gapic_version=package_version.__version__
)


__all__ = ("FleetRoutingClient",)
Loading