Skip to content
Permalink
Browse files
feat: add context manager support in client (#129)
- [ ] Regenerate this pull request now.

chore: fix docstring for first attribute of protos

committer: @busunkim96
PiperOrigin-RevId: 401271153

Source-Link: googleapis/googleapis@787f8c9

Source-Link: googleapis/googleapis-gen@81decff
Copy-Tag: eyJwIjoiLmdpdGh1Yi8uT3dsQm90LnlhbWwiLCJoIjoiODFkZWNmZmU5ZmM3MjM5NmE4MTUzZTc1NmQxZDY3YTZlZWNmZDYyMCJ9
  • Loading branch information
gcf-owl-bot committed Oct 7, 2021
1 parent 31f9979 commit b207115ed97544585c5f0dc7512d71fd94b5aae2
Showing with 303 additions and 14 deletions.
  1. +6 −0 google/cloud/osconfig_v1/services/os_config_service/async_client.py
  2. +14 −4 google/cloud/osconfig_v1/services/os_config_service/client.py
  3. +9 −0 google/cloud/osconfig_v1/services/os_config_service/transports/base.py
  4. +3 −0 google/cloud/osconfig_v1/services/os_config_service/transports/grpc.py
  5. +3 −0 google/cloud/osconfig_v1/services/os_config_service/transports/grpc_asyncio.py
  6. +6 −0 google/cloud/osconfig_v1/services/os_config_zonal_service/async_client.py
  7. +14 −4 google/cloud/osconfig_v1/services/os_config_zonal_service/client.py
  8. +9 −0 google/cloud/osconfig_v1/services/os_config_zonal_service/transports/base.py
  9. +3 −0 google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc.py
  10. +3 −0 google/cloud/osconfig_v1/services/os_config_zonal_service/transports/grpc_asyncio.py
  11. +5 −0 google/cloud/osconfig_v1/types/inventory.py
  12. +7 −0 google/cloud/osconfig_v1/types/patch_deployments.py
  13. +12 −2 google/cloud/osconfig_v1/types/patch_jobs.py
  14. +2 −0 google/cloud/osconfig_v1/types/vulnerability.py
  15. +6 −0 google/cloud/osconfig_v1alpha/services/os_config_zonal_service/async_client.py
  16. +14 −4 google/cloud/osconfig_v1alpha/services/os_config_zonal_service/client.py
  17. +9 −0 google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/base.py
  18. +3 −0 google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc.py
  19. +3 −0 google/cloud/osconfig_v1alpha/services/os_config_zonal_service/transports/grpc_asyncio.py
  20. +2 −0 google/cloud/osconfig_v1alpha/types/config_common.py
  21. +1 −0 google/cloud/osconfig_v1alpha/types/instance_os_policies_compliance.py
  22. +5 −0 google/cloud/osconfig_v1alpha/types/inventory.py
  23. +8 −0 google/cloud/osconfig_v1alpha/types/os_policy.py
  24. +4 −0 google/cloud/osconfig_v1alpha/types/os_policy_assignments.py
  25. +2 −0 google/cloud/osconfig_v1alpha/types/vulnerability.py
  26. +50 −0 tests/unit/gapic/osconfig_v1/test_os_config_service.py
  27. +50 −0 tests/unit/gapic/osconfig_v1/test_os_config_zonal_service.py
  28. +50 −0 tests/unit/gapic/osconfig_v1alpha/test_os_config_zonal_service.py
@@ -850,6 +850,12 @@ async def delete_patch_deployment(
request, retry=retry, timeout=timeout, metadata=metadata,
)

async def __aenter__(self):
return self

async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -380,10 +380,7 @@ def __init__(
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def execute_patch_job(
@@ -1066,6 +1063,19 @@ def delete_patch_deployment(
request, retry=retry, timeout=timeout, metadata=metadata,
)

def __enter__(self):
return self

def __exit__(self, type, value, traceback):
"""Releases underlying transport's resources.
.. warning::
ONLY use as a context manager if the transport is NOT shared
with other clients! Exiting the with block will CLOSE the transport
and may cause errors in other clients!
"""
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -193,6 +193,15 @@ def _prep_wrapped_messages(self, client_info):
),
}

def close(self):
"""Closes resources associated with the transport.
.. warning::
Only call this method if the transport is NOT shared
with other clients - this may cause errors in other clients!
"""
raise NotImplementedError()

@property
def execute_patch_job(
self,
@@ -482,5 +482,8 @@ def delete_patch_deployment(
)
return self._stubs["delete_patch_deployment"]

def close(self):
self.grpc_channel.close()


__all__ = ("OsConfigServiceGrpcTransport",)
@@ -490,5 +490,8 @@ def delete_patch_deployment(
)
return self._stubs["delete_patch_deployment"]

def close(self):
return self.grpc_channel.close()


__all__ = ("OsConfigServiceGrpcAsyncIOTransport",)
@@ -522,6 +522,12 @@ async def list_vulnerability_reports(
# Done; return the response.
return response

async def __aenter__(self):
return self

async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -384,10 +384,7 @@ def __init__(
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def get_inventory(
@@ -738,6 +735,19 @@ def list_vulnerability_reports(
# Done; return the response.
return response

def __enter__(self):
return self

def __exit__(self, type, value, traceback):
"""Releases underlying transport's resources.
.. warning::
ONLY use as a context manager if the transport is NOT shared
with other clients! Exiting the with block will CLOSE the transport
and may cause errors in other clients!
"""
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -171,6 +171,15 @@ def _prep_wrapped_messages(self, client_info):
),
}

def close(self):
"""Closes resources associated with the transport.
.. warning::
Only call this method if the transport is NOT shared
with other clients - this may cause errors in other clients!
"""
raise NotImplementedError()

@property
def get_inventory(
self,
@@ -345,5 +345,8 @@ def list_vulnerability_reports(
)
return self._stubs["list_vulnerability_reports"]

def close(self):
self.grpc_channel.close()


__all__ = ("OsConfigZonalServiceGrpcTransport",)
@@ -349,5 +349,8 @@ def list_vulnerability_reports(
)
return self._stubs["list_vulnerability_reports"]

def close(self):
return self.grpc_channel.close()


__all__ = ("OsConfigZonalServiceGrpcAsyncIOTransport",)
@@ -71,6 +71,7 @@ class Inventory(proto.Message):

class OsInfo(proto.Message):
r"""Operating system information for the VM.
Attributes:
hostname (str):
The VM hostname.
@@ -106,6 +107,7 @@ class OsInfo(proto.Message):

class Item(proto.Message):
r"""A single piece of inventory on a VM.
Attributes:
id (str):
Identifier for this item, unique across items
@@ -163,6 +165,7 @@ class Type(proto.Enum):

class SoftwarePackage(proto.Message):
r"""Software package information of the operating system.
Attributes:
yum_package (google.cloud.osconfig_v1.types.Inventory.VersionedPackage):
Yum package info. For details about the yum package manager,
@@ -273,6 +276,7 @@ class VersionedPackage(proto.Message):

class ZypperPatch(proto.Message):
r"""Details related to a Zypper Patch.
Attributes:
patch_name (str):
The name of the patch.
@@ -328,6 +332,7 @@ class WindowsUpdatePackage(proto.Message):

class WindowsUpdateCategory(proto.Message):
r"""Categories specified by the Windows Update.
Attributes:
id (str):
The identifier of the windows update
@@ -128,6 +128,7 @@ class OneTimeSchedule(proto.Message):

class RecurringSchedule(proto.Message):
r"""Sets the time for recurring patch deployments.
Attributes:
time_zone (google.type.datetime_pb2.TimeZone):
Required. Defines the time zone that ``time_of_day`` is
@@ -185,6 +186,7 @@ class Frequency(proto.Enum):

class WeeklySchedule(proto.Message):
r"""Represents a weekly schedule.
Attributes:
day_of_week (google.type.dayofweek_pb2.DayOfWeek):
Required. Day of the week.
@@ -235,6 +237,7 @@ class WeekDayOfMonth(proto.Message):

class CreatePatchDeploymentRequest(proto.Message):
r"""A request message for creating a patch deployment.
Attributes:
parent (str):
Required. The project to apply this patch deployment to in
@@ -260,6 +263,7 @@ class CreatePatchDeploymentRequest(proto.Message):

class GetPatchDeploymentRequest(proto.Message):
r"""A request message for retrieving a patch deployment.
Attributes:
name (str):
Required. The resource name of the patch deployment in the
@@ -271,6 +275,7 @@ class GetPatchDeploymentRequest(proto.Message):

class ListPatchDeploymentsRequest(proto.Message):
r"""A request message for listing patch deployments.
Attributes:
parent (str):
Required. The resource name of the parent in the form
@@ -292,6 +297,7 @@ class ListPatchDeploymentsRequest(proto.Message):

class ListPatchDeploymentsResponse(proto.Message):
r"""A response message for listing patch deployments.
Attributes:
patch_deployments (Sequence[google.cloud.osconfig_v1.types.PatchDeployment]):
The list of patch deployments.
@@ -312,6 +318,7 @@ def raw_page(self):

class DeletePatchDeploymentRequest(proto.Message):
r"""A request message for deleting a patch deployment.
Attributes:
name (str):
Required. The resource name of the patch deployment in the
@@ -94,6 +94,7 @@ class ExecutePatchJobRequest(proto.Message):

class GetPatchJobRequest(proto.Message):
r"""Request to get an active or completed patch job.
Attributes:
name (str):
Required. Name of the patch in the form
@@ -184,6 +185,7 @@ class PatchJobInstanceDetails(proto.Message):

class ListPatchJobsRequest(proto.Message):
r"""A request message for listing patch jobs.
Attributes:
parent (str):
Required. In the form of ``projects/*``
@@ -208,6 +210,7 @@ class ListPatchJobsRequest(proto.Message):

class ListPatchJobsResponse(proto.Message):
r"""A response message for listing patch jobs.
Attributes:
patch_jobs (Sequence[google.cloud.osconfig_v1.types.PatchJob]):
The list of patch jobs.
@@ -424,7 +427,8 @@ class RebootConfig(proto.Enum):


class Instance(proto.Message):
r"""Namespace for instance state enums. """
r"""Namespace for instance state enums.
"""

class PatchState(proto.Enum):
r"""Patch state of an instance."""
@@ -448,6 +452,7 @@ class PatchState(proto.Enum):

class CancelPatchJobRequest(proto.Message):
r"""Message for canceling a patch job.
Attributes:
name (str):
Required. Name of the patch in the form
@@ -520,7 +525,8 @@ class YumSettings(proto.Message):


class GooSettings(proto.Message):
r"""Googet patching is performed by running ``googet update``. """
r"""Googet patching is performed by running ``googet update``.
"""


class ZypperSettings(proto.Message):
@@ -559,6 +565,7 @@ class ZypperSettings(proto.Message):

class WindowsUpdateSettings(proto.Message):
r"""Windows patching is performed using the Windows Update Agent.
Attributes:
classifications (Sequence[google.cloud.osconfig_v1.types.WindowsUpdateSettings.Classification]):
Only apply updates of these windows update
@@ -595,6 +602,7 @@ class Classification(proto.Enum):

class ExecStep(proto.Message):
r"""A step that runs an executable for a PatchJob.
Attributes:
linux_exec_step_config (google.cloud.osconfig_v1.types.ExecStepConfig):
The ExecStepConfig for all Linux VMs targeted
@@ -614,6 +622,7 @@ class ExecStep(proto.Message):

class ExecStepConfig(proto.Message):
r"""Common configurations for an ExecStep.
Attributes:
local_path (str):
An absolute path to the executable on the VM.
@@ -647,6 +656,7 @@ class Interpreter(proto.Enum):

class GcsObject(proto.Message):
r"""Cloud Storage object representation.
Attributes:
bucket (str):
Required. Bucket of the Cloud Storage object.
@@ -54,6 +54,7 @@ class VulnerabilityReport(proto.Message):

class Vulnerability(proto.Message):
r"""A vulnerability affecting the VM instance.
Attributes:
details (google.cloud.osconfig_v1.types.VulnerabilityReport.Vulnerability.Details):
Contains metadata as per the upstream feed of
@@ -113,6 +114,7 @@ class Details(proto.Message):

class Reference(proto.Message):
r"""A reference for this vulnerability.
Attributes:
url (str):
The url of the reference.
@@ -1329,6 +1329,12 @@ async def list_vulnerability_reports(
# Done; return the response.
return response

async def __aenter__(self):
return self

async def __aexit__(self, exc_type, exc, tb):
await self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
@@ -430,10 +430,7 @@ def __init__(
client_cert_source_for_mtls=client_cert_source_func,
quota_project_id=client_options.quota_project_id,
client_info=client_info,
always_use_jwt_access=(
Transport == type(self).get_transport_class("grpc")
or Transport == type(self).get_transport_class("grpc_asyncio")
),
always_use_jwt_access=True,
)

def create_os_policy_assignment(
@@ -1618,6 +1615,19 @@ def list_vulnerability_reports(
# Done; return the response.
return response

def __enter__(self):
return self

def __exit__(self, type, value, traceback):
"""Releases underlying transport's resources.
.. warning::
ONLY use as a context manager if the transport is NOT shared
with other clients! Exiting the with block will CLOSE the transport
and may cause errors in other clients!
"""
self.transport.close()


try:
DEFAULT_CLIENT_INFO = gapic_v1.client_info.ClientInfo(
Loading

0 comments on commit b207115

Please sign in to comment.