ó
º9—^c           @   s(   d  d l  Z  e d „ Z e d „ Z d S(   iÿÿÿÿNc         C   sK   t  ƒ  } x( |  D]  } i | d 6} | j | ƒ q W| rG t j | ƒ S| S(   sp    decouple, allow for modifications to return type
        returns a list of ip addresses in object or json form t   ip(   t   listt   appendt   jsont   dumps(   t
   return_sett   as_jsont   ret_listt   itemt   d(    (    sJ   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/endpoints/ip/unassigned.pyt
   format_ret   s    	c         C   s…   t  ƒ  } t |  t ƒ s( t | d | ƒSxD |  D]< } t | d ƒ } | d k r/ | d } | j | ƒ q/ q/ Wt | d | ƒ} | S(   s|   https://sendgrid.com/docs/API_Reference/api_v3.html#ip-addresses
        The /ips rest endpoint returns information about the IP addresses
        and the usernames assigned to an IP

        unassigned returns a listing of the IP addresses that are allocated
        but have 0 users assigned


        data (response.body from sg.client.ips.get())
        as_json False -> get list of dicts
                True  -> get json object

        example:
        sg = sendgrid.SendGridAPIClient(os.environ.get('SENDGRID_API_KEY'))

        params = {
            'subuser': 'test_string',
            'ip': 'test_string',
            'limit': 1,
            'exclude_whitelabels':
            'true', 'offset': 1
        }
        response = sg.client.ips.get(query_params=params)
        if response.status_code == 201:
           data = response.body
           unused = unassigned(data)
    R   t   subusersi    R    (   t   sett
   isinstanceR   R
   t   lent   add(   t   dataR   t   no_subuserst   currentt   num_subuserst
   current_ipt   ret_val(    (    sJ   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/endpoints/ip/unassigned.pyt
   unassigned   s    	
(   R   t   FalseR
   R   (    (    (    sJ   /tmp/pip-unpacked-wheel-v7av_c/sendgrid/helpers/endpoints/ip/unassigned.pyt   <module>   s   