1# -*- coding: utf-8 -*- # 2# Copyright 2019 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"""Additional flags for data-catalog tags commands.""" 17 18from __future__ import absolute_import 19from __future__ import division 20from __future__ import unicode_literals 21 22from googlecloudsdk.calliope.concepts import concepts 23from googlecloudsdk.command_lib.util.apis import yaml_data 24from googlecloudsdk.command_lib.util.concepts import concept_parsers 25from googlecloudsdk.command_lib.util.concepts import presentation_specs 26 27 28def AddCreateUpdateTagFlags(): 29 """Hook for adding flags to tags create and update.""" 30 resource_spec = concepts.ResourceSpec.FromYaml( 31 yaml_data.ResourceYAMLData.FromPath('data_catalog.tag_template') 32 .GetData()) 33 presentation_spec = presentation_specs.ResourcePresentationSpec( 34 name='--tag-template', 35 concept_spec=resource_spec, 36 prefixes=True, 37 required=True, 38 flag_name_overrides={ 39 'project': '--tag-template-project', 40 }, 41 group_help="""\ 42Tag template. `--tag-template-location` defaults to the tag's location. 43`--tag-template-project` defaults to the tag's project. 44 """ 45 ) 46 tag_template_arg = concept_parsers.ConceptParser( 47 [presentation_spec], 48 command_level_fallthroughs={ 49 '--tag-template.location': ['--location'], 50 '--tag-template.project': ['--project'], 51 }, 52 ) 53 54 return [tag_template_arg] 55