1# -*- coding: utf-8 -*- # Lint as: python3 2# Copyright 2020 Google Inc. All Rights Reserved. 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Command to describe an Apigee long running operation.""" 15 16from __future__ import absolute_import 17from __future__ import division 18from __future__ import unicode_literals 19 20from googlecloudsdk.api_lib import apigee 21from googlecloudsdk.calliope import base 22from googlecloudsdk.command_lib.apigee import defaults 23from googlecloudsdk.command_lib.apigee import resource_args 24 25 26class Describe(base.DescribeCommand): 27 """Describe an Apigee long running operation.""" 28 29 detailed_help = { 30 "EXAMPLES": 31 """\ 32 To describe an operation with UUID ``e267d2c8-04f4-0000-b890-a241de823b0e'' 33 given that its matching Cloud Platform project has been set in gcloud 34 settings, run: 35 36 $ {command} e267d2c8-04f4-0000-b890-a241de823b0e 37 38 To describe an operation with UUID ``e267d2c8-04f4-0000-b890-a241de823b0e'' 39 within an organization named ``my-org'', formatted as JSON, run: 40 41 $ {command} e267d2c8-04f4-0000-b890-a241de823b0e --organization=my-org --format=json 42 """ 43 } 44 45 @staticmethod 46 def Args(parser): 47 resource_args.AddSingleResourceArgument( 48 parser, "organization.operation", 49 "Operation to be described. To get a list of available operations, run " 50 "`{{parent_command}} list`.", 51 fallthroughs=[defaults.GCPProductOrganizationFallthrough()]) 52 53 def Run(self, args): 54 """Run the describe command.""" 55 identifiers = args.CONCEPTS.operation.Parse().AsDict() 56 return apigee.OperationsClient.Describe(identifiers) 57