def get_type()

in tools/genconfig/genconfig.py [0:0]


def get_type(kind, props):
  """Converts API resource 'kind' to a DM type.

  Only supports compute right now.

  Args:
    kind: the API resource kind associated with this resource, e.g.,
      'compute#instance'

  Returns:
    The DM type for this resource, e.g., compute.v1.instance

  Raises:
    Exception: if the kind is invalid or not supported.
  """

  parts = kind.split('#')
  if len(parts) != 2:
    raise Exception('Invalid resource kind: ' + kind)

  service = {
      'compute': 'compute.v1'
  }.get(parts[0], None)

  if service is None:
    raise Exception('Unsupported resource kind: ' + kind)

  if parts[1] == 'instanceGroupManager' and 'region' in props:
    return service + '.' + 'regionInstanceGroupManager'

  return service + '.' + parts[1]