def esg_create(client_session, esg_name, esg_pwd, esg_size, datacentermoid, datastoremoid, resourcepoolid, default_pg,
               esg_username=None, esg_remote_access=None):
    """
    This function creates a new Edge Services Gateway
    :param client_session: An instance of an NsxClient Session
    :param esg_name: The name of the ESG to be created
    :param esg_pwd: The CLI password of the ESG
    :param esg_size: The size of the ESG, options are compact, large, quadlarge, xlarge
    :param datacentermoid: The managed object id of the vCenter DC Object to deploy the ESG in
    :param datastoremoid: The managed object id of the vCenter Datastore Object to deploy the ESG in
    :param resourcepoolid: The managed object id of the vCenter Cluster or RP Object to deploy the ESG in
    :param default_pg: The managed object id of the port group for the first vnic (on creation the first vnic must
                       be connected to a valid portgroup in NSX)
    :param esg_username: The Username for the CLI and SSH access (default: admin)
    :param esg_remote_access: Enables / Disables SSH access to the Edge Host (default: False)
    :return: returns a tuple, the first item is a string containing the Edge ID, the second is a dictionary
             containing the ESG details retrieved from the API
    """
    esg_create_dict = client_session.extract_resource_body_example('nsxEdges', 'create')

    if not esg_username:
        esg_username = 'admin'
    if not esg_remote_access:
        esg_remote_access = 'false'

    first_vnic = {'index': '0', 'portgroupId': default_pg, 'isConnected': 'True'}

    del esg_create_dict['edge']['vnics']['vnic']
    del esg_create_dict['edge']['appliances']['appliance']['hostId']
    del esg_create_dict['edge']['appliances']['appliance']['customField']

    esg_create_dict['edge']['vnics'] = {'vnic': first_vnic}

    esg_create_dict['edge']['name'] = esg_name
    esg_create_dict['edge']['cliSettings'] = {'password': esg_pwd, 'remoteAccess': esg_remote_access,
                                              'userName': esg_username}
    esg_create_dict['edge']['appliances']['applianceSize'] = esg_size
    esg_create_dict['edge']['datacenterMoid'] = datacentermoid
    esg_create_dict['edge']['appliances']['appliance']['datastoreId'] = datastoremoid
    esg_create_dict['edge']['appliances']['appliance']['resourcePoolId'] = resourcepoolid

    new_esg = client_session.create('nsxEdges', request_body_dict=esg_create_dict)
    if new_esg['status'] == 201:
        return new_esg['objectId'], new_esg['body']
    else:
        return None, None