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,45 @@
# -*- coding: utf-8 -*- #
# Copyright 2019 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.
"""Command group for Artifact Registry versions."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.UniverseCompatible
class Versions(base.Group):
"""Manage Artifact Registry package versions.
## EXAMPLES
To list all versions for a package when the `artifacts/repository` and
`artifacts/location` properties are set to a repository in the current
project, run:
$ {command} list --package=my-pkg
To delete version `1.0.0` under package `my-pkg`, run:
$ {command} delete 1.0.0 --package=my-pkg
To delete version `1.0.0` under package `my-pkg` with its tags, run:
$ {command} delete 1.0.0 --package=my-pkg --delete-tags
"""
category = base.CI_CD_CATEGORY

View File

@@ -0,0 +1,38 @@
- release_tracks: [ALPHA, BETA, GA]
help_text:
brief: |
Delete an Artifact Registry package version.
description: |
Delete an Artifact Registry package version.
This command can fail for the following reasons:
* The specified package version does not exist.
* The active account does not have permission to delete package versions.
examples: |
To delete version `1.0.0` of `my-pkg` under the current project, repository, and location, run:
$ {command} 1.0.0 --package=my-pkg
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.artifacts.resources:version
help_text: |
The Artifact Registry package version to delete.
params:
- arg_name: delete-tags
type: bool
default: false
help_text: |
If specified, all tags associated with the version are deleted.
request: &request
api_version: v1
collection: artifactregistry.projects.locations.repositories.packages.versions
modify_request_hooks:
- googlecloudsdk.command_lib.artifacts.util:EscapeVersionNameHook
- googlecloudsdk.command_lib.artifacts.util:DeleteVersionTags
async:
collection: artifactregistry.projects.locations.operations

View File

@@ -0,0 +1,40 @@
- release_tracks: [GA]
help_text:
brief: |
Describe an Artifact Registry package version.
description: |
Describe an Artifact Registry package version.
This command can fail for the following reasons:
* The specified package version does not exist.
* The active account does not have permission to describe package versions.
examples: |
To describe version `1.0.0` of `my-pkg` under the current project, repository, and location, run:
$ {command} 1.0.0 --package=my-pkg
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.artifacts.resources:version
help_text: |
The Artifact Registry package version to describe.
params:
- arg_name: show-package-vulnerability
type: bool
default: false
help_text: |
Include vulnerability metadata in the output.
request: &request
api_version: v1
collection: artifactregistry.projects.locations.repositories.packages.versions
modify_request_hooks:
- googlecloudsdk.command_lib.artifacts.util:EscapeVersionNameHook
response:
modify_response_hooks:
- googlecloudsdk.command_lib.artifacts.version_util:ShortenRelatedTags
- googlecloudsdk.command_lib.artifacts.version_util:ListOccurrences
- googlecloudsdk.command_lib.artifacts.version_util:ConvertFingerprint

View File

@@ -0,0 +1,78 @@
# -*- 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.
"""Export an Artifact Registry version."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.artifacts import flags
from googlecloudsdk.command_lib.artifacts import requests
from googlecloudsdk.core import log
from googlecloudsdk.core import resources
@base.UniverseCompatible
@base.ReleaseTracks(base.ReleaseTrack.GA)
class Export(base.Command):
"""Export an Artifact Registry package version.
Export files of an Artifact Registry package version to a Google Cloud Storage
path.
"""
detailed_help = {
'DESCRIPTION': '{description}',
'EXAMPLES': """\
To export version `1.0.0` of package `my-pkg` to a Google Cloud Storage path `gs://my-bucket/sub-folder` under the current project, repository, and location, run:
$ {command} 1.0.0 --package=my-pkg --gcs-destination=gs://my-bucket/sub-folder
""",
}
@staticmethod
def Args(parser):
"""Set up arguments for this command.
Args:
parser: An argparse.Parser.
"""
flags.GetRequiredVersionFlag().AddToParser(parser)
parser.add_argument(
'--gcs-destination',
metavar='GCS_DESTINATION',
required=True,
help='Google Cloud Storage path to export the artifact to.',
)
def Run(self, args):
"""Run the export command."""
version_ref = args.CONCEPTS.version.Parse()
# ExportArtifact takes the gcs_destination path without the "gs://" prefix.
# We allow the "gs://" prefix here to match yum/apt/googet import commands.
gcs_destination = args.gcs_destination.removeprefix('gs://')
op = requests.ExportArtifact(version_ref, None, gcs_destination)
op_ref = resources.REGISTRY.ParseRelativeName(
op.name, collection='artifactregistry.projects.locations.operations'
)
log.status.Print(
'Export request issued from [{}] to [{}].\nCreated operation [{}].'
.format(
version_ref.RelativeName(),
args.gcs_destination,
op_ref.RelativeName(),
)
)

View File

@@ -0,0 +1,121 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 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.
"""List Artifact Registry versions."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.artifacts import flags
from googlecloudsdk.command_lib.artifacts import version_util
DEFAULT_LIST_FORMAT = """\
table(
name.basename().sub("%5E", "^"):label=VERSION,
description,
createTime.date(tz=LOCAL),
updateTime.date(tz=LOCAL),
metadata.imageSizeBytes:label=SIZE,
annotations
)"""
@base.DefaultUniverseOnly
class List(base.ListCommand):
"""List Artifact Registry package versions.
List all Artifact Registry versions in the specified package.
To specify the maximum number of versions to list, use the --limit flag.
"""
detailed_help = {
'DESCRIPTION':
'{description}',
'EXAMPLES':
"""\
The following command lists a maximum of five packages versions:
$ {command} --limit=5
To list versions of package `my_pkg` with name as `1.0-SNAPSHOT`:
$ {command} --package=my_pkg --filter='name="projects/my-project/locations/us/repositories/my-repo/packages/my_pkg/versions/1.0-SNAPSHOT"'
To list versions of package `my_pkg` with a given partial name, use `*` to match any character in name:
$ {command} --package=my_pkg --filter='name="projects/my-project/locations/us/repositories/my-repo/packages/my_pkg/versions/1.0*"'
$ {command} --package=my_pkg --filter='name="projects/my-project/locations/us/repositories/my-repo/packages/my_pkg/versions/*SNAPSHOT"'
To list versions of package `my_pkg` that have annotations:
$ {command} --package=my_pkg --filter=annotations:*
To list versions of package `my_pkg` with annotations pair as [annotation_key: annotation_value]:
$ {command} --package=my_pkg --filter='annotations.annotation_key:annotation_value'
To list versions of package `my_pkg` with annotations containing key as `my_key`:
$ {command} --package=my_pkg --filter=annotations.my_key
If the key or value contains special characters, such as `my.key` and `my.value`, backtick("`") is required:
$ {command} --filter='annotations.`my.key`'
$ {command} --filter='annotations.`my.key`:`my.value`'
To list versions of package `my_pkg` with given partial annotation key or value, use `*` to match any character:
$ {command} --filter='annotations.*key:`*.value`'
To list versions of package `my_pkg` ordered by create_time:
$ {command} --package=my_pkg --sort-by=create_time
To list versions of package `my_pkg` ordered by update_time reversely:
$ {command} --package=my_pkg --sort-by=~update_time
"""
}
@staticmethod
def Args(parser):
parser.display_info.AddFormat(DEFAULT_LIST_FORMAT)
base.URI_FLAG.RemoveFromParser(parser)
flags.GetRepoFlag().AddToParser(parser)
parser.add_argument(
'--package',
required=True,
help="""List all versions in a specified artifact, such as a container
image or a language package."""
)
def Run(self, args):
"""This is what gets called when the user runs this command.
Args:
args: an argparse namespace. All the arguments that were provided to this
command invocation.
Returns:
A list of package versions.
"""
return (
version_util.ConvertFingerprint(v, args)
for v in version_util.ListVersions(args)
)

View File

@@ -0,0 +1,40 @@
- release_tracks: [GA]
help_text:
brief: |
Update annotations on an Artifact Registry package version.
description: |
Update annotations on an Artifact Registry package version.
examples: |
To update annotations on version `1.0.0` of `my-pkg` when the project ID, repository and location defaults are set, run the following command:
CAUTION: This command will overwrite any existing annotations on the version.
$ {command} 1.0.0 --package=my-pkg --annotations=key1=value1,key2=value2
To clear all annotations on the version run the following command:
$ {command} 1.0.0 --package=my-pkg --annotations={}
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.artifacts.resources:version
help_text: |
The Artifact Registry package version to update.
params:
- arg_name: annotations
api_field: version.annotations
required: false
help_text: |
List of annotations in the format of KEY=VALUE pairs to add, update, or remove.
Duplicate keys will be overwritten. For more details on annotations,
see https://google.aip.dev/148#annotations.
spec:
- api_field: key
- api_field: value
request: &request
api_version: v1
collection: artifactregistry.projects.locations.repositories.packages.versions
modify_request_hooks:
- googlecloudsdk.command_lib.artifacts.util:EscapeVersionNameHook