text: # --------------------------------------------------------------------------
  # Copyright (c) Microsoft Corporation. All rights reserved.
  # Licensed under the MIT License. See License.txt in the project root for
  # license information.
  #
  # Code generated by Microsoft (R) AutoRest Code Generator.
  # Changes may cause incorrect behavior and will be lost if the code is
  # regenerated.
  # --------------------------------------------------------------------------
  # pylint: disable=protected-access
  
  import argparse
  from collections import defaultdict
  from knack.util import CLIError
  
  
  class AddResources(argparse._AppendAction):
      def __call__(self, parser, namespace, values, option_string=None):
          action = self.get_action(values, option_string)
          super(AddResources, self).__call__(parser, namespace, action, option_string)
  
      def get_action(self, values, option_string):  # pylint: disable=no-self-use
          try:
              properties = defaultdict(list)
              for (k, v) in (x.split('=', 1) for x in values):
                  properties[k].append(v)
              properties = dict(properties)
          except ValueError:
              raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
          d = {}
          for k in properties:
              kl = k.lower()
              v = properties[k]
              if kl == 'content':
                  d['content'] = v[0]
              elif kl == 'content-url':
                  d['content_url'] = v[0]
              elif kl == 'self':
                  d['self_property'] = v[0]
              elif kl == 'id':
                  d['id'] = v[0]
              else:
                  raise CLIError('Unsupported Key {} is provided for parameter resources. All possible keys are: '
                                 'content, content-url, self, id'.format(k))
          return d
  
  
  class AddApplication(argparse.Action):
      def __call__(self, parser, namespace, values, option_string=None):
          action = self.get_action(values, option_string)
          namespace.application = action
  
      def get_action(self, values, option_string):  # pylint: disable=no-self-use
          try:
              properties = defaultdict(list)
              for (k, v) in (x.split('=', 1) for x in values):
                  properties[k].append(v)
              properties = dict(properties)
          except ValueError:
              raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
          d = {}
          for k in properties:
              kl = k.lower()
              v = properties[k]
              if kl == 'display-name':
                  d['display_name'] = v[0]
              elif kl == 'id':
                  d['id'] = v[0]
              else:
                  raise CLIError('Unsupported Key {} is provided for parameter application. All possible keys are: '
                                 'display-name, id'.format(k))
          return d
  
  
  class AddError(argparse.Action):
      def __call__(self, parser, namespace, values, option_string=None):
          action = self.get_action(values, option_string)
          namespace.error = action
  
      def get_action(self, values, option_string):  # pylint: disable=no-self-use
          try:
              properties = defaultdict(list)
              for (k, v) in (x.split('=', 1) for x in values):
                  properties[k].append(v)
              properties = dict(properties)
          except ValueError:
              raise CLIError('usage error: {} [KEY=VALUE ...]'.format(option_string))
          d = {}
          for k in properties:
              kl = k.lower()
              v = properties[k]
              if kl == 'code':
                  d['code'] = v[0]
              elif kl == 'message':
                  d['message'] = v[0]
              else:
                  raise CLIError('Unsupported Key {} is provided for parameter error. All possible keys are: code, '
                                 'message'.format(k))
          return d
  