def __init__(self, api_client=None):
     if api_client is None:
         api_client = ApiClient()
     self.api_client = api_client
def main():

    urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)

    parser = argparse.ArgumentParser()
    parser.add_argument('command', choices=['network'], type=str,
                        help='command = "network" for retrieving network count ' \
                             'and a list of network devices')
    parser.add_argument('-i',
                        '--ipaddress',
                        type=str,
                        help='DNA Center cluster ip address')
    parser.add_argument('-u',
                        '--uname',
                        type=str,
                        default='admin',
                        help='DNA Center login username')
    args = parser.parse_args()

    if valid_ip(args.ipaddress) == False:
        print('You need to provide a valid ipaddress')
        sys.exit('Invalid ipaddress')
    if args.uname == '':
        print('You need to provide a valid DNAC login username')
        sys.exit('Invalid username')

    # Prompt for password
    dnacPwd = getpass.getpass(
        "\nPlease enter the DNA Center \'{}\' user password for the {} cluster : "
        .format(args.uname, args.ipaddress))
    #Set up configuration
    config = Configuration()
    config.host = "https://" + args.ipaddress
    config.username = args.uname
    config.password = dnacPwd
    # Set the following to True if you want to enable SSL verification
    config.verify_ssl = False
    config.debug = False

    #Get Basic Auth of credentials
    config.api_key = config.get_basic_auth_token()
    #Create client by passing the config params
    apic = ApiClient(configuration=config,
                     header_name='Authorization',
                     header_value=config.api_key)
    #Get the auth token
    tokenRequest = GenerateTokenRequest()
    auth_instance = MiscApi(apic)
    auth_response = auth_instance.post_auth_token(request=tokenRequest,
                                                  authorization=config.api_key)
    token = auth_response.token
    # Set X-AUTH-TOKEN
    apic.set_default_header("X-AUTH-TOKEN", token)

    # Call the APIs
    api_instance = NetworkDeviceApi(apic)
    print("\nGetting device count\n")
    count_response = api_instance.get_network_device_count()
    print(count_response.response)
    print("\n")
    print("Getting devices\n")
    template = '{:<20} {:<25} {:<6}'
    table_headers = ['PlatformId', 'Hostname', 'Serial']
    table_ul = ['--------', '----------', '------']
    dev_response = api_instance.get_network_device()
    print(template.format(*table_headers))
    print(template.format(*table_ul))
    for dev in dev_response.response:
        dev_dict = dev.to_dict()
        print(
            template.format(dev_dict["platform_id"], dev_dict["hostname"],
                            dev_dict["serial_number"]))
    print("\n")