def _get_network_interface(name, resource_group):
    '''
    Get a network interface.
    '''
    public_ips = []
    private_ips = []
    netapi_versions = get_api_versions(kwargs={
        'resource_provider': 'Microsoft.Network',
        'resource_type': 'publicIPAddresses'
        }
    )
    netapi_version = netapi_versions[0]
    netconn = get_conn(client_type='network')
    netiface_query = netconn.network_interfaces.get(
        resource_group_name=resource_group,
        network_interface_name=name
    )

    netiface = netiface_query.as_dict()
    for index, ip_config in enumerate(netiface['ip_configurations']):
        if ip_config.get('private_ip_address') is not None:
            private_ips.append(ip_config['private_ip_address'])
        if 'id' in ip_config.get('public_ip_address', {}):
            public_ip_name = get_resource_by_id(
                ip_config['public_ip_address']['id'],
                netapi_version,
                'name'
            )
            public_ip = _get_public_ip(public_ip_name, resource_group)
            public_ips.append(public_ip['ip_address'])
            netiface['ip_configurations'][index]['public_ip_address'].update(public_ip)

    return netiface, public_ips, private_ips
def _get_network_interface ( name , resource_group ) : public_ips = [ ] private_ips = [ ] netapi_versions = get_api_versions ( kwargs = { 'resource_provider' : 'Microsoft.Network' , 'resource_type' : 'publicIPAddresses' } ) netapi_version = netapi_versions [ 0 ] netconn = get_conn ( client_type = 'network' ) netiface_query = netconn . network_interfaces . get ( resource_group_name = resource_group , network_interface_name = name ) netiface = netiface_query . as_dict ( ) for index , ip_config in enumerate ( netiface [ 'ip_configurations' ] ) : if ip_config . get ( 'private_ip_address' ) is not None : private_ips . append ( ip_config [ 'private_ip_address' ] ) if 'id' in ip_config . get ( 'public_ip_address' , { } ) : public_ip_name = get_resource_by_id ( ip_config [ 'public_ip_address' ] [ 'id' ] , netapi_version , 'name' ) public_ip = _get_public_ip ( public_ip_name , resource_group ) public_ips . append ( public_ip [ 'ip_address' ] ) netiface [ 'ip_configurations' ] [ index ] [ 'public_ip_address' ] . update ( public_ip ) return netiface , public_ips , private_ips
Get a network interface.