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,48 @@
# -*- 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.
"""Command group for Namespace."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes namespaces',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Namespace(base.Group):
"""Fleet namespaces are the fleet equivalent of k8s cluster namespaces.
This command group allows for manipulation of fleet namespaces.
## EXAMPLES
Manage fleet namespaces:
$ {command} --help
Manage RBAC RoleBindings in a fleet namespace:
$ {command} rbacrolebindings --help
"""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,77 @@
# -*- 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.
"""Command to create a fleet namespace."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.api_lib.container.fleet import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
from googlecloudsdk.command_lib.container.fleet import resources
from googlecloudsdk.command_lib.util.apis import arg_utils
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes namespaces create',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Create(base.CreateCommand):
"""Create a fleet namespace.
This command can fail for the following reasons:
* The project specified does not exist.
* The project has a fleet namespace with the same name.
* The caller does not have permission to access the given project.
## EXAMPLES
To create a fleet namespace with name `NAMESPACE` in the active project, run:
$ {command} NAMESPACE
To create a fleet namespace in fleet scope `SCOPE` in project `PROJECT_ID`
with name
`NAMESPACE`, run:
$ {command} NAMESPACE --scope=SCOPE --project=PROJECT_ID
"""
@classmethod
def Args(cls, parser):
parser.add_argument(
'NAME',
type=str,
help='Name of the fleet namespace to be created. Must comply with'
' RFC 1123 (up to 63 characters, alphanumeric and \'-\')')
resources.AddScopeResourceArg(
parser,
'--scope',
util.VERSION_MAP[cls.ReleaseTrack()],
scope_help='Name of the fleet scope to create the fleet namespace in.',
)
def Run(self, args):
scope = None
scope_arg = args.CONCEPTS.scope.Parse()
if scope_arg is not None:
scope = scope_arg.RelativeName()
project = arg_utils.GetFromNamespace(args, '--project', use_defaults=True)
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
return fleetclient.CreateNamespace(args.NAME, scope, project)

View File

@@ -0,0 +1,61 @@
# -*- 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.
"""Command to delete a fleet namespace."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
from googlecloudsdk.command_lib.util.apis import arg_utils
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes namespaces delete',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Delete(base.DeleteCommand):
"""Delete a fleet namespace.
This command can fail for the following reasons:
* The project specified does not exist.
* The namespace specified does not exist.
* The caller does not have permission to access the given project or
namespace.
## EXAMPLES
To delete fleet namespace `NAMESPACE` in the active project:
$ {command} NAMESPACE
To delete fleet namespace `NAMESPACE` in project `PROJECT_ID`:
$ {command} NAMESPACE --project=PROJECT_ID
"""
@staticmethod
def Args(parser):
parser.add_argument(
'NAME', type=str, help='Name of the fleet namespace to be deleted.')
def Run(self, args):
project = arg_utils.GetFromNamespace(args, '--project', use_defaults=True)
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
return fleetclient.DeleteNamespace(project, args.NAME)

View File

@@ -0,0 +1,62 @@
# -*- 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.
"""Command to show fleet information."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
from googlecloudsdk.command_lib.util.apis import arg_utils
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes namespaces describe',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Describe(base.DescribeCommand):
"""Show fleet namespace info.
This command can fail for the following reasons:
* The project specified does not exist.
* The namespace specified does not exist in the project.
* The caller does not have permission to access the project or namespace.
## EXAMPLES
To print metadata for the namespace `NAMESPACE` in the active project,
run:
$ {command} NAMESPACE
To print metadata for the namespace `NAMESPACE` in project `PROJECT_ID`,
run:
$ {command} NAMESPACE --project=PROJECT_ID
"""
@staticmethod
def Args(parser):
parser.add_argument(
'NAME', type=str, help='Name of the fleet namespace to be described.')
def Run(self, args):
project = arg_utils.GetFromNamespace(args, '--project', use_defaults=True)
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
return fleetclient.GetNamespace(project, args.NAME)

View File

@@ -0,0 +1,62 @@
# -*- 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.
"""Command to show fleet namespaces in a project."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
from googlecloudsdk.command_lib.container.fleet import util
from googlecloudsdk.core import properties
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes namespaces list',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class List(base.ListCommand):
"""List fleet namespaces in a project.
This command can fail for the following reasons:
* The project specified does not exist.
* The user does not have access to the project specified.
## EXAMPLES
The following command lists namespaces in the active project:
$ {command}
The following command lists namespaces in project `PROJECT_ID`:
$ {command} --project=PROJECT_ID
"""
@staticmethod
def Args(parser):
# Table formatting
parser.display_info.AddFormat(util.NS_LIST_FORMAT)
def Run(self, args):
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
project = args.project
if project is None:
project = properties.VALUES.core.project.Get()
return fleetclient.ListNamespaces(project)

View File

@@ -0,0 +1,44 @@
# -*- 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.
"""Command group for RBAC RoleBindings."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes rbacrolebindings',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Namespace(base.Group):
"""Fleet namespace RBAC RoleBindings for permissions.
This command group allows for manipulation of fleet namespace RBAC
RoleBindings.
## EXAMPLES
Manage RBAC RoleBindings:
$ {command} --help
"""
category = base.COMPUTE_CATEGORY

View File

@@ -0,0 +1,91 @@
# -*- 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.
"""Command to create a fleet namespace RBAC RoleBinding."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.api_lib.container.fleet import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
from googlecloudsdk.command_lib.container.fleet import resources
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes rbacrolebindings create',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Create(base.CreateCommand):
"""Create an RBAC RoleBinding.
This command can fail for the following reasons:
* The RBAC RoleBinding already exists.
* The caller does not have permission to access the given namespace.
## EXAMPLES
To create an admin RBAC RoleBinding `RBRB` in namespace `NAMESPACE` for user
`person@google.com`, run:
$ {command} RBRB --namespace=NAMESPACE --role=admin
--user=person@google.com
To create a viewer RBAC RoleBinding `RBRB` in namespace `NAMESPACE` for group
`people@google.com`, run:
$ {command} RBRB --namespace=NAMESPACE --role=viewer
--group=people@google.com
"""
@classmethod
def Args(cls, parser):
resources.AddRBACResourceArg(
parser,
api_version=util.VERSION_MAP[cls.ReleaseTrack()],
rbacrb_help=(
'Name of the RBAC RoleBinding to be created. '
'Must comply with RFC 1123 (up to 63 characters, '
"alphanumeric and '-')"
),
)
group = parser.add_mutually_exclusive_group(required=True)
group.add_argument(
'--user',
type=str,
help='User for the RoleBinding.',
)
group.add_argument(
'--group',
type=str,
help='Group for the RoleBinding.',
)
parser.add_argument(
'--role',
required=True,
choices=['admin', 'edit', 'view'],
help='Role to assign.',
)
def Run(self, args):
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
return fleetclient.CreateRBACRoleBinding(
resources.RBACResourceName(args),
role=args.role,
user=args.user,
group=args.group)

View File

@@ -0,0 +1,63 @@
# -*- 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.
"""Command to delete a fleet namespace."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.api_lib.container.fleet import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
from googlecloudsdk.command_lib.container.fleet import resources
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes rbacrolebindings delete',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Delete(base.DeleteCommand):
"""Delete a fleet namespace RBAC RoleBinding.
This command can fail for the following reasons:
* The RoleBinding specified does not exist.
* The caller does not have permission to access the given RoleBinding.
## EXAMPLES
To delete RBAC RoleBinding `RBRB` in namespace `NAMESPACE` in the active
project:
$ {command} RBRB --namespace=NAMESPACE
"""
@classmethod
def Args(cls, parser):
resources.AddRBACResourceArg(
parser,
api_version=util.VERSION_MAP[cls.ReleaseTrack()],
rbacrb_help=(
'Name of the RBAC RoleBinding to be created. '
'Must comply with RFC 1123 (up to 63 characters, '
"alphanumeric and '-')"
),
)
def Run(self, args):
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
return fleetclient.DeleteRBACRoleBinding(resources.RBACResourceName(args))

View File

@@ -0,0 +1,63 @@
# -*- 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.
"""Command to show fleet information."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.api_lib.container.fleet import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
from googlecloudsdk.command_lib.container.fleet import resources
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes rbacrolebindings',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Describe(base.DescribeCommand):
"""Show fleet namespace RBAC RoleBinding information.
This command can fail for the following reasons:
* The RoleBinding specified does not exist in the project.
* The caller does not have permission to access the RoleBinding.
## EXAMPLES
To print metadata for RBAC RoleBinding `RBRB` in the namespace `NAMESPACE`,
run:
$ {command} RBRB --namespace=NAMESPACE
"""
@classmethod
def Args(cls, parser):
resources.AddRBACResourceArg(
parser,
api_version=util.VERSION_MAP[cls.ReleaseTrack()],
rbacrb_help=(
'Name of the RBAC RoleBinding to be created. '
'Must comply with RFC 1123 (up to 63 characters, '
"alphanumeric and '-')"
),
)
def Run(self, args):
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
return fleetclient.GetRBACRoleBinding(resources.RBACResourceName(args))

View File

@@ -0,0 +1,69 @@
# -*- 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.
"""Command to show fleet namespaces in a project."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.calliope import base
from googlecloudsdk.calliope import exceptions as calliope_exceptions
from googlecloudsdk.command_lib import deprecation_utils
from googlecloudsdk.command_lib.container.fleet import util
from googlecloudsdk.core import properties
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes rbacrolebindings list',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class List(base.ListCommand):
"""List RBAC RoleBindings in a fleet namespace.
This command can fail for the following reasons:
* The namespace specified does not exist.
* The user does not have access to the specified namespace.
## EXAMPLES
The following command lists RBAC RoleBindings in namespace `NAMESPACE` in
project `PROJECT_ID`:
$ {command} --namespace=NAMESPACE --project=PROJECT_ID
"""
@staticmethod
def Args(parser):
# Table formatting
parser.display_info.AddFormat(util.RB_LIST_FORMAT)
parser.add_argument(
'--namespace',
type=str,
required=True,
help='Name of the fleet namespace to list RBAC RoleBindings from.')
def Run(self, args):
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
project = args.project
if project is None:
project = properties.VALUES.core.project.Get()
if args.IsKnownAndSpecified('namespace'):
return fleetclient.ListRBACRoleBindings(project, args.namespace)
raise calliope_exceptions.RequiredArgumentException(
'namespace', 'Namespace parent is required.')

View File

@@ -0,0 +1,94 @@
# -*- 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.
"""Command to update fleet information."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.api_lib.container.fleet import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib import deprecation_utils
from googlecloudsdk.command_lib.container.fleet import resources
@deprecation_utils.DeprecateCommandAtVersion(
remove_version='447.0.0',
remove=True,
alt_command='gcloud fleet scopes rbacrolebindings update',
)
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Update(base.UpdateCommand):
"""Update a fleet namespace RBAC RoleBinding.
This command can fail for the following reasons:
* The RoleBinding does not exist in the project.
* The caller does not have permission to access the RoleBinding.
## EXAMPLES
To update the RBAC RoleBinding `RBRB` in namespace `NAMESPACE` in the active
project to the `viewer` role:
$ {command} RBRB --namespace=NAMESPACE --role=viewer
To update the RBAC RoleBinding `RBRB` in namespace `NAMESPACE` in the active
project to the user `someone@google.com`:
$ {command} RBRB --namespace=NAMESPACE --user=someone@google.com
"""
@classmethod
def Args(cls, parser):
resources.AddRBACResourceArg(
parser,
api_version=util.VERSION_MAP[cls.ReleaseTrack()],
rbacrb_help=(
'Name of the RBAC RoleBinding to be updated. '
'Must comply with RFC 1123 (up to 63 characters, '
"alphanumeric and '-')"
),
)
group = parser.add_mutually_exclusive_group()
group.add_argument(
'--user',
type=str,
help='User for the RBACRoleBinding to update to.',
)
group.add_argument(
'--group',
type=str,
help='Group for the RBACRoleBinding to update to.',
)
parser.add_argument(
'--role',
choices=['admin', 'edit', 'view'],
help='Role for the RBACRoleBinding to update to.',
)
def Run(self, args):
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
mask = []
for flag in ['role', 'user', 'group']:
if args.IsKnownAndSpecified(flag):
mask.append(flag)
return fleetclient.UpdateRBACRoleBinding(
resources.RBACResourceName(args),
user=args.user,
group=args.group,
role=args.role,
mask=','.join(mask))

View File

@@ -0,0 +1,72 @@
# -*- 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.
"""Command to update fleet information."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.container.fleet import client
from googlecloudsdk.api_lib.container.fleet import util
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.container.fleet import resources
from googlecloudsdk.command_lib.util.apis import arg_utils
@base.ReleaseTracks(base.ReleaseTrack.ALPHA, base.ReleaseTrack.BETA)
class Update(base.UpdateCommand):
"""Update a fleet namespace.
This command can fail for the following reasons:
* The project specified does not exist.
* The fleet namespace does not exist in the project.
* The caller does not have permission to access the project or namespace.
## EXAMPLES
To update the namespace `NAMESPACE` in the active project:
$ {command} NAMESPACE
To update the namespace `NAMESPACE` in project `PROJECT_ID`:
$ {command} NAMESPACE --project=PROJECT_ID
"""
@classmethod
def Args(cls, parser):
parser.add_argument(
'NAME', type=str, help='Name of the namespace to be updated.')
resources.AddScopeResourceArg(
parser,
'--scope',
util.VERSION_MAP[cls.ReleaseTrack()],
scope_help='Name of the fleet scope to create the fleet namespace in.',
)
def Run(self, args):
mask = []
for flag in ['scope']:
if args.IsKnownAndSpecified(flag):
mask.append(flag)
scope = None
scope_arg = args.CONCEPTS.scope.Parse()
if scope_arg is not None:
scope = scope_arg.RelativeName()
project = arg_utils.GetFromNamespace(args, '--project', use_defaults=True)
fleetclient = client.FleetClient(release_track=self.ReleaseTrack())
return fleetclient.UpdateNamespace(
args.NAME, scope, project, mask=','.join(mask)
)