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,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The consumer command group for Commerce Procurement."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Consumer(base.Group):
"""A group of subcommands for working with Procurement Consumer resources."""
category = base.COMMERCE_CATEGORY

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for gcloud Commerce Procurement consumer accounts."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Accounts(base.Group):
"""A group of subcommands for working with Procurement Consumer accounts."""
pass

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer accounts describe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.commerce_procurement import resource_args
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Describe(base.DescribeCommand):
"""Returns the Account object resulting from the Get API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
resource_args.AddAccountResourceArg(parser, 'Account to describe.')
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
An Account message.
"""
account_ref = args.CONCEPTS.account.Parse()
return apis.Accounts.Get(account_ref.RelativeName())

View File

@@ -0,0 +1,59 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer accounts list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.commerce_procurement import resource_args
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class List(base.ListCommand):
"""Returns the List of Account objects resulting from the List API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
resource_args.AddBillingAccountResourceArg(
parser, 'Parent Cloud Billing account to list accounts.')
base.FILTER_FLAG.RemoveFromParser(parser)
base.LIMIT_FLAG.RemoveFromParser(parser)
base.SORT_BY_FLAG.RemoveFromParser(parser)
base.URI_FLAG.RemoveFromParser(parser)
parser.add_argument(
'--page-token',
help=('Token that specifies the next page in the list.'))
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
List of accounts and next token if applicable.
"""
billing_account_ref = args.CONCEPTS.billing_account.Parse()
return apis.Accounts.List(billing_account_ref.RelativeName(),
args.page_size, args.page_token)

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for gcloud Commerce Procurement consumer entitlements."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Entitlements(base.Group):
"""A group of subcommands for working with Procurement Consumer entitlements."""
pass

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer entitlements describe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.commerce_procurement import resource_args
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Describe(base.DescribeCommand):
"""Returns the Entitlement object resulting from the Get API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
resource_args.AddEntitlementResourceArg(parser, 'Entitlement to describe.')
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
An Entitlement message.
"""
entitlement_ref = args.CONCEPTS.entitlement.Parse()
return apis.Entitlements.Get(entitlement_ref.RelativeName())

View File

@@ -0,0 +1,54 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer entitlements list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class List(base.ListCommand):
"""Returns the List of Entitlement objects resulting from the List API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
base.FILTER_FLAG.RemoveFromParser(parser)
base.LIMIT_FLAG.RemoveFromParser(parser)
base.SORT_BY_FLAG.RemoveFromParser(parser)
base.URI_FLAG.RemoveFromParser(parser)
parser.add_argument(
'--page-token',
help=('Token that specifies the next page in the list.'))
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
List of entitlements and next token if applicable.
"""
return apis.Entitlements.List(args.page_size, args.page_token)

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for gcloud Commerce Procurement consumer free trials."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class FreeTrials(base.Group):
"""A group of subcommands for working with Procurement Consumer free trials."""
pass

View File

@@ -0,0 +1,55 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer free trials create command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Create(base.Command):
"""Creates the Free Trial resource from the Create API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
parser.add_argument(
'--provider-id',
required=True,
help='ID of the provider to which the product belongs.')
parser.add_argument(
'--product-external-name',
required=True,
help='Product external name to offer the free trial of.')
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
A Free Trial operation.
"""
return apis.FreeTrials.Create(args.provider_id, args.product_external_name)

View File

@@ -0,0 +1,99 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer free trials list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
DETAILED_HELP = {
'EXAMPLES':
"""
The filter is a query string that can match a selected set of attributes
with string values. For example:
$ {command} --filter "product_external_name=1234-5678-ABCD-EFG"
Supported query attributes are the following:
* `product_external_name`
* `provider` (in the naming format of "provider/{provider-id}")
If the query contains some special characters other than letters,
underscore, or digits, the phrase must be quoted with double quotes. For
example, where the product name needs to be quoted because it contains
the special character colon:
$ {command} --filter "product_external_name=\\"foo:bar\\""
Queries can be combined with AND, OR, and NOT to form more complex
queries. They can also be grouped to force a desired evaluation order.
For example:
$ {command} --filter "provider=providers/E-1234 OR provider=providers/5678 AND NOT (product_external_name=foo-product)"
Connective AND can be omitted between two predicates. For example:
$ {command} --filter "provider=providers/E-1234 product_external_name=foo"
is equivalent to:
$ {command} --filter "provider=providers/E-1234 AND product_external_name=foo"
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class List(base.Command):
"""Returns the List of Free Trial objects resulting from the List API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
parser.add_argument(
'--page-size', type=int, help=('Maximum number of resources per page.'))
parser.add_argument(
'--page-token',
help=('Token that specifies the next page in the list.'))
parser.add_argument(
'--filter', help=('Filter that limits the list request.'))
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
List of free trials and next token if applicable.
"""
result = apis.FreeTrials.List(args.page_size, args.page_token, args.filter)
# Clear the filter on args so the built-in functionality will not overwrite
# already filtered result.
args.filter = ''
return result
List.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for gcloud Commerce Procurement consumer operations."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Operations(base.Group):
"""A group of subcommands for working with Procurement Consumer operations."""
pass

View File

@@ -0,0 +1,56 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer operations describe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.commerce_procurement import resource_args
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Describe(base.DescribeCommand):
"""Returns the Operation object resulting from the Get API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
operation_name_group = parser.add_mutually_exclusive_group(required=True)
resource_args.AddOrderOperationResourceArg(operation_name_group,
'Order operation to describe.')
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
An Operation message.
"""
order_operation_ref = args.CONCEPTS.order_operation.Parse()
if order_operation_ref:
return apis.Operations.GetOrderOperation(
order_operation_ref.RelativeName())
else:
raise ValueError('No matching operation spoecified')

View File

@@ -0,0 +1,28 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 Google LLC. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""The command group for gcloud Commerce Procurement consumer orders."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.calliope import base
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Orders(base.Group):
"""A group of subcommands for working with Procurement Consumer orders."""
pass

View File

@@ -0,0 +1,52 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer order cancel command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.commerce_procurement import resource_args
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Cancel(base.Command):
"""Cancels the order resource from the Cancel API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
resource_args.AddOrderResourceArg(parser, 'Order to describe.')
parser.add_argument(
'--etag', help='The weak etag for validation check, if specified.')
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
An Order operation.
"""
order_ref = args.CONCEPTS.order.Parse()
return apis.Orders.Cancel(order_ref.RelativeName(), args.etag)

View File

@@ -0,0 +1,98 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer order place command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.commerce_procurement import resource_args
DETAILED_HELP = {
'EXAMPLES':
"""
To purchase a product-based order, you must specify product request. For
example:
$ {command} --product-request product-external-name=productId,flavor-external-name=flavorId
To specify parameters, you must follow the pattern
"ParameterName=ParameterType:ParameterValue". For example:
$ {command} --product-request product-external-name=productId,flavor-external-name=flavorId,region=str:us-west-1
To purchase a quote-based order, you must specify quote external name.
For example:
$ {command} --quote-external-name quoteId
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Create(base.Command):
"""Creates the order resource from the Place API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
resource_args.AddBillingAccountResourceArg(
parser, 'Parent Cloud Billing account to place order under.')
parser.add_argument(
'--display-name', required=True, help='Display name of the order.')
parser.add_argument(
'--provider-id',
required=True,
help='ID of the provider for which the order is created.')
parser.add_argument(
'--request-id', help='ID of the request for idempotency purposes.')
product_quote_group = parser.add_mutually_exclusive_group(required=True)
product_quote_group.add_argument(
'--product-request',
type=arg_parsers.ArgDict(
required_keys=['product-external-name', 'flavor-external-name']),
metavar='KEY=VALUE',
action='append',
help='Request for information about the product in the order.')
product_quote_group.add_argument(
'--quote-external-name',
help='External name of the quote for the order.')
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
An Order operation.
"""
billing_account_ref = args.CONCEPTS.billing_account.Parse()
return apis.Orders.Place(billing_account_ref.RelativeName(),
args.display_name, args.provider_id,
args.request_id, args.product_request,
args.quote_external_name)
Create.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,50 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer orders describe command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.commerce_procurement import resource_args
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Describe(base.DescribeCommand):
"""Returns the Order object resulting from the Get API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
resource_args.AddOrderResourceArg(parser, 'Order to describe.')
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
An Order message.
"""
order_ref = args.CONCEPTS.order.Parse()
return apis.Orders.Get(order_ref.RelativeName())

View File

@@ -0,0 +1,94 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer orders list command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.commerce_procurement import resource_args
DETAILED_HELP = {
'EXAMPLES':
"""
The filter is a query string that can match a selected set of attributes
with string values. For example:
$ {command} --filter "display_name=TEST"
Supported query attributes are the following:
* `display_name`
If the query contains special characters other than letters, underscore,
or digits, the phrase must be quoted with double quotes. For example,
where the display name needs to be quoted because it contains the
special character colon:
$ {command} --filter "display_name=\\"foo:bar\\""
Queries can be combined with AND, OR, and NOT to form more complex
queries. They can also be grouped to force a desired evaluation order.
For example:
$ {command} --filter "display_name=foo OR display_name=bar"
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class List(base.Command):
"""Returns the List of Order objects resulting from the List API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
resource_args.AddBillingAccountResourceArg(
parser, 'Parent Cloud Billing account to list orders for.')
parser.add_argument(
'--page-size', type=int, help=('Maximum number of resources per page.'))
parser.add_argument(
'--page-token',
help=('Token that specifies the next page in the list.'))
parser.add_argument(
'--filter', help=('Filter that limits the list request.'))
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
List of orders and next token if applicable.
"""
billing_account_ref = args.CONCEPTS.billing_account.Parse()
result = apis.Orders.List(billing_account_ref.RelativeName(),
args.page_size, args.page_token, args.filter)
# Clear the filter on args so the built-in functionality will not overwrite
# already filtered result.
args.filter = ''
return result
List.detailed_help = DETAILED_HELP

View File

@@ -0,0 +1,112 @@
# -*- coding: utf-8 -*- #
# Copyright 2020 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.
"""Implementation of gcloud Procurement consumer order modify command."""
from __future__ import absolute_import
from __future__ import division
from __future__ import unicode_literals
from googlecloudsdk.api_lib.commerce_procurement import apis
from googlecloudsdk.calliope import arg_parsers
from googlecloudsdk.calliope import base
from googlecloudsdk.command_lib.commerce_procurement import resource_args
DETAILED_HELP = {
'EXAMPLES':
"""
To modify an order to another product plan or update parameters, you
must specify product request. To specify parameters, you must follow the
pattern "ParameterName=ParameterType:ParameterValue". For example:
$ {command} --product-request line-item-id=lineItemId,line-item-change-type=UPDATE,product-external-name=productId,flavor-external-name=flavorId,region=str:us-west-1
To cancel a product plan-based order, you must specify the product
request. For example:
$ {command} --product-request line-item-id=lineItemId,line-item-change-type=CANCEL
To revert cancellation on a product plan-based order, you must specify
the product request. For example:
$ {command} --product-request line-item-id=lineItemId,line-item-change-type=REVERT_CANCELLATION
To update an order to another quote, you must specify the fields that
are related to the quote. For example:
$ {command} --quote-change-type UPDATE --new-quote-external-name quoteId
To cancel a quote-based order, you must specify the quote change type.
For example:
$ {command} --quote-change-type CANCEL
To revert cancellation on a quote-based order, you must specify the
quote change type. For example:
$ {command} --quote-change-type REVERT_CANCELLATION
""",
}
@base.Hidden
@base.ReleaseTracks(base.ReleaseTrack.ALPHA)
class Modify(base.Command):
"""Modifies the order resource from the Modify API."""
@staticmethod
def Args(parser):
"""Register flags for this command.
Args:
parser: argparse.ArgumentParser to register arguments with.
"""
resource_args.AddOrderResourceArg(parser, 'Order to modify.')
parser.add_argument(
'--etag', help='The weak etag for validation check, if specified.')
product_quote_group = parser.add_mutually_exclusive_group(required=True)
product_quote_group.add_argument(
'--product-request',
type=arg_parsers.ArgDict(
required_keys=['line-item-id', 'line-item-change-type']),
metavar='KEY=VALUE',
action='append',
help='Request about product info to modify order against.')
quote_request_group = product_quote_group.add_group(
help='Quote-related modification.')
quote_request_group.add_argument(
'--quote-change-type',
required=True,
help='Change type on quote based purchase.')
quote_request_group.add_argument(
'--new-quote-external-name',
help='The external name of the quote the order will use.')
def Run(self, args):
"""Runs the command.
Args:
args: The arguments that were provided to this command invocation.
Returns:
An Order operation.
"""
order_ref = args.CONCEPTS.order.Parse()
return apis.Orders.Modify(order_ref.RelativeName(), args.etag,
args.product_request, args.quote_change_type,
args.new_quote_external_name)
Modify.detailed_help = DETAILED_HELP