Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [google-cloud-parallelstore] add iam.googleapis.com/ServiceAccount resource definition #12857

Merged
merged 3 commits into from
Jul 3, 2024
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
2 changes: 1 addition & 1 deletion packages/google-cloud-parallelstore/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Python Client for Parallelstore API
.. |versions| image:: https://img.shields.io/pypi/pyversions/google-cloud-parallelstore.svg
:target: https://pypi.org/project/google-cloud-parallelstore/
.. _Parallelstore API: https://cloud.google.com/parallelstore
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/google-cloud-parallelstore/latest
.. _Client Library Documentation: https://cloud.google.com/python/docs/reference/google-cloud-parallelstore/latest/summary_overview
.. _Product Documentation: https://cloud.google.com/parallelstore

Quick Start
Expand Down
5 changes: 5 additions & 0 deletions packages/google-cloud-parallelstore/docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,8 @@ For a list of all ``google-cloud-parallelstore`` releases:
:maxdepth: 2

CHANGELOG

.. toctree::
:hidden:

summary_overview.md
22 changes: 22 additions & 0 deletions packages/google-cloud-parallelstore/docs/summary_overview.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
[
This is a templated file. Adding content to this file may result in it being
reverted. Instead, if you want to place additional content, create an
"overview_content.md" file in `docs/` directory. The Sphinx tool will
pick up on the content and merge the content.
]: #

# Parallelstore API API

Overview of the APIs available for Parallelstore API API.

## All entries

Classes, methods and properties & attributes for
Parallelstore API API.

[classes](https://cloud.google.com/python/docs/reference/google-cloud-parallelstore/latest/summary_class.html)

[methods](https://cloud.google.com/python/docs/reference/google-cloud-parallelstore/latest/summary_method.html)

[properties and
attributes](https://cloud.google.com/python/docs/reference/google-cloud-parallelstore/latest/summary_property.html)
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class ParallelstoreAsyncClient:
parse_instance_path = staticmethod(ParallelstoreClient.parse_instance_path)
network_path = staticmethod(ParallelstoreClient.network_path)
parse_network_path = staticmethod(ParallelstoreClient.parse_network_path)
service_account_path = staticmethod(ParallelstoreClient.service_account_path)
parse_service_account_path = staticmethod(
ParallelstoreClient.parse_service_account_path
)
common_billing_account_path = staticmethod(
ParallelstoreClient.common_billing_account_path
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,26 @@ def parse_network_path(path: str) -> Dict[str, str]:
)
return m.groupdict() if m else {}

@staticmethod
def service_account_path(
project: str,
service_account: str,
) -> str:
"""Returns a fully-qualified service_account string."""
return "projects/{project}/serviceAccounts/{service_account}".format(
project=project,
service_account=service_account,
)

@staticmethod
def parse_service_account_path(path: str) -> Dict[str, str]:
"""Parses a service_account path into its component segments."""
m = re.match(
r"^projects/(?P<project>.+?)/serviceAccounts/(?P<service_account>.+?)$",
path,
)
return m.groupdict() if m else {}

@staticmethod
def common_billing_account_path(
billing_account: str,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -624,6 +624,12 @@ class ImportDataRequest(proto.Message):
The request ID must be a valid UUID with the
exception that zero UUID is not supported
(00000000-0000-0000-0000-000000000000).
service_account (str):
Optional. User-specified Service Account (SA) credentials to
be used when performing the transfer. Format:
``projects/{project_id}/serviceAccounts/{service_account}``
If unspecified, the Parallelstore service agent is used:
service-<PROJECT_NUMBER>@gcp-sa-parallelstore.iam.gserviceaccount.com)
"""

source_gcs_bucket: "SourceGcsBucket" = proto.Field(
Expand All @@ -646,6 +652,10 @@ class ImportDataRequest(proto.Message):
proto.STRING,
number=4,
)
service_account: str = proto.Field(
proto.STRING,
number=5,
)


class ExportDataRequest(proto.Message):
Expand Down Expand Up @@ -686,6 +696,12 @@ class ExportDataRequest(proto.Message):
The request ID must be a valid UUID with the
exception that zero UUID is not supported
(00000000-0000-0000-0000-000000000000).
service_account (str):
Optional. User-specified Service Account (SA) credentials to
be used when performing the transfer. Format:
``projects/{project_id}/serviceAccounts/{service_account}``
If unspecified, the Parallelstore service agent is used:
service-<PROJECT_NUMBER>@gcp-sa-parallelstore.iam.gserviceaccount.com)
"""

source_parallelstore: "SourceParallelstore" = proto.Field(
Expand All @@ -708,6 +724,10 @@ class ExportDataRequest(proto.Message):
proto.STRING,
number=4,
)
service_account: str = proto.Field(
proto.STRING,
number=5,
)


class ImportDataResponse(proto.Message):
Expand Down
46 changes: 35 additions & 11 deletions packages/google-cloud-parallelstore/noxfile.py
Original file line number Diff line number Diff line change
Expand Up @@ -160,14 +160,28 @@ def install_unittest_dependencies(session, *constraints):
session.install("-e", ".", *constraints)


def default(session):
@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
@nox.parametrize(
"protobuf_implementation",
["python", "upb", "cpp"],
)
def unit(session, protobuf_implementation):
# Install all test dependencies, then install this package in-place.

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
session.skip("cpp implementation is not supported in python 3.11+")

constraints_path = str(
CURRENT_DIRECTORY / "testing" / f"constraints-{session.python}.txt"
)
install_unittest_dependencies(session, "-c", constraints_path)

# TODO(https://github.com/googleapis/synthtool/issues/1976):
# Remove the 'cpp' implementation once support for Protobuf 3.x is dropped.
# The 'cpp' implementation requires Protobuf<4.
if protobuf_implementation == "cpp":
session.install("protobuf<4")

# Run py.test against the unit tests.
session.run(
"py.test",
Expand All @@ -181,15 +195,12 @@ def default(session):
"--cov-fail-under=0",
os.path.join("tests", "unit"),
*session.posargs,
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)


@nox.session(python=UNIT_TEST_PYTHON_VERSIONS)
def unit(session):
"""Run the unit test suite."""
default(session)


def install_systemtest_dependencies(session, *constraints):
# Use pre-release gRPC for system tests.
# Exclude version 1.52.0rc1 which has a known issue.
Expand Down Expand Up @@ -358,9 +369,16 @@ def docfx(session):


@nox.session(python="3.12")
def prerelease_deps(session):
@nox.parametrize(
"protobuf_implementation",
["python", "upb", "cpp"],
)
def prerelease_deps(session, protobuf_implementation):
"""Run all tests with prerelease versions of dependencies installed."""

if protobuf_implementation == "cpp" and session.python in ("3.11", "3.12"):
session.skip("cpp implementation is not supported in python 3.11+")

# Install all dependencies
session.install("-e", ".[all, tests, tracing]")
unit_deps_all = UNIT_TEST_STANDARD_DEPENDENCIES + UNIT_TEST_EXTERNAL_DEPENDENCIES
Expand Down Expand Up @@ -397,9 +415,9 @@ def prerelease_deps(session):
"protobuf",
# dependency of grpc
"six",
"grpc-google-iam-v1",
"googleapis-common-protos",
# Exclude version 1.52.0rc1 which has a known issue. See https://github.com/grpc/grpc/issues/32163
"grpcio!=1.52.0rc1",
"grpcio",
"grpcio-status",
"google-api-core",
"google-auth",
Expand All @@ -425,4 +443,10 @@ def prerelease_deps(session):
session.run("python", "-c", "import grpc; print(grpc.__version__)")
session.run("python", "-c", "import google.auth; print(google.auth.__version__)")

session.run("py.test", "tests/unit")
session.run(
"py.test",
"tests/unit",
env={
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ class parallelstoreCallTransformer(cst.CSTTransformer):
METHOD_TO_PARAMS: Dict[str, Tuple[str]] = {
'create_instance': ('parent', 'instance_id', 'instance', 'request_id', ),
'delete_instance': ('name', 'request_id', ),
'export_data': ('name', 'source_parallelstore', 'destination_gcs_bucket', 'request_id', ),
'export_data': ('name', 'source_parallelstore', 'destination_gcs_bucket', 'request_id', 'service_account', ),
'get_instance': ('name', ),
'import_data': ('name', 'source_gcs_bucket', 'destination_parallelstore', 'request_id', ),
'import_data': ('name', 'source_gcs_bucket', 'destination_parallelstore', 'request_id', 'service_account', ),
'list_instances': ('parent', 'page_size', 'page_token', 'filter', 'order_by', ),
'update_instance': ('update_mask', 'instance', 'request_id', ),
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3313,6 +3313,7 @@ def test_import_data_non_empty_request_with_auto_populated_field():
# if they meet the requirements of AIP 4235.
request = parallelstore.ImportDataRequest(
name="name_value",
service_account="service_account_value",
)

# Mock the actual call within the gRPC stub, and fake the request.
Expand All @@ -3325,6 +3326,7 @@ def test_import_data_non_empty_request_with_auto_populated_field():
_, args, _ = call.mock_calls[0]
assert args[0] == parallelstore.ImportDataRequest(
name="name_value",
service_account="service_account_value",
)


Expand Down Expand Up @@ -3600,6 +3602,7 @@ def test_export_data_non_empty_request_with_auto_populated_field():
# if they meet the requirements of AIP 4235.
request = parallelstore.ExportDataRequest(
name="name_value",
service_account="service_account_value",
)

# Mock the actual call within the gRPC stub, and fake the request.
Expand All @@ -3612,6 +3615,7 @@ def test_export_data_non_empty_request_with_auto_populated_field():
_, args, _ = call.mock_calls[0]
assert args[0] == parallelstore.ExportDataRequest(
name="name_value",
service_account="service_account_value",
)


Expand Down Expand Up @@ -6824,8 +6828,31 @@ def test_parse_network_path():
assert expected == actual


def test_service_account_path():
project = "oyster"
service_account = "nudibranch"
expected = "projects/{project}/serviceAccounts/{service_account}".format(
project=project,
service_account=service_account,
)
actual = ParallelstoreClient.service_account_path(project, service_account)
assert expected == actual


def test_parse_service_account_path():
expected = {
"project": "cuttlefish",
"service_account": "mussel",
}
path = ParallelstoreClient.service_account_path(**expected)

# Check that the path construction is reversible.
actual = ParallelstoreClient.parse_service_account_path(path)
assert expected == actual


def test_common_billing_account_path():
billing_account = "oyster"
billing_account = "winkle"
expected = "billingAccounts/{billing_account}".format(
billing_account=billing_account,
)
Expand All @@ -6835,7 +6862,7 @@ def test_common_billing_account_path():

def test_parse_common_billing_account_path():
expected = {
"billing_account": "nudibranch",
"billing_account": "nautilus",
}
path = ParallelstoreClient.common_billing_account_path(**expected)

Expand All @@ -6845,7 +6872,7 @@ def test_parse_common_billing_account_path():


def test_common_folder_path():
folder = "cuttlefish"
folder = "scallop"
expected = "folders/{folder}".format(
folder=folder,
)
Expand All @@ -6855,7 +6882,7 @@ def test_common_folder_path():

def test_parse_common_folder_path():
expected = {
"folder": "mussel",
"folder": "abalone",
}
path = ParallelstoreClient.common_folder_path(**expected)

Expand All @@ -6865,7 +6892,7 @@ def test_parse_common_folder_path():


def test_common_organization_path():
organization = "winkle"
organization = "squid"
expected = "organizations/{organization}".format(
organization=organization,
)
Expand All @@ -6875,7 +6902,7 @@ def test_common_organization_path():

def test_parse_common_organization_path():
expected = {
"organization": "nautilus",
"organization": "clam",
}
path = ParallelstoreClient.common_organization_path(**expected)

Expand All @@ -6885,7 +6912,7 @@ def test_parse_common_organization_path():


def test_common_project_path():
project = "scallop"
project = "whelk"
expected = "projects/{project}".format(
project=project,
)
Expand All @@ -6895,7 +6922,7 @@ def test_common_project_path():

def test_parse_common_project_path():
expected = {
"project": "abalone",
"project": "octopus",
}
path = ParallelstoreClient.common_project_path(**expected)

Expand All @@ -6905,8 +6932,8 @@ def test_parse_common_project_path():


def test_common_location_path():
project = "squid"
location = "clam"
project = "oyster"
location = "nudibranch"
expected = "projects/{project}/locations/{location}".format(
project=project,
location=location,
Expand All @@ -6917,8 +6944,8 @@ def test_common_location_path():

def test_parse_common_location_path():
expected = {
"project": "whelk",
"location": "octopus",
"project": "cuttlefish",
"location": "mussel",
}
path = ParallelstoreClient.common_location_path(**expected)

Expand Down
Loading