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,36 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""The command group for the Cloud IDS operations CLI."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Operations(base.Group):
"""Manage Cloud IDS Operations.
The {command} group lets you manage Cloud IDS Operations,
including canceling, waiting for complition, listing ,and describing their
properties.
More information on Cloud IDS Operations can be found at
https://cloud.google.com/intrusion-detection-system
"""
category = base.NETWORKING_CATEGORY

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""'ids operations cancel' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ids import ids_api
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ids import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Cancel a Cloud IDS operation.
""",
'EXAMPLES':
"""
To cancel an operation called `my-operation` in
project `my-project` and zone `us-central1-a`, run:
$ {command} my-operation --project=my-project --zone=us-central1-a
OR
$ {command} projects/myproject/locations/us-central1-a/endpoints/my-operation
""",
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Wait(base.Command):
"""Cancel a Cloud IDS operation."""
@staticmethod
def Args(parser):
flags.AddOperationResource(parser)
def Run(self, args):
operation = args.CONCEPTS.operation.Parse()
client = ids_api.Client(self.ReleaseTrack())
return client.CancelOperations(operation.RelativeName())
Wait.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,58 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""'ids operations describe' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ids import ids_api
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ids import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Describe a Cloud IDS operation.
""",
'EXAMPLES':
"""
To get a description of an operation called `my-operation` in
project `my-project` and zone `us-central1-a`, run:
$ {command} my-operation --project=my-project --zone=us-central1-a
OR
$ {command} projects/myproject/locations/us-central1-a/operations/my-operation
""",
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Describe(base.DescribeCommand):
"""Describe a Cloud IDS operation."""
@staticmethod
def Args(parser):
flags.AddOperationResource(parser)
def Run(self, args):
operation = args.CONCEPTS.operation.Parse()
client = ids_api.Client(self.ReleaseTrack())
return client.DescribeOperation(operation.RelativeName())
Describe.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,71 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""'ids operations list' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.ids import ids_api
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ids import flags
from googlecloudsdk.command_lib.util.args import common_args
from googlecloudsdk.core import properties
DETAILED_HELP = {
'DESCRIPTION':
"""
List Cloud IDS operation in a project.
""",
'EXAMPLES':
"""
$ {command} --project=my-project
The project is automatically read from the core/project property if it is defined.
""",
}
_FORMAT = """\
table(
name.scope("operations"):label=ID,
name.scope("locations").segment(0):label=LOCATION,
metadata.target,
metadata.verb,
done
)
"""
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class List(base.ListCommand):
"""List Cloud IDS operations."""
@classmethod
def Args(cls, parser):
parser.display_info.AddFormat(_FORMAT)
parser.display_info.AddUriFunc(flags.MakeGetUriFunc(cls.ReleaseTrack()))
common_args.ProjectArgument().AddToParser(parser)
flags.AddZoneArg(
parser, required=False, help_text='The zone of an operation')
def Run(self, args):
project = args.project or properties.VALUES.core.project.GetOrFail()
zone = args.zone or '-'
name = 'projects/{}/locations/{}'.format(project, zone)
client = ids_api.Client(self.ReleaseTrack())
return client.ListOperations(name, args.limit, args.page_size)
List.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,66 @@
# -*- coding: utf-8 -*- #
# Copyright 2022 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.
"""'ids operations wait' command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
import datetime
from googlecloudsdk.api_lib.ids import ids_api
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.ids import flags
DETAILED_HELP = {
'DESCRIPTION':
"""
Wait for a Cloud IDS operation to complete.
""",
'EXAMPLES':
"""
To get a description of an operation called `my-operation` in
project `my-project` and zone `us-central1-a`, run:
$ {command} my-operation --project=my-project --zone=us-central1-a
OR
$ {command} projects/myproject/locations/us-central1-a/operations/my-operation
""",
}
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Wait(base.Command):
"""Wait for a Cloud IDS operation to complete."""
@staticmethod
def Args(parser):
flags.AddOperationResource(parser)
flags.AddMaxWait(parser, '60m') # default to 60 minutes wait.
def Run(self, args):
operation = args.CONCEPTS.operation.Parse()
max_wait = datetime.timedelta(seconds=args.max_wait)
client = ids_api.Client(self.ReleaseTrack())
return client.WaitForOperation(
operation_ref=operation,
message='Waiting for operation to complete',
has_result=False,
max_wait=max_wait)
Wait.detailed_help = DETAILED_HELP