Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions docs/resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,21 @@ impresso.entities.find(term="Douglas Adams")
::: impresso.resources.entities.EntityType
::: impresso.api_client.models.find_entities_order_by.FindEntitiesOrderByLiteral

## Newspapers
## Media sources

Search newspapers available in the Impresso corpus.
Search media sources available in the Impresso corpus.

```python
impresso.newspapers.find(
impresso.media_sources.find(
term="wort",
order_by="lastIssue",
)
```

::: impresso.resources.newspapers.NewspapersResource
::: impresso.resources.media_sources.MediaSourcesResource

::: impresso.api_client.models.find_newspapers_order_by.FindNewspapersOrderByLiteral
::: impresso.resources.newspapers.FindNewspapersContainer
::: impresso.api_client.models.find_media_sources_order_by.FindMediaSourcesOrderByLiteral
::: impresso.resources.media_sources.FindMediaSourcesContainer

## Content Items

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"output_type": "stream",
"text": [
"🎉 You are now connected to the Impresso API! 🎉\n",
"🔗 Using API: https://dev.impresso-project.ch/public-api\n"
"🔗 Using API: http://localhost:3030\n"
]
}
],
Expand All @@ -24,22 +24,22 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"# Search newspapers\n",
"# Search media sources\n",
"\n",
"Find newspapers having the term 'wort' in their name."
]
},
{
"cell_type": "code",
"execution_count": 2,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div style=\"display: grid; \">\n",
"<div>\n",
"<h2>FindNewspapers result</h2>\n",
"<h2>FindMediaSources result</h2>\n",
"<div>Contains <b>2</b> items of <b>2</b> total items.</div>\n",
"<br/>\n",
"See this result in the <a href=\"https://impresso-project.ch/app/newspapers?orderBy=lastIssue&q=wort\">Impresso App</a>.\n",
Expand All @@ -64,13 +64,15 @@
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>title</th>\n",
" <th>startYear</th>\n",
" <th>endYear</th>\n",
" <th>type</th>\n",
" <th>name</th>\n",
" <th>languageCodes</th>\n",
" <th>totalArticles</th>\n",
" <th>totalIssues</th>\n",
" <th>totalPages</th>\n",
" <th>publishedPeriodYears</th>\n",
" <th>availableDatesRange</th>\n",
" <th>properties</th>\n",
" <th>totals.articles</th>\n",
" <th>totals.issues</th>\n",
" <th>totals.pages</th>\n",
" </tr>\n",
" <tr>\n",
" <th>uid</th>\n",
Expand All @@ -81,45 +83,52 @@
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" <th></th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>landwortbild</th>\n",
" <td>newspaper</td>\n",
" <td>Luxemburger Land in Wort und Bild</td>\n",
" <td>1895</td>\n",
" <td>1895</td>\n",
" <td>[de, fr]</td>\n",
" <td>755</td>\n",
" <td>[fr, de]</td>\n",
" <td>[1895, 1895]</td>\n",
" <td>[1895-04-07T00:00:00+00:00, 1895-12-29T00:00:0...</td>\n",
" <td>[]</td>\n",
" <td>735</td>\n",
" <td>39</td>\n",
" <td>314</td>\n",
" </tr>\n",
" <tr>\n",
" <th>luxwort</th>\n",
" <td>newspaper</td>\n",
" <td>Luxemburger Wort</td>\n",
" <td>1848</td>\n",
" <td>1950</td>\n",
" <td>[de, fr, lb]</td>\n",
" <td>1160333</td>\n",
" <td>30355</td>\n",
" <td>101320</td>\n",
" <td>[fr, de, lb]</td>\n",
" <td>[1848, 1950]</td>\n",
" <td>[1848-03-23T00:00:00+00:00, 1950-12-30T00:00:0...</td>\n",
" <td>[]</td>\n",
" <td>1113163</td>\n",
" <td>30372</td>\n",
" <td>161216</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
"<impresso.resources.newspapers.FindNewspapersContainer at 0x114562fd0>"
"<impresso.resources.media_sources.FindMediaSourcesContainer at 0x1170df990>"
]
},
"execution_count": 2,
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"result = impresso.newspapers.find(\n",
"result = impresso.media_sources.find(\n",
" term=\"wort\",\n",
" type=\"newspaper\",\n",
" order_by=\"lastIssue\",\n",
")\n",
"result"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,28 +6,39 @@
from ... import errors
from ...client import AuthenticatedClient, Client
from ...models.error import Error
from ...models.find_newspapers_base_find_response import FindNewspapersBaseFindResponse
from ...models.find_newspapers_order_by import FindNewspapersOrderBy
from ...models.find_media_sources_base_find_response import FindMediaSourcesBaseFindResponse
from ...models.find_media_sources_order_by import FindMediaSourcesOrderBy
from ...models.find_media_sources_type import FindMediaSourcesType
from ...types import UNSET, Response, Unset


def _get_kwargs(
*,
term: Union[Unset, str] = UNSET,
order_by: Union[Unset, FindNewspapersOrderBy] = UNSET,
type: Union[Unset, FindMediaSourcesType] = UNSET,
order_by: Union[Unset, FindMediaSourcesOrderBy] = UNSET,
include_properties: Union[Unset, bool] = False,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Dict[str, Any]:
params: Dict[str, Any] = {}

params["term"] = term

json_type: Union[Unset, str] = UNSET
if not isinstance(type, Unset):
json_type = type.value

params["type"] = json_type

json_order_by: Union[Unset, str] = UNSET
if not isinstance(order_by, Unset):
json_order_by = order_by.value

params["order_by"] = json_order_by

params["include_properties"] = include_properties

params["limit"] = limit

params["offset"] = offset
Expand All @@ -36,7 +47,7 @@ def _get_kwargs(

_kwargs: Dict[str, Any] = {
"method": "get",
"url": "/newspapers",
"url": "/media-sources",
"params": params,
}

Expand All @@ -45,9 +56,9 @@ def _get_kwargs(

def _parse_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Optional[Union[Error, FindNewspapersBaseFindResponse]]:
) -> Optional[Union[Error, FindMediaSourcesBaseFindResponse]]:
if response.status_code == HTTPStatus.OK:
response_200 = FindNewspapersBaseFindResponse.from_dict(response.json())
response_200 = FindMediaSourcesBaseFindResponse.from_dict(response.json())

return response_200
if response.status_code == HTTPStatus.UNAUTHORIZED:
Expand Down Expand Up @@ -82,7 +93,7 @@ def _parse_response(

def _build_response(
*, client: Union[AuthenticatedClient, Client], response: httpx.Response
) -> Response[Union[Error, FindNewspapersBaseFindResponse]]:
) -> Response[Union[Error, FindMediaSourcesBaseFindResponse]]:
return Response(
status_code=HTTPStatus(response.status_code),
content=response.content,
Expand All @@ -95,15 +106,19 @@ def sync_detailed(
*,
client: AuthenticatedClient,
term: Union[Unset, str] = UNSET,
order_by: Union[Unset, FindNewspapersOrderBy] = UNSET,
type: Union[Unset, FindMediaSourcesType] = UNSET,
order_by: Union[Unset, FindMediaSourcesOrderBy] = UNSET,
include_properties: Union[Unset, bool] = False,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[Union[Error, FindNewspapersBaseFindResponse]]:
"""Find newspapers that match the given query
) -> Response[Union[Error, FindMediaSourcesBaseFindResponse]]:
"""Find media sources

Args:
term (Union[Unset, str]):
order_by (Union[Unset, FindNewspapersOrderBy]):
type (Union[Unset, FindMediaSourcesType]):
order_by (Union[Unset, FindMediaSourcesOrderBy]):
include_properties (Union[Unset, bool]): Default: False.
limit (Union[Unset, int]):
offset (Union[Unset, int]):

Expand All @@ -112,12 +127,14 @@ def sync_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Error, FindNewspapersBaseFindResponse]]
Response[Union[Error, FindMediaSourcesBaseFindResponse]]
"""

kwargs = _get_kwargs(
term=term,
type=type,
order_by=order_by,
include_properties=include_properties,
limit=limit,
offset=offset,
)
Expand All @@ -133,15 +150,19 @@ def sync(
*,
client: AuthenticatedClient,
term: Union[Unset, str] = UNSET,
order_by: Union[Unset, FindNewspapersOrderBy] = UNSET,
type: Union[Unset, FindMediaSourcesType] = UNSET,
order_by: Union[Unset, FindMediaSourcesOrderBy] = UNSET,
include_properties: Union[Unset, bool] = False,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[Union[Error, FindNewspapersBaseFindResponse]]:
"""Find newspapers that match the given query
) -> Optional[Union[Error, FindMediaSourcesBaseFindResponse]]:
"""Find media sources

Args:
term (Union[Unset, str]):
order_by (Union[Unset, FindNewspapersOrderBy]):
type (Union[Unset, FindMediaSourcesType]):
order_by (Union[Unset, FindMediaSourcesOrderBy]):
include_properties (Union[Unset, bool]): Default: False.
limit (Union[Unset, int]):
offset (Union[Unset, int]):

Expand All @@ -150,13 +171,15 @@ def sync(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[Error, FindNewspapersBaseFindResponse]
Union[Error, FindMediaSourcesBaseFindResponse]
"""

return sync_detailed(
client=client,
term=term,
type=type,
order_by=order_by,
include_properties=include_properties,
limit=limit,
offset=offset,
).parsed
Expand All @@ -166,15 +189,19 @@ async def asyncio_detailed(
*,
client: AuthenticatedClient,
term: Union[Unset, str] = UNSET,
order_by: Union[Unset, FindNewspapersOrderBy] = UNSET,
type: Union[Unset, FindMediaSourcesType] = UNSET,
order_by: Union[Unset, FindMediaSourcesOrderBy] = UNSET,
include_properties: Union[Unset, bool] = False,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Response[Union[Error, FindNewspapersBaseFindResponse]]:
"""Find newspapers that match the given query
) -> Response[Union[Error, FindMediaSourcesBaseFindResponse]]:
"""Find media sources

Args:
term (Union[Unset, str]):
order_by (Union[Unset, FindNewspapersOrderBy]):
type (Union[Unset, FindMediaSourcesType]):
order_by (Union[Unset, FindMediaSourcesOrderBy]):
include_properties (Union[Unset, bool]): Default: False.
limit (Union[Unset, int]):
offset (Union[Unset, int]):

Expand All @@ -183,12 +210,14 @@ async def asyncio_detailed(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Response[Union[Error, FindNewspapersBaseFindResponse]]
Response[Union[Error, FindMediaSourcesBaseFindResponse]]
"""

kwargs = _get_kwargs(
term=term,
type=type,
order_by=order_by,
include_properties=include_properties,
limit=limit,
offset=offset,
)
Expand All @@ -202,15 +231,19 @@ async def asyncio(
*,
client: AuthenticatedClient,
term: Union[Unset, str] = UNSET,
order_by: Union[Unset, FindNewspapersOrderBy] = UNSET,
type: Union[Unset, FindMediaSourcesType] = UNSET,
order_by: Union[Unset, FindMediaSourcesOrderBy] = UNSET,
include_properties: Union[Unset, bool] = False,
limit: Union[Unset, int] = UNSET,
offset: Union[Unset, int] = UNSET,
) -> Optional[Union[Error, FindNewspapersBaseFindResponse]]:
"""Find newspapers that match the given query
) -> Optional[Union[Error, FindMediaSourcesBaseFindResponse]]:
"""Find media sources

Args:
term (Union[Unset, str]):
order_by (Union[Unset, FindNewspapersOrderBy]):
type (Union[Unset, FindMediaSourcesType]):
order_by (Union[Unset, FindMediaSourcesOrderBy]):
include_properties (Union[Unset, bool]): Default: False.
limit (Union[Unset, int]):
offset (Union[Unset, int]):

Expand All @@ -219,14 +252,16 @@ async def asyncio(
httpx.TimeoutException: If the request takes longer than Client.timeout.

Returns:
Union[Error, FindNewspapersBaseFindResponse]
Union[Error, FindMediaSourcesBaseFindResponse]
"""

return (
await asyncio_detailed(
client=client,
term=term,
type=type,
order_by=order_by,
include_properties=include_properties,
limit=limit,
offset=offset,
)
Expand Down
Loading
Loading