feat: Add new gcloud commands, API clients, and third-party libraries across various services.

This commit is contained in:
2026-01-01 20:26:35 +01:00
parent 5e23cbece0
commit a19e592eb7
25221 changed files with 8324611 additions and 0 deletions

View File

@@ -0,0 +1,47 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# 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.
"""Flags for saas runtime commands."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope.concepts import concepts
from googlecloudsdk.command_lib.util.apis import yaml_data
from googlecloudsdk.command_lib.util.concepts import concept_parsers
def AddUnitKindArgToParser(parser, required=True, help_text='UnitKind.'):
"""Sets up the UnitKind argument for the command."""
unit_kind_data = yaml_data.ResourceYAMLData.FromPath('saas_runtime.unit_kind')
return concept_parsers.ConceptParser.ForResource(
'--unit-kind',
concepts.ResourceSpec.FromYaml(unit_kind_data.GetData()),
help_text,
required=required,
).AddToParser(parser)
def AddProjectLocationArgToParser(parser, required=True, help_text='location.'):
"""Sets up the location argument for the command."""
project_location_data = yaml_data.ResourceYAMLData.FromPath(
'saas_runtime.project_location'
)
return concept_parsers.ConceptParser.ForResource(
'--project-location',
concepts.ResourceSpec.FromYaml(project_location_data.GetData()),
help_text,
required=required,
).AddToParser(parser)

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# 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.
"""Utilities for releases commands."""
import re
def AddParentToUpgradeableFromReleases(ref, args, request):
"""Request hook to add parent to upgradeable from releases if missing.
Args:
ref: A resource ref to the parsed resource.
args: Parsed args namespace containing the flags.
request: The request message to be modified.
Returns:
The modified request message.
"""
del ref, args # Unused.
parent = None
if hasattr(request, "parent"):
parent = request.parent
elif hasattr(request, "name"):
match = re.match(r"(projects/[^/]+/locations/[^/]+)", request.name)
if match:
parent = match.group(1)
if (
parent
and hasattr(request, "release")
and hasattr(
request.release.releaseRequirements, "upgradeableFromReleases"
)
):
updated_upgradeable_from_releases = []
for (
upgradeable_from_release
) in request.release.releaseRequirements.upgradeableFromReleases:
if not upgradeable_from_release.startswith("projects/"):
full_uri = f"{parent}/releases/{upgradeable_from_release}"
else:
full_uri = upgradeable_from_release
updated_upgradeable_from_releases.append(full_uri)
request.release.releaseRequirements.upgradeableFromReleases = (
updated_upgradeable_from_releases
)
return request

View File

@@ -0,0 +1,210 @@
project:
name: project
plural_name: projects
collection: saasservicemgmt.projects
attributes:
- &project
parameter_name: projectsId
attribute_name: project
help: Project ID
property: core/project
disable_auto_completers: true
project_location:
name: location
plural_name: locations
collection: saasservicemgmt.projects.locations
attributes:
- *project
- &location
parameter_name: locationsId
attribute_name: location
help: Location ID
disable_auto_completers: true
# This is for the 'parent' argument for list commands. It is the same as project_location, but with
# a default value of '-' to support fanout when the parent isn't specified.
project_location_with_default:
name: location
plural_name: locations
collection: saasservicemgmt.projects.locations
attributes:
- *project
- &project_location_with_default
parameter_name: locationsId
attribute_name: location
help: Location ID
fallthroughs:
- value: "-"
hint: |-
if left empty, will use the wildcard '-' to list all locations
disable_auto_completers: true
flag:
name: flag
plural_name: flags
collection: saasservicemgmt.projects.locations.flags
attributes:
- *project
- *location
- &flagId
parameter_name: flagsId
attribute_name: flag
help: Flag ID
disable_auto_completers: false
flag_release:
name: flagRelease
plural_name: flagReleases
collection: saasservicemgmt.projects.locations.flagReleases
attributes:
- *project
- *location
- &flagRelease
parameter_name: flagReleasesId
attribute_name: flag_release
help: Flag Release ID
disable_auto_completers: false
flag_revision:
name: flagRevision
plural_name: flagRevisions
collection: saasservicemgmt.projects.locations.flagRevisions
attributes:
- *project
- *location
- &flagRevision
parameter_name: flagRevisionsId
attribute_name: flag_revision
help: Flag Revision ID
disable_auto_completers: false
rollout_kind:
name: rolloutKindId
plural_name: rolloutKinds
collection: saasservicemgmt.projects.locations.rolloutKinds
attributes:
- *project
- *location
- &rolloutKindId
parameter_name: rolloutKindsId
attribute_name: rollout_kind
help: Rollout Kind ID.
disable_auto_completers: false
rollout:
name: rolloutId
plural_name: rollouts
collection: saasservicemgmt.projects.locations.rollouts
attributes:
- *project
- *location
- &rolloutId
parameter_name: rolloutsId
attribute_name: rollout
help: Rollout ID
disable_auto_completers: false
saas:
name: saas
plural_name: saas
collection: saasservicemgmt.projects.locations.saas
attributes:
- *project
- *location
- &saas
parameter_name: saasId
attribute_name: saas
help: Saas ID
disable_auto_completers: false
tenant:
name: tenant
plural_name: tenants
collection: saasservicemgmt.projects.locations.tenants
attributes:
- *project
- *location
- &tenant
parameter_name: tenantsId
attribute_name: tenant
help: Tenant ID
disable_auto_completers: false
unit_kind:
name: unitKind
plural_name: unitKinds
collection: saasservicemgmt.projects.locations.unitKinds
attributes:
- *project
- *location
- &unitKind
parameter_name: unitKindsId
attribute_name: unit_kind
help: Unit Kind ID
disable_auto_completers: false
unit:
name: unit
plural_name: units
collection: saasservicemgmt.projects.locations.units
attributes:
- *project
- *location
- &unit
parameter_name: unitsId
attribute_name: unit
help: Unit ID
disable_auto_completers: false
unit_operation:
name: unitOperation
plural_name: unitOperations
collection: saasservicemgmt.projects.locations.unitOperations
attributes:
- *project
- *location
- &unitOperation
parameter_name: unitOperationsId
attribute_name: unit_operation
help: Unit Operation ID
disable_auto_completers: false
parent_unit_operation:
name: parentUnitOperation
plural_name: parentUnitOperations
collection: saasservicemgmt.projects.locations.unitOperations
attributes:
- *project
- *location
- &parentUnitOperation
parameter_name: unitOperationsId
attribute_name: unit_operation
help: Unit Operation ID
disable_auto_completers: false
release:
name: release
plural_name: releases
collection: saasservicemgmt.projects.locations.releases
attributes:
- *project
- *location
- &release
parameter_name: releasesId
attribute_name: release
help: Release ID
disable_auto_completers: false
operation:
name: operation
plural_name: operations
collection: saasservicemgmt.projects.locations.operations
attributes:
- *project
- *location
- &operation
parameter_name: operationsId
attribute_name: operation
help: Operation ID
disable_auto_completers: false

View File

@@ -0,0 +1,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# 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.
"""Utilities for rollouts commands."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
def HandleResume(unused_ref, args, request):
"""Request hook to handle use of --resume flag.
Args:
unused_ref: A resource ref to the parsed resource.
args: Parsed args namespace containing the flags.
request: The request message to be modified.
Returns:
The modified request message.
"""
if not args.IsSpecified('resume'):
return request
request.rollout.pause = False
return request

View File

@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# 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.
"""Utilities for unit kinds commands."""
import re
def AddParentToDependencies(ref, args, request):
"""Request hook to add parent to dependencies if missing.
Args:
ref: A resource ref to the parsed resource.
args: Parsed args namespace containing the flags.
request: The request message to be modified.
Returns:
The modified request message.
"""
del ref, args # Unused.
parent = None
if hasattr(request, "parent"):
parent = request.parent
elif hasattr(request, "name"):
match = re.match(r"(projects/[^/]+/locations/[^/]+)", request.name)
if match:
parent = match.group(1)
if (
parent
and hasattr(request, "unitKind")
and hasattr(request.unitKind, "dependencies")
):
for dependency in request.unitKind.dependencies:
if hasattr(dependency, "unitKind"):
if not dependency.unitKind.startswith("projects/"):
full_uri = f"{parent}/unitKinds/{dependency.unitKind}"
dependency.unitKind = full_uri
return request

View File

@@ -0,0 +1,131 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google LLC. All Rights Reserved.
#
# 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.
"""Utilities for unit operations commands."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
def HandleEmptyProvision(unused_ref, args, request):
"""Request hook to handle use of --provision flag.
Args:
unused_ref: A resource ref to the parsed resource.
args: Parsed args namespace containing the flags.
request: The request message to be modified.
Returns:
The modified request message.
"""
if not args.IsSpecified('provision'):
return request
if args.IsSpecified('provision_release') or args.IsSpecified(
'provision_input_variables'
):
return request
request.unitOperation.provision = {}
return request
def HandleEmptyUpgrade(unused_ref, args, request):
"""Request hook to handle use of --upgrade flag.
Args:
unused_ref: A resource ref to the parsed resource.
args: Parsed args namespace containing the flags.
request: The request message to be modified.
Returns:
The modified request message.
"""
if not args.IsSpecified('upgrade'):
return request
if args.IsSpecified('upgrade_release') or args.IsSpecified(
'upgrade_input_variables'
):
return request
request.unitOperation.upgrade = {}
return request
def HandleEmptyDeprovision(unused_ref, args, request):
"""Request hook to handle use of --deprovision flag.
Args:
unused_ref: A resource ref to the parsed resource.
args: Parsed args namespace containing the flags.
request: The request message to be modified.
Returns:
The modified request message.
"""
if not args.IsSpecified('deprovision'):
return request
request.unitOperation.deprovision = {}
return request
def HandleOneOfOperationTypeUpdate(unused_ref, args, request):
"""Request hook to handle updates to the operation type.
The declarative framework does not fully support one_of fields in updates. For
example, if the command 'saas-runtime unit-operations update --provision' is
run, the request will have an empty upgrade field but that field should not be
present at all. This hook will delete the unspecified one_of field from the
request.
Args:
unused_ref: A resource ref to the parsed resource.
args: Parsed args namespace containing the flags.
request: The request message to be modified.
Returns:
The modified request message.
"""
provision_flags = [
'add_provision_input_variables',
'clear_provision_input_variables',
'clear_provision_release',
'provision',
'provision_input_variables',
'provision_release',
'remove_provision_input_variables',
]
upgrade_flags = [
'add_upgrade_input_variables',
'clear_upgrade_input_variables',
'clear_upgrade_release',
'upgrade',
'upgrade_input_variables',
'upgrade_release',
'remove_upgrade_input_variables',
]
deprovision_flags = ['deprovision']
operation_flags = {
'provision': any(args.IsSpecified(flag) for flag in provision_flags),
'upgrade': any(args.IsSpecified(flag) for flag in upgrade_flags),
'deprovision': any(args.IsSpecified(flag) for flag in deprovision_flags),
}
for operation, is_specified in operation_flags.items():
if (
not is_specified
and hasattr(request.unitOperation, operation)
and getattr(request.unitOperation, operation) is not None
):
setattr(request.unitOperation, operation, None)
return request