docs: def get_subnets(
          target='ec2',
          purpose='internal',
          env='',
          region='', ):
      """Get all availability zones for a given target.
  
      Args:
          target (str): Type of subnets to look up (ec2 or elb).
          env (str): Environment to look up.
          region (str): AWS Region to find Subnets for.
  
      Returns:
          az_dict: dictionary of  availbility zones, structured like
          { $region: [ $avaibilityzones ] }
          or
          { $account: $region: [ $availabilityzone] }
      """
      account_az_dict = defaultdict(defaultdict)
      subnet_id_dict = defaultdict(defaultdict)
  
      subnet_url = '{0}/subnets/aws'.format(API_URL)
      subnet_response = requests.get(subnet_url, verify=GATE_CA_BUNDLE, cert=GATE_CLIENT_CERT)
  
      if not subnet_response.ok:
          raise SpinnakerTimeout(subnet_response.text)
  
      subnet_list = subnet_response.json()
      for subnet in subnet_list:
          LOG.debug('Subnet: %(account)s\t%(region)s\t%(target)s\t%(vpcId)s\t' '%(availabilityZone)s', subnet)
  
          if subnet.get('target', '') == target:
              availability_zone = subnet['availabilityZone']
              account = subnet['account']
              subnet_region = subnet['region']
              subnet_id = subnet['id']
              try:
                  if availability_zone not in account_az_dict[account][subnet_region]:
                      account_az_dict[account][subnet_region].append(availability_zone)
              except KeyError:
                  account_az_dict[account][subnet_region] = [availability_zone]
              # get list of all subnet IDs with correct purpose
              if subnet['purpose'] == purpose:
                  try:
                      subnet_id_dict[account][subnet_region].append(subnet_id)
                  except KeyError:
                      subnet_id_dict[account][subnet_region] = [subnet_id]
  
              LOG.debug('%s regions: %s', account, list(account_az_dict[account].keys()))
  
      if all([env, region]):
          try:
              region_dict = {region: account_az_dict[env][region]}
              region_dict['subnet_ids'] = {region: subnet_id_dict[env][region]}
              LOG.debug('Region dict: %s', region_dict)
              return region_dict
          except KeyError:
              raise SpinnakerSubnetError(env=env, region=region)
  
      LOG.debug('AZ dict:\n%s', pformat(dict(account_az_dict)))
  
      return account_az_dict