1# -*- coding: utf-8 -*- # 2# Copyright 2016 Google LLC. All Rights Reserved. 3# 4# Licensed under the Apache License, Version 2.0 (the "License"); 5# you may not use this file except in compliance with the License. 6# You may obtain a copy of the License at 7# 8# http://www.apache.org/licenses/LICENSE-2.0 9# 10# Unless required by applicable law or agreed to in writing, software 11# distributed under the License is distributed on an "AS IS" BASIS, 12# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13# See the License for the specific language governing permissions and 14# limitations under the License. 15 16"""Helper methods for configuring deployment manager command flags.""" 17 18 19from __future__ import absolute_import 20from __future__ import division 21from __future__ import unicode_literals 22 23LIST_PREVIEWED_RESOURCES_FORMAT = """ 24 table( 25 name, 26 type:wrap, 27 update.state.yesno(no="COMPLETED"), 28 update.error.errors.group(code), 29 update.intent 30 ) 31""" 32 33LIST_RESOURCES_FORMAT = """ 34 table( 35 name, 36 type:wrap, 37 update.state.yesno(no="COMPLETED"), 38 update.error.errors.group(code), 39 runtimePolicies.list(undefined="N/A", separator=", ") 40 ) 41""" 42 43DEPLOYMENT_AND_RESOURCES_AND_OUTPUTS_FORMAT = """ 44 table( 45 deployment:format='default(name, id, description, fingerprint, 46 credential.serviceAccount.email, insertTime, manifest.basename(), 47 labels, operation.operationType, operation.name, operation.progress, 48 operation.status, operation.user, operation.endTime, operation.startTime, 49 operation.error, operation.warnings, update)', 50 resources:format='table( 51 name:label=NAME, 52 type:wrap:label=TYPE, 53 update.state.yesno(no="COMPLETED"), 54 update.error.errors.group(code), 55 runtimePolicies.list(undefined="N/A", separator=", "))', 56 outputs:format='table( 57 name:label=OUTPUTS, 58 finalValue:label=VALUE)' 59 ) 60""" 61 62PREVIEWED_DEPLOYMENT_AND_RESOURCES_AND_OUTPUTS_FORMAT = """ 63 table( 64 deployment:format='default(name, id, description, fingerprint, 65 credential.serviceAccount.email, insertTime, manifest.basename(), 66 labels, operation.operationType, operation.name, operation.progress, 67 operation.status, operation.user, operation.endTime, operation.startTime, 68 operation.error, operation.warnings, update)', 69 resources:format='table( 70 name:label=NAME, 71 type:wrap:label=TYPE, 72 update.state.yesno(no="COMPLETED"), 73 update.intent)', 74 outputs:format='table( 75 name:label=OUTPUTS, 76 finalValue:label=VALUE)' 77 ) 78""" 79 80RESOURCES_AND_OUTPUTS_FORMAT = """ 81 table( 82 resources:format='table( 83 name, 84 type:wrap, 85 update.state.yesno(no="COMPLETED"), 86 update.error.errors.group(code), 87 update.intent.if(preview), 88 runtimePolicies.if(NOT preview).list(undefined="N/A", separator=", "))', 89 outputs:format='table( 90 name:label=OUTPUTS, 91 finalValue:label=VALUE)' 92 ) 93""" 94 95 96def AddCredentialFlag(parser): 97 """Add the credential argument.""" 98 parser.add_argument( 99 '--credential', 100 help=('Set the default credential that Deployment Manager uses to call ' 101 'underlying APIs of a deployment. Use PROJECT_DEFAULT to set ' 102 'deployment credential same as the credential of its owning ' 103 'project. Use serviceAccount:email to set default credential ' 104 'using provided service account.'), 105 dest='credential') 106