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,33 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 Backup for GKE."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class GKEBackup(base.Group):
"""Backup for GKE Services."""
category = base.COMPUTE_CATEGORY
def Filter(self, context, args):
"""See base class."""
base.RequireProjectID(args)
return context

View File

@@ -0,0 +1,29 @@
# -*- 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.
"""Command group for Backup Channel."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class BackupChannels(base.Group):
"""Backup for GKE Backup Channels."""
category = base.BACKUP_CATEGORY

View File

@@ -0,0 +1,40 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Create a backup channel.
description: |
Create a Backup for GKE backup channel.
## EXAMPLES
To create a backup channel ``my-backup-channel'' in project ``my-project'' in location ``us-central1'' with destination project ``projects/backup-project'', run:
$ {command} my-backup-channel --project=my-project --location=us-central1 --destination-project=projects/backup-project
request:
collection: gkebackup.projects.locations.backupChannels
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the backup channel to create. Once the channel is created, this name can't be
changed. This must be 63 or fewer characters long and must be unique within
the project and location. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupChannels/<backupChannel>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP_CHANNEL --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_channel
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_destination_project
required: true
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_channel_description
labels:
api_field: backupChannel.labels

View File

@@ -0,0 +1,37 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Delete a backup channel.
description: |
Delete a Backup for GKE backup channel.
## EXAMPLES
To delete a backup channel ``my-backup-channel'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-backup-channel --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.backupChannels
modify_request_hooks:
- googlecloudsdk.command_lib.container.backup_restore.hooks:AddForceToDeleteRequest
api_version: v1
arguments:
resource:
help_text: |
Name of the backup channel to delete. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupChannels/<backupChannel>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP_CHANNEL --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_channel
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:etag
async:
collection: gkebackup.projects.locations.operations
api_version: v1
extract_resource_result: false

View File

@@ -0,0 +1,28 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a backup channel.
description: |
Describe a Backup for GKE backup channel.
## EXAMPLES
To describe a backup channel ``my-backup-channel'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-backup-channel --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.backupChannels
api_version: v1
arguments:
resource:
help_text: |
Name of the backup channel to describe. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/backupChannels/<backupChannel>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP_CHANNEL --project=<project> --location=<location>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_channel

View File

@@ -0,0 +1,40 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List backup channels.
description: |
List Backup for GKE backup channels.
## EXAMPLES
To list all backup channels in project ``my-project'' in location ``us-central1'', run:
$ {command} --project=my-project --location=us-central1
To list all backup channels in project ``my-project'' across all locations, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.backupChannels
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the location from which to list backup channels (provided via options or through
properties):
`--project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_location
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
destinationProject:label=DESTINATION_PROJECT
)

View File

@@ -0,0 +1,39 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Update a backup channel.
description: |
Update a Backup for GKE backup channel.
## EXAMPLES
To update a backup channel ``my-backup-channel'' in project ``my-project'' in location ``us-central1'' to add new description, run:
$ {command} my-backup-channel --project=my-project --location=us-central1 --description="New description"
request:
collection: gkebackup.projects.locations.backupChannels
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the backup channel to update. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupChannels/<backupChannel>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g. `BACKUP_CHANNEL --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_channel
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_channel_etag
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_channel_description
labels:
api_field: backupChannel.labels
update:
read_modify_update: true

View File

@@ -0,0 +1,29 @@
# -*- 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.
"""Command group for Backup Plan Bindings."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class BackupPlanBindings(base.Group):
"""Backup for GKE Backup Plan Bindings."""
category = base.BACKUP_CATEGORY

View File

@@ -0,0 +1,27 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a backup plan binding.
description: |
Describe a Backup for GKE backup plan binding.
## EXAMPLES
To describe a backup plan binding ``my-backup-plan-binding'' in project ``my-project'' in location ``us-central1'' under backup channel ``my-backup-channel'', run:
$ {command} my-backup-plan-binding --backup-channel=my-backup-channel --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.backupChannels.backupPlanBindings
api_version: v1
arguments:
resource:
help_text: |
Name of the backup plan binding to describe. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupChannels/<backupChannel>/backupPlanBindings/<backupPlanBinding>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP_PLAN_BINDING --project=<project> --location=<location> --backup-channel=<backupChannel>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:backup_plan_binding

View File

@@ -0,0 +1,43 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List backup plan bindings.
description: |
List Backup Plan Bindings for GKE backup plan bindings.
## EXAMPLES
To list all backup plan bindings in project ``my-project'' in location ``us-central1'' under backup channel ``my-backup-channel'', run:
$ {command} --backup-channel=my-backup-channel --project=my-project --location=us-central1
To list all backup plan bindings in project ``my-project'' across all locations under all backup channels, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.backupChannels.backupPlanBindings
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the backup channel from which to list backup plan bindings (provided via options or through
properties), e.g.
`--project=<project> --location=<location> --backup-channel=<backupChannel>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:backup_channel
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
name.segment(5):label=BACKUP_CHANNEL,
createTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
cluster,
backupPlan
)

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 Backup Plan."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class BackupPlans(base.Group):
"""Backup for GKE Backup Plans."""
category = base.BACKUP_CATEGORY

View File

@@ -0,0 +1,76 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Create a backup plan.
description: |
Create a Backup for GKE backup plan.
## EXAMPLES
To create a backup plan ``my-backup-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-backup-plan --project=my-project --location=us-central1 --cluster=projects/my-project/locations/us-central1/clusters/my-cluster --all-namespaces
request:
collection: gkebackup.projects.locations.backupPlans
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the backup plan to create. Once the plan is created, this name can't be changed.
This must be 63 or fewer characters long and must be unique within the project and location.
The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP_PLAN --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_plan
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_plan_cluster
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_plan_description
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:deactivated
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_plan_tags
# Retention policy
- group:
required: false
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_delete_lock_days
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_retain_days
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:locked
# Backup schedule
- group:
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:paused
- group:
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cron_schedule
- group:
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:target_rpo_minutes
required: true
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:exclusion_windows_file
# Backup scope
- group:
required: true
mutex: true
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:all_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:selected_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:selected_applications
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:selected_namespace_labels
# Backup config
- group:
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:include_volume_data
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:include_secrets
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:encryption_key
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:permissive_mode
labels:
api_field: backupPlan.labels

View File

@@ -0,0 +1,35 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Delete a backup plan.
description: |
Delete a Backup for GKE backup plan.
## EXAMPLES
To delete a backup plan ``my-backup-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-backup-plan --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.backupPlans
api_version: v1
arguments:
resource:
help_text: |
Name of the backup plan to delete. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP_PLAN --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_plan
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:etag
async:
collection: gkebackup.projects.locations.operations
api_version: v1
extract_resource_result: false

View File

@@ -0,0 +1,27 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a backup plan.
description: |
Describe a Backup for GKE backup plan.
## EXAMPLES
To describe a backup plan ``my-backup-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-backup-plan --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.backupPlans
api_version: v1
arguments:
resource:
help_text: |
Name of the backup plan to describe. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP_PLAN --project=<project> --location=<location>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_plan

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Get the IAM policy for a backup plan.
description: |
Display the IAM policy associated with a backup plan.
## EXAMPLES
To display the IAM policy associated with a backup plan ``my-backup-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-backup-plan --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.backupPlans
api_version: v1
arguments:
resource:
help_text: |
Name of the backup plan for which to display IAM policy. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP_PLAN --project=<project> --location=<location>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_plan

View File

@@ -0,0 +1,42 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List backup plans.
description: |
List Backup for GKE backup plans.
## EXAMPLES
To list all backup plans in project ``my-project'' in location ``us-central1'', run:
$ {command} --project=my-project --location=us-central1
To list all backup plans in project ``my-project'' across all locations, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.backupPlans
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the location from which to list backup plans (provided via options or through
properties):
`--project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_location
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
cluster.basename(),
deactivated.yesno(yes='N', no='Y'):label=ACTIVE,
backupSchedule.paused.yesno(yes='Y', no='N'):label=PAUSED
)

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Set the IAM policy for a backup plan.
description: |
Set the IAM policy for a backup plan.
## EXAMPLES
To set the IAM policy for a backup plan ``my-backup-plan'' in project ``my-project'' in location ``us-central1'' with the policy defined in the JSON file ``policy.json'', run:
$ {command} my-backup-plan policy.json --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.backupPlans
api_version: v1
arguments:
resource:
help_text: |
Name of the backup plan for which to set IAM policy. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP_PLAN --project=<project> --location=<location>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_plan

View File

@@ -0,0 +1,75 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Update a backup plan.
description: |
Update a Backup for GKE backup plan.
## EXAMPLES
To update a backup plan ``my-backup-plan'' in project ``my-project'' in location ``us-central1'' to add new description, run:
$ {command} my-backup-plan --project=my-project --location=us-central1 --description="New description"
request:
collection: gkebackup.projects.locations.backupPlans
modify_request_hooks:
- googlecloudsdk.command_lib.container.backup_restore.hooks:PreprocessUpdateBackupPlan
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the backup plan to update. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g. `BACKUP_PLAN --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_backup_plan
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_plan_etag
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_plan_description
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:deactivated
# Retention policy
- group:
required: false
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_delete_lock_days
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_retain_days
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:locked
# Backup schedule
- group:
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:paused
- group:
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cron_schedule
- group:
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:target_rpo_minutes
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:exclusion_windows_file
# Backup scope
- group:
mutex: true
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:all_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:selected_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:selected_applications
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:selected_namespace_labels
# Backup config
- group:
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:include_volume_data
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:include_secrets
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:encryption_key
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:permissive_mode
labels:
api_field: backupPlan.labels
update:
read_modify_update: true

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 Backup."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Backups(base.Group):
"""Backup for GKE Backups."""
category = base.BACKUP_CATEGORY

View File

@@ -0,0 +1,136 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google Inc. 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.
"""Create command for Backup for GKE backup."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.backup_restore import util as api_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.backup_restore import resource_args
from googlecloudsdk.command_lib.util.args import labels_util
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Create(base.CreateCommand):
"""Creates a backup.
Creates a Backup for GKE backup.
## EXAMPLES
To create a backup ``my-backup'' in project ``my-project'' in location
``us-central1'' under backup plan ``my-backup-plan'', run:
$ {command} my-backup --project=my-project --location=us-central1
--backup-plan=my-backup-plan
To create a backup ``my-backup'' in project ``my-project'' in location
``us-central1'' under backup plan ``my-backup-plan'' and not wait for the
resulting operation to finish, run:
$ {command} my-backup --project=my-project --location=us-central1
--backup-plan=my-backup-plan --async
To create a backup ``my-backup'' in project ``my-project'' in location
``us-central1'' under backup plan ``my-backup-plan'' and wait for the Backup
to complete, run:
$ {command} my-backup --project=my-project --location=us-central1
--backup-plan=my-backup-plan --wait-for-completion
"""
@staticmethod
def Args(parser):
resource_args.AddBackupArg(parser)
group = parser.add_group(mutex=True)
group.add_argument(
'--async',
required=False,
action='store_true',
default=False,
help='Return immediately, without waiting for the operation in progress to complete.'
)
group.add_argument(
'--wait-for-completion',
required=False,
action='store_true',
default=False,
help='Wait for the created backup to complete.')
parser.add_argument(
'--description',
type=str,
required=False,
default=None,
help='Optional text description for the backup being created.')
parser.add_argument(
'--retain-days',
type=int,
required=False,
default=None,
help="""
Retain days specifies the desired number of days from the createTime of
this backup after which it will be automatically deleted.
If not specified or set to 0, it means the backup will NOT be automatically
deleted.
Manual creation of a backup with this field unspecified causes the service
to use the value of backupPlan.retentionPolicy.backupRetainDays.
Creation of a Backup with this field set to a value SMALLER than
delete_lock_days results in an invalid response from the service.
This field may ONLY be increased in an Update request, or an invalid
response will be returned by the service immediately.
Default to 0 if not provided.
""")
parser.add_argument(
'--delete-lock-days',
type=int,
required=False,
default=None,
help="""
Delete lock days specifies the number of days from the createTime of this
Backup before which deletion will be blocked. Must be >= the value in
the backup plan. If not specified, inherited from the backup plan.
Manual creation of a backup with this field unspecified causes the
service to use the value of backupPlan.RetentionPolicy.backupDeleteBlockDays.
Creation of a backup with this field set to a value SMALLER than
backupPlan.RetentionPolicy.backupDeleteBlockDays results in an invalid
response from the service.
This field MUST be an int value between 0-90(inclusive).
This field may only be INCREASED in an update command, or an invalid
response will be returned by the service.
""")
labels_util.AddCreateLabelsFlags(parser)
def Run(self, args):
labels = labels_util.GetUpdateLabelsDictFromArgs(args)
backup_ref = args.CONCEPTS.backup.Parse()
if args.IsSpecified('async'):
return api_util.CreateBackup(
backup_ref,
description=args.description,
labels=labels,
retain_days=args.retain_days,
delete_lock_days=args.delete_lock_days)
api_util.CreateBackupAndWaitForLRO(
backup_ref,
description=args.description,
labels=labels,
retain_days=args.retain_days,
delete_lock_days=args.delete_lock_days)
if not args.IsSpecified('wait_for_completion'):
return []
return api_util.WaitForBackupToFinish(backup_ref.RelativeName())

View File

@@ -0,0 +1,37 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Delete a backup.
description: |
Delete a Backup for GKE backup.
## EXAMPLES
To delete a backup ``my-backup'' in project ``my-project'' in location ``us-central1'' under backup plan ``my-backup-plan'', run:
$ {command} my-backup --backup-plan=my-backup-plan --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.backupPlans.backups
modify_request_hooks:
- googlecloudsdk.command_lib.container.backup_restore.hooks:AddForceToDeleteRequest
api_version: v1
arguments:
resource:
help_text: |
Name of the backup to delete. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>/backups/<backup>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP --project=<project> --location=<location> --backup-plan=<backupPlan>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:backup
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:etag
async:
collection: gkebackup.projects.locations.operations
api_version: v1
extract_resource_result: false

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a backup.
description: |
Describe a Backup for GKE backup.
## EXAMPLES
To describe a backup ``my-backup'' in project ``my-project'' in location ``us-central1'' under backup plan ``my-backup-plan'', run:
$ {command} my-backup --backup-plan=my-backup-plan --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.backupPlans.backups
api_version: v1
arguments:
resource:
help_text: |
Name of the backup to describe. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>/backups/<backup>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP --project=<project> --location=<location> --backup-plan=<backupPlan>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:backup

View File

@@ -0,0 +1,49 @@
# -*- coding: utf-8 -*- #
# Copyright 2024 Google Inc. 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.
"""Create command for Backup for GKE backup."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.backup_restore import util as api_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.backup_restore import resource_args
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class GetBackupIndexDownloadUrl(base.Command):
"""Get a backup index download URL.
Get backup index download URL for a Backup for GKE backup. Backup index
displays resources' basic information stored in the backup.
## EXAMPLES
To get the backup index associated with a backup ``my-backup'' in backup plan
``my-backup-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-backup --project=my-project --location=us-central1
--backup-plan=my-backup-plan
"""
@staticmethod
def Args(parser):
resource_args.AddBackupArg(parser)
def Run(self, args):
backup_ref = args.CONCEPTS.backup.Parse()
return api_util.GetBackupIndexDownloadUrl(backup_ref)

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Get the IAM policy for a backup.
description: |
Display the IAM policy associated with a backup.
## EXAMPLES
To display the IAM policy associated with a backup ``my-backup'' in backup plan ``my-backup-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-backup --project=my-project --location=us-central1 --backup-plan=my-backup-plan
request:
collection: gkebackup.projects.locations.backupPlans.backups
api_version: v1
arguments:
resource:
help_text: |
Name of the backup for which to display IAM policy. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>/backups/<backup>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP --project=<project> --location=<location> --backup-plan=<backupPlan>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:backup

View File

@@ -0,0 +1,43 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List backups.
description: |
List Backup for GKE backups.
## EXAMPLES
To list all backups in project ``my-project'' in location ``us-central1'' under backup plan ``my-backup-plan'', run:
$ {command} --backup-plan=my-backup-plan --project=my-project --location=us-central1
To list all backups in project ``my-project'' across all locations under all backup plans, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.backupPlans.backups
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the backup plan from which to list backups (provided via options or through
properties), e.g.
`--project=<project> --location=<location> --backup-plan=<backupPlan>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_backup_plan
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
name.segment(5):label=BACKUP_PLAN,
createTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
completeTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
state
)

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Set the IAM policy for a backup.
description: |
Set the IAM policy associated with a backup.
## EXAMPLES
To set the IAM policy associated with a backup ``my-backup'' in backup plan ``my-backup-plan'' in project ``my-project'' in location ``us-central1'' with the policy defined in the JSON file ``policy.json'', run:
$ {command} my-backup policy.json --project=my-project --location=us-central1 --backup-plan=my-backup-plan
request:
collection: gkebackup.projects.locations.backupPlans.backups
api_version: v1
arguments:
resource:
help_text: |
Name of the backup for which to set IAM policy. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>/backups/<backup>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP --project=<project> --location=<location> --backup-plan=<backupPlan>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:backup

View File

@@ -0,0 +1,73 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Update a backup.
description: |
Update a Backup for GKE backup.
## EXAMPLES
To update a backup ``my-backup'' in project ``my-project'' in location ``us-central1'' under backup plan ``my-backup-plan'' to add new description, run:
$ {command} 'my-backup' --backup-plan=my-backup-plan --project=my-project --location=us-central1 --description="New description"
request:
collection: gkebackup.projects.locations.backupPlans.backups
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the backup to update. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>/backups/<backup>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`BACKUP --project=<project> --location=<location> --backup-plan=<backupPlan>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:backup
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:backup_etag
- arg_name: description
api_field: backup.description
type: str
help_text: |
Optional text description for the backup.
- arg_name: retain-days
api_field: backup.retainDays
type: int
help_text: |
Retain days specifies the desired number of days from the createTime of
this backup after which it will be automatically deleted.
If not specified or set to 0, it means the backup will NOT be
automatically deleted.
Manual creation of a backup with this field unspecified causes the
service to use the value of backupPlan.retentionPolicy.backupRetainDays.
Creation of a backup with this field set to a value SMALLER than
deleteLockDays results in an invalid response from the service.
This field may ONLY be increased in an Update command, or an invalid
response will be returned by the service immediately.
Default to 0.
- arg_name: delete-lock-days
api_field: backup.deleteLockDays
type: int
help_text: |
Delete lock days specifies the number of days from the createTime of this
Backup before which deletion will be blocked. Must be >= the value in
the backup plan. If not specified, inherited from the backup plan.
Manual creation of a backup with this field unspecified causes the service
to use the value of backupPlan.RetentionPolicy.backupDeleteBlockDays.
Creation of a backup with this field set to a value SMALLER than
backupPlan.RetentionPolicy.backupDeleteBlockDays results in an invalid
response from the service.
This field MUST be an int value between 0-90(inclusive).
This field may only be INCREASED in an update command, or an invalid
response will be returned by the service.
labels:
api_field: backup.labels
update:
read_modify_update: true

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 Location."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Locations(base.Group):
"""Backup for GKE Locations."""
category = base.UNCATEGORIZED_CATEGORY

View File

@@ -0,0 +1,20 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a location.
description: |
Describe a Backup for GKE location.
## EXAMPLES
To describe a location 'us-central1' in project 'my-project', run:
$ {command} us-central1 --project=my-project
request:
collection: gkebackup.projects.locations
api_version: v1
arguments:
resource:
help_text: Location to describe.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:location

View File

@@ -0,0 +1,30 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List locations.
description: |
List Backup for GKE locations.
## EXAMPLES
To list all locations in project 'my-project', run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: Project under which the locations to list.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_project
output:
format: |
table(
name
)

View File

@@ -0,0 +1,27 @@
# -*- coding: utf-8 -*- #
# Copyright 2025 Google Inc. 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 Operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
@base.DefaultUniverseOnly
class Operation(base.Group):
"""Backup for GKE Operations."""
category = base.UNCATEGORIZED_CATEGORY

View File

@@ -0,0 +1,18 @@
- help_text:
brief: Describe an operation.
description: |
Describe a Backup for GKE operation.
## EXAMPLES
To describe an operation ``OPERATION'' in project ``my-project'', run:
$ {command} OPERATION --project=my-project
request:
collection: gkebackup.projects.locations.operations
arguments:
resource:
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:operation
help_text: Operation to describe.

View File

@@ -0,0 +1,42 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List operations.
description: |
List Backup for GKE operations.
## EXAMPLES
To list all operations in project ``my-project'' in location ``us-central1'', run:
$ {command} --project=my-project --location=us-central1
To list all operations in project ``my-project'' across all locations, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.operations
api_version: v1
arguments:
resource:
help_text: |
Name of the location from which to list operations (provided via options or through
properties):
`--project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_location
response:
id_field: name
output:
format: |
table(
name.scope("operations"):label=ID,
name.scope("locations").segment(0):label=LOCATION,
metadata.target:label=TARGET,
metadata.verb:label=TYPE,
done:label=DONE,
error.code:label=ERROR_CODE
)

View File

@@ -0,0 +1,29 @@
# -*- 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.
"""Command group for Restore Channel."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class RestoreChannels(base.Group):
"""Backup for GKE Restore Channels."""
category = base.RESTORE_CATEGORY

View File

@@ -0,0 +1,40 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Create a restore channel.
description: |
Create a Backup for GKE restore channel.
## EXAMPLES
To create a restore channel ``my-restore-channel'' in project ``my-project'' in location ``us-central1'' with destination project ``projects/restore-project'', run:
$ {command} my-restore-channel --project=my-project --location=us-central1 --destination-project=projects/restore-project
request:
collection: gkebackup.projects.locations.restoreChannels
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the restore channel to create. Once the channel is created, this name can't be
changed. This must be 63 or fewer characters long and must be unique within
the project and location. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restoreChannels/<restoreChannel>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_CHANNEL --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_channel
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_destination_project
required: true
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_channel_description
labels:
api_field: restoreChannel.labels

View File

@@ -0,0 +1,35 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Delete a restore channel.
description: |
Delete a Backup for GKE restore channel.
## EXAMPLES
To delete a restore channel ``my-restore-channel'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-restore-channel --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.restoreChannels
api_version: v1
arguments:
resource:
help_text: |
Name of the restore channel to delete. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restoreChannels/<restoreChannel>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_CHANNEL --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_channel
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:etag
async:
collection: gkebackup.projects.locations.operations
api_version: v1
extract_resource_result: false

View File

@@ -0,0 +1,28 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a restore channel.
description: |
Describe a Backup for GKE restore channel.
## EXAMPLES
To describe a restore channel ``my-restore-channel'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-restore-channel --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.restoreChannels
api_version: v1
arguments:
resource:
help_text: |
Name of the restore channel to describe. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/restoreChannels/<restoreChannel>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_CHANNEL --project=<project> --location=<location>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_channel

View File

@@ -0,0 +1,40 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List restore channels.
description: |
List Backup for GKE restore channels.
## EXAMPLES
To list all restore channels in project ``my-project'' in location ``us-central1'', run:
$ {command} --project=my-project --location=us-central1
To list all restore channels in project ``my-project'' across all locations, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.restoreChannels
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the location from which to list restore channels (provided via options or through
properties):
`--project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_location
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
destinationProject:label=DESTINATION_PROJECT
)

View File

@@ -0,0 +1,39 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Update a restore channel.
description: |
Update a Backup for GKE restore channel.
## EXAMPLES
To update a restore channel ``my-restore-channel'' in project ``my-project'' in location ``us-central1'' to add new description, run:
$ {command} my-restore-channel --project=my-project --location=us-central1 --description="New description"
request:
collection: gkebackup.projects.locations.restoreChannels
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the restore channel to update. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restoreChannels/<restoreChannel>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g. `RESTORE_CHANNEL --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_channel
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_channel_etag
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_channel_description
labels:
api_field: restoreChannel.labels
update:
read_modify_update: true

View File

@@ -0,0 +1,29 @@
# -*- 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.
"""Command group for Restore Plan Bindings."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class RestorePlanBindings(base.Group):
"""Backup for GKE Restore Plan Bindings."""
category = base.RESTORE_CATEGORY

View File

@@ -0,0 +1,27 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a restore plan binding.
description: |
Describe a Backup for GKE restore plan binding.
## EXAMPLES
To describe a restore plan binding ``my-restore-plan-binding'' in project ``my-project'' in location ``us-central1'' under restore channel ``my-restore-channel'', run:
$ {command} my-restore-plan-binding --restore-channel=my-restore-channel --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.restoreChannels.restorePlanBindings
api_version: v1
arguments:
resource:
help_text: |
Name of the restore plan binding to describe. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restoreChannels/<restoreChannel>/restorePlanBindings/<restorePlanBinding>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_PLAN_BINDING --project=<project> --location=<location> --restore-channel=<restoreChannel>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:restore_plan_binding

View File

@@ -0,0 +1,43 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List restore plan bindings.
description: |
List Restore Plan Bindings for GKE restore plan bindings.
## EXAMPLES
To list all restore plan bindings in project ``my-project'' in location ``us-central1'' under restore channel ``my-restore-channel'', run:
$ {command} --restore-channel=my-restore-channel --project=my-project --location=us-central1
To list all restore plan bindings in project ``my-project'' across all locations under all restore channels, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.restoreChannels.restorePlanBindings
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the restore channel from which to list restore plan bindings (provided via options or through
properties), e.g.
`--project=<project> --location=<location> --restore-channel=<restoreChannel>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:restore_channel
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
name.segment(5):label=RESTORE_CHANNEL,
createTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
restorePlan,
backupPlan
)

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 Restore Plan."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class RestorePlans(base.Group):
"""Backup for GKE Restore Plans."""
category = base.RESTORE_CATEGORY

View File

@@ -0,0 +1,76 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Create a restore plan.
description: |
Create a Backup for GKE restore plan.
## EXAMPLES
To create a restore plan ``my-restore-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-restore-plan --project=my-project --location=us-central1 --cluster=projects/my-project/locations/us-central1/clusters/my-cluster --backup-plan=projects/my-project/locations/us-central1/backupPlans/my-backup-plan --all-namespaces --namespaced-resource-restore-mode=merge-skip-on-conflict
request:
collection: gkebackup.projects.locations.restorePlans
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the restore plan to create. Once the plan is created, this name can't be changed.
This must be 63 or fewer characters long and must be unique within the project and location.
The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_PLAN --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_plan
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_cluster
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_backup_plan
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_description
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_tags
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:volume_data_restore_policy
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:volume_data_restore_policy_bindings
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:namespaced_resource_restore_mode
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_conflict_policy
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_restore_order_file
# Restore scope
- group:
required: true
mutex: true
help_text: |
The scope of namespaced resources to restore.
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_all_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_no_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_selected_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_excluded_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_selected_applications
- group:
help_text: |
The scope of cluster-scoped resources to restore.
mutex: true
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_selected_group_kinds
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_excluded_group_kinds
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_all_group_kinds
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_no_group_kinds
- group:
mutex: true
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_substitution_rules_file
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_transformation_rules_file
labels:
api_field: restorePlan.labels

View File

@@ -0,0 +1,37 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Delete a restore plan.
description: |
Delete a Backup for GKE restore plan.
## EXAMPLES
To delete a restore plan ``my-restore-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-restore-plan --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.restorePlans
modify_request_hooks:
- googlecloudsdk.command_lib.container.backup_restore.hooks:AddForceToDeleteRequest
api_version: v1
arguments:
resource:
help_text: |
Name of the restore plan to delete. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_PLAN --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_plan
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:etag
async:
collection: gkebackup.projects.locations.operations
ALPHA:
api_version: v1
extract_resource_result: false

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a restore plan.
description: |
Describe a Backup for GKE restore plan.
## EXAMPLES
To describe a restore plan ``my-restore-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-restore-plan --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.restorePlans
api_version: v1
arguments:
resource:
help_text: |
Name of the restore plan to describe. The name may be provided either as a relative name,
e.g. `projects/<project>/locations/<location>/restorePlans/<restorePlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_PLAN --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_plan

View File

@@ -0,0 +1,27 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Get the IAM policy for a restore plan.
description: |
Display the IAM policy associated with a restore plan.
## EXAMPLES
To display the IAM policy associated with a restore plan ``my-restore-plan'' in project ``my-project'' in location ``us-central1'', run:
$ {command} my-restore-plan --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.restorePlans
api_version: v1
arguments:
resource:
help_text: |
Name of the restore plan for which to display IAM policy. The name may be provided either as
a relative name, e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_PLAN --project=<project> --location=<location>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_plan

View File

@@ -0,0 +1,40 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List restore plans.
description: |
List Backup for GKE restore plans.
## EXAMPLES
To list all restore plans in project ``my-project'' in location ``us-central1'', run:
$ {command} --project=my-project --location=us-central1
To list all restore plans in project ``my-project'' across all locations, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.restorePlans
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the location from which to list restore plans (provided via options or through
properties):
`--project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_location
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
cluster.basename(),
backupPlan.basename()
)

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Set the IAM policy for a restore plan.
description: |
Set the IAM policy associated with a restore plan.
## EXAMPLES
To set the IAM policy associated with a restore plan ``my-restore-plan'' in project ``my-project'' in location ``us-central1'' with the policy defined in the JSON file ``policy.json'', run:
$ {command} my-restore-plan policy.json --project=my-project --location=us-central1
request:
collection: gkebackup.projects.locations.restorePlans
api_version: v1
arguments:
resource:
help_text: |
Name of the restore plan for which to display IAM policy. The name may be provided either as
a relative name, e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_PLAN --project=<project> --location=<location>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_plan

View File

@@ -0,0 +1,76 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Update a restore plan.
description: |
Update a Backup for GKE restore plan.
## EXAMPLES
To update a restore plan ``my-restore-plan'' in project ``my-project'' in location ``us-central1'' to add new description, run:
$ {command} my-restore-plan --project=my-project --location=us-central1 --description="New description"
request:
collection: gkebackup.projects.locations.restorePlans
modify_request_hooks:
- googlecloudsdk.command_lib.container.backup_restore.hooks:PreprocessUpdateRestorePlan
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the restore plan to update. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE_PLAN --project=<project> --location=<location>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:positional_restore_plan
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_etag
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_description
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:volume_data_restore_policy
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:volume_data_restore_policy_bindings
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:namespaced_resource_restore_mode_update
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_conflict_policy
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_restore_order_file
# Restore scope
- group:
# Update restore plan does not require these args.
help_text: |
The scope of namespaced resources to restore.
mutex: true
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_all_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_no_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_selected_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_excluded_namespaces
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_selected_applications
- group:
help_text: |
The scope of cluster-scoped resources to restore.
mutex: true
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_selected_group_kinds
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_excluded_group_kinds
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_all_group_kinds
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:cluster_resource_no_group_kinds
- group:
mutex: true
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_substitution_rules_file
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_plan_transformation_rules_file
labels:
api_field: restorePlan.labels
update:
read_modify_update: true

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 Restore."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Restores(base.Group):
"""Backup for GKE Restores."""
category = base.RESTORE_CATEGORY

View File

@@ -0,0 +1,139 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 Google Inc. 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.
"""Create command for Backup for GKE restore."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.backup_restore import util as api_util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.backup_restore import hooks
from googlecloudsdk.command_lib.container.backup_restore import resource_args
from googlecloudsdk.command_lib.util.args import labels_util
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Create(base.CreateCommand):
"""Creates a restore.
Creates a Backup for GKE restore.
## EXAMPLES
To create a restore ``my-restore'' in location ``us-central1'' under restore
plan ``my-restore-plan'', run:
$ {command} my-restore --project=my-project --location=us-central1
--restore-plan=my-restore-plan
--backup=projects/my-project/locations/us-east1/backupPlans/my-backup-plan/backups/my-backup
"""
@staticmethod
def Args(parser):
resource_args.AddRestoreArg(parser)
group = parser.add_group(mutex=True)
group.add_argument(
'--async',
required=False,
action='store_true',
default=False,
help="""
Return immediately, without waiting for the operation in progress to
complete.
""",
)
group.add_argument(
'--wait-for-completion',
required=False,
action='store_true',
default=False,
help='Wait for the created restore to complete.',
)
# TODO(b/205222596): Figure out if we can/should use the relative name of
# the backup. This would potentially require the CLI to first get the backup
# plan referenced in the parent restore plan and then concat it with the
# user input relative name.
parser.add_argument(
'--backup',
type=str,
required=True,
help="""
Name of the backup from which to restore under the backup plan specified
in restore plan.
Format: projects/<project>/locations/<location>/backupPlans/<backupPlan>/backups/<backup>.
""",
)
parser.add_argument(
'--description',
type=str,
required=False,
default=None,
help='Optional text description for the restore.',
)
parser.add_argument(
'--volume-data-restore-policy-overrides-file',
required=False,
default=None,
help="""
If provided, defines an array of volume data restore policy overrides
from the given config file in yaml.
""",
)
parser.add_argument(
'--filter-file',
required=False,
default=None,
help="""
JSON/YAML file containing the configuration of the fine-grained
restore filter which can be used to further refine the resource
selection of the Restore beyond the coarse-grained scope defined
in the RestorePlan.
For more information about examples and how to use this filter,
please refer to the Backup for GKE documentation:
https://cloud.google.com/kubernetes-engine/docs/add-on/backup-for-gke/how-to/fine-grained-restore.
""",
)
labels_util.AddCreateLabelsFlags(parser)
def Run(self, args):
labels = labels_util.GetUpdateLabelsDictFromArgs(args)
vdrpo = hooks.ReadVolumeDataRestorePolicyOverridesFile(
args.volume_data_restore_policy_overrides_file
)
restore_ref = args.CONCEPTS.restore.Parse()
restore_filter = hooks.ReadRestoreFilterFile(args.filter_file)
if args.IsSpecified('async'):
return api_util.CreateRestore(
restore_ref,
backup=args.backup,
description=args.description,
labels=labels,
volume_data_restore_policy_overrides=vdrpo,
restore_filter=restore_filter,
)
api_util.CreateRestoreAndWaitForLRO(
restore_ref=restore_ref,
backup=args.backup,
description=args.description,
labels=labels,
volume_data_restore_policy_overrides=vdrpo,
restore_filter=restore_filter,
)
if not args.IsSpecified('wait_for_completion'):
return []
return api_util.WaitForRestoreToFinish(restore_ref.RelativeName())

View File

@@ -0,0 +1,36 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Delete a restore.
description: |
Delete a Backup for GKE restore.
## EXAMPLES
To delete a restore 'my-restore' in project 'my-project' in location 'us-central1' under restore plan ``my-restore-plan'', run:
$ {command} my-restore --project=my-project --location=us-central1 --restore-plan=my-restore-plan
request:
collection: gkebackup.projects.locations.restorePlans.restores
modify_request_hooks:
- googlecloudsdk.command_lib.container.backup_restore.hooks:AddForceToDeleteRequest
api_version: v1
arguments:
resource:
help_text: |
Name of the restore to delete. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>/restores/<restore>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE --project=<project> --location=<location> --restore-plan=<restorePlan>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:restore
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:etag
async:
collection: gkebackup.projects.locations.operations
api_version: v1
extract_resource_result: false

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a restore.
description: |
Describe a Backup for GKE restore.
## EXAMPLES
To describe a restore 'my-restore' in project 'my-project' in location 'us-central1' under restore plan ``my-restore-plan'', run:
$ {command} my-restore --project=my-project --location=us-central1 --restore-plan=my-restore-plan
request:
collection: gkebackup.projects.locations.restorePlans.restores
api_version: v1
arguments:
resource:
help_text: |
Name of the restore to describe. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>/restores/<restore>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE --project=<project> --location=<location> --restore-plan=<restore-plan>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:restore

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Get the IAM policy for a restore.
description: |
Display the IAM policy associated with a restore.
## EXAMPLES
To display the IAM policy associated with a restore ``my-restore'' in project ``my-project'' in location ``us-central1'' under restore plan ``my-restore-plan'', run:
$ {command} my-restore --project=my-project --location=us-central1 --restore-plan=my-restore-plan
request:
collection: gkebackup.projects.locations.restorePlans.restores
api_version: v1
arguments:
resource:
help_text: |
Name of the restore for which to display IAM policy. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>/restores/<restore>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE --project=<project> --location=<location> --restore-plan=<restore-plan>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:restore

View File

@@ -0,0 +1,43 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List restores.
description: |
List Backup for GKE restores.
## EXAMPLES
To list all restores in project 'my-project' in location 'us-central1', run:
$ {command} --project=my-project --location=us-central1
To list all restores in project 'my-project' across all locations, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.restorePlans.restores
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the location from which to list restores (provided via options or through
properties):
`--project=<project> --location=<location> --restore-plan=<restore-plan>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_restore_plan
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
name.segment(5):label=RESTORE_PLAN,
backup.basename(),
createTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
completeTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
state
)

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Set the IAM policy for a restore.
description: |
Set the IAM policy associated with a restore.
## EXAMPLES
To set the IAM policy associated with a restore ``my-restore'' in project ``my-project'' in location ``us-central1'' under restore plan ``my-restore-plan'' with the policy defined in the JSON file ``policy.json'', run:
$ {command} my-restore policy.json --project=my-project --location=us-central1 --restore-plan=my-restore-plan
request:
collection: gkebackup.projects.locations.restorePlans.restores
api_version: v1
arguments:
resource:
help_text: |
Name of the restore for which to display IAM policy. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>/restores/<restore>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE --project=<project> --location=<location> --restore-plan=<restore-plan>`
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:restore

View File

@@ -0,0 +1,43 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Update a restore.
description: |
Update a Backup for GKE restore.
## EXAMPLES
To update a restore ``my-restore'' in project ``my-project'' in location ``us-central1'' under restore plan ``my-restore-plan'' to add new description, run:
$ {command} my-restore --project=my-project --location=us-central1 --restore-plan=my-restore-plan --description="New description"
request:
collection: gkebackup.projects.locations.restorePlans.restores
api_version: v1
async:
collection: gkebackup.projects.locations.operations
arguments:
resource:
help_text: |
Name of the restore to update. The name may be provided either as a relative name, e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>/restores/<restore>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`RESTORE --project=<project> --location=<location> --restore-plan=<restore-plan>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:restore
params:
- _REF_: googlecloudsdk.command_lib.container.backup_restore.flags:restore_etag
- arg_name: description
api_field: restore.description
type: str
help_text: |
Optional text description for the restore.
labels:
api_field: restore.labels
update:
read_modify_update: true

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 Volume Backup."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class VolumeBackups(base.Group):
"""Backup for GKE Volume Backups."""
category = base.BACKUP_CATEGORY

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a volume backup.
description: |
Describe a Backup for GKE volume backup.
## EXAMPLES
To describe a volume backup ``my-volume-backup'' in project ``my-project'' in location ``us-central1'' under backup plan ``my-backup-plan'' under backup ``my-backup'', run:
$ {command} my-volume-backup --project=my-project --location=us-central1 --backup-plan=my-backup-plan --backup=my-backup
request:
collection: gkebackup.projects.locations.backupPlans.backups.volumeBackups
api_version: v1
arguments:
resource:
help_text: |
Name of the volume backup to describe. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/backupPlans/<backupPlan>/backups/<backup>/volumeBackups/<volumeBackup>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`VOLUME_BACKUPS --project=PROJECT --location=LOCATION --backup-plan=BACKUP_PLAN --backup=BACKUP`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:volume_backup

View File

@@ -0,0 +1,49 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List volume backups.
description: |
List Backup for GKE volume backups.
## EXAMPLES
To list all volume backups in project ``my-project'' in location ``us-central1'' under backup plan ``my-backup-plan'' under backup ``my-backup'', run:
$ {command} --backup-plan=my-backup-plan --backup=my-backup --project=my-project --location=us-central1
To list all volume backups in project 'my-project' in location 'us-central1' under all backup plans under all backups, run:
$ {command} --project=my-project --location=us-central1
To list all volume backups in project 'my-project' across all locations under all backup plans under all backups, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.backupPlans.backups.volumeBackups
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the backup from which to list volume backups (provided via options or through
properties), e.g.
`--project=<project> --location=<location> --backup-plan=<backupPlan> --backup=<backup>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_backup
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
name.segment(5):label=BACKUP_PLAN,
name.segment(7):label=BACKUP,
format('{0}/{1}', sourcePvc.namespace, sourcePvc.name):label=SOURCE_PVC,
createTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
completeTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
state
)

View File

@@ -0,0 +1,29 @@
# -*- coding: utf-8 -*- #
# Copyright 2021 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 Volume Restore."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.DefaultUniverseOnly
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class VolumeRestores(base.Group):
"""Backup for GKE Volume Restores."""
category = base.RESTORE_CATEGORY

View File

@@ -0,0 +1,26 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: Describe a volume restore.
description: |
Describe a Backup for GKE volume restore.
## EXAMPLES
To describe a volume restore ``my-volume-restore'' in project ``my-project'' in location ``us-central1'' under restore plan ``my-restore-plan'' under restore ``my-restore'', run:
$ {command} my-volume-restore --project=my-project --location=us-central1 --restore-plan=my-restore-plan --restore=my-restore
request:
collection: gkebackup.projects.locations.restorePlans.restores.volumeRestores
api_version: v1
arguments:
resource:
help_text: |
Name of the volume restore to describe. The name may be provided either as a relative name,
e.g.
`projects/<project>/locations/<location>/restorePlans/<restorePlan>/restores/<restores>/volumeRestores/<volumeRestore>`
or as a single ID name (with the parent resources provided via options or through
properties), e.g.
`VOLUME_RESTORE --project=<project> --location=<location> --restore-plan=<restore-plan> --restore=<restore>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:volume_restore

View File

@@ -0,0 +1,44 @@
- release_tracks: [ALPHA, BETA]
help_text:
brief: List volume restores.
description: |
List Backup for GKE volume restores.
## EXAMPLES
To list all volume restores in project ``my-project'' in location ``us-central1'' under restore plan ``my-restore-plan'' under restores ``my-restore'', run:
$ {command} --project=my-project --location=us-central1 --restore-plan=my-restore-plan --restore=my-restore
To list all volume restores in project ``my-project'' across all locations under all restore plans and restores, run:
$ {command} --project=my-project
request:
collection: gkebackup.projects.locations.restorePlans.restores.volumeRestores
api_version: v1
response:
id_field: name
arguments:
resource:
help_text: |
Name of the restore from which to list volume restores (provided via options or through
properties), e.g.
`--project=<project> --location=<location> --restore-plan=<restore-plan> --restore=<restore>`.
spec: !REF googlecloudsdk.command_lib.container.backup_restore.resources:default_restore
output:
format: |
table(
name.basename():label=NAME,
name.segment(3):label=LOCATION,
name.segment(5):label=RESTORE_PLAN,
name.segment(7):label=RESTORE,
format('{0}/{1}', targetPvc.namespace, targetPvc.name):label=TARGET_PVC,
createTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
completeTime.date('%Y-%m-%dT%H:%M:%S %Z', tz=LOCAL),
state
)