# AUTOGENERATED! DO NOT EDIT! File to edit: ../../nbs/routes/page.ipynb.

# %% auto 0
__all__ = ['get_page_by_id', 'get_page_definition']

# %% ../../nbs/routes/page.ipynb 2
import httpx
import pandas as pd

import domolibrary.client.get_data as gd
import domolibrary.client.ResponseGetData as rgd
import domolibrary.client.DomoAuth as dmda


# %% ../../nbs/routes/page.ipynb 3
async def get_page_by_id(auth: dmda.DomoAuth, page_id: str,
                         debug_api: bool = False, 
                         session: httpx.AsyncClient = None,
                         ) -> rgd.ResponseGetData:
    url = f'https://{auth.domo_instance}.domo.com/api/content/v3/stacks/{page_id}/cards'

    res = await gd.get_data(
        auth=auth,
        url=url,
        method='GET',
        debug_api=debug_api,
        session = session,
    )

    res.response


    return res

# %% ../../nbs/routes/page.ipynb 6
async def get_page_definition(auth, page_id, debug_api: bool = False, session: httpx.AsyncClient = None):

    close_session = False if session else True

    if not session:
        session = httpx.AsyncClient()
    try:
        url = f"https://{auth.domo_instance}.domo.com/api/content/v3/stacks/{page_id}/cards"

        params = {"includeV4PageLayouts": "true",
                  "parts": "metadata,datasources,library,drillPathURNs,certification,owners,dateInfo,subscriptions,slicers"}

        res = await gd.get_data(url,
                             method='GET',
                             auth=auth,
                             session=session,
                             params=params, debug_api=debug_api)

        return res
    finally:
        if close_session:
            await session.aclose()
