Compare commits
47
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
97928d8fff | ||
|
|
10cfb565ea | ||
|
|
de1ff24e35 | ||
|
|
bc31b9f3f5 | ||
|
|
f35068761b | ||
|
|
4ce8f53e5e | ||
|
|
6438efdda8 | ||
|
|
b6b5ab23bd | ||
|
|
42db2222eb | ||
|
|
f09df855ee | ||
|
|
2eb97bc4f7 | ||
|
|
1409d801bf | ||
|
|
fc356401e4 | ||
|
|
adbd741268 | ||
|
|
fe6dd1b3e6 | ||
|
|
7770bd3841 | ||
|
|
92d4cd446f | ||
|
|
f29b3da8ed | ||
|
|
af39d73ba6 | ||
|
|
d323b75e12 | ||
|
|
b67c667376 | ||
|
|
4415683874 | ||
|
|
eba62aa568 | ||
|
|
16b129b9f6 | ||
|
|
31b0ae6ee2 | ||
|
|
5b684c1c67 | ||
|
|
16d99d7dca | ||
|
|
84ef2433ef | ||
|
|
6b2c864df1 | ||
|
|
096fbb1604 | ||
|
|
6a715d2bec | ||
|
|
fd36eeedba | ||
|
|
8fc5524ad4 | ||
|
|
3fefedc82d | ||
|
|
bea9682958 | ||
|
|
ddc2e33279 | ||
|
|
d5b5a31d1a | ||
|
|
708dd13ca0 | ||
|
|
916ec5fa61 | ||
|
|
011c14ee6a | ||
|
|
88210bf2a7 | ||
|
|
98504963f9 | ||
|
|
74f6ff7ef5 | ||
|
|
45e02a72b4 | ||
|
|
a33e38eebb | ||
|
|
a3088062f0 | ||
|
|
78e6b371e5 |
+1
-1
@@ -14,4 +14,4 @@ src/python/account/
|
||||
*.pyc
|
||||
|
||||
node_modules/
|
||||
angular-app/.angular
|
||||
angular-app/.angular
|
||||
@@ -0,0 +1 @@
|
||||
3.12
|
||||
+2
-1
@@ -14,7 +14,8 @@ RUN mkdir /test && \
|
||||
"uvicorn~=0.29.0" \
|
||||
"pytest~=8.1.0" \
|
||||
"httpx~=0.27.0" \
|
||||
"python-multipart~=0.0.19"
|
||||
"python-multipart~=0.0.19"\
|
||||
"elasticsearch~=9.4.0"
|
||||
|
||||
COPY [ "src/main", "/home" ]
|
||||
COPY [ "src/data", "/data" ]
|
||||
|
||||
@@ -31,7 +31,7 @@ task exportOpenApiSpec(type: Exec) {
|
||||
'--entrypoint', 'python',
|
||||
"${imagePrefix}-service:${imageVersion}",
|
||||
'-c',
|
||||
"import json; from inse.service import app; open('/mnt/openapi/inse-service.openapi.json', 'w').write(json.dumps(app.openapi(), indent=2))"
|
||||
"import json; from inse.main import app; open('/mnt/openapi/inse-service.openapi.json', 'w').write(json.dumps(app.openapi(), indent=2))"
|
||||
}
|
||||
|
||||
task runServeContainer(type: Exec) {
|
||||
@@ -40,8 +40,8 @@ task runServeContainer(type: Exec) {
|
||||
}
|
||||
|
||||
task stopServeContainer(type: Exec) {
|
||||
dependsOn runServeContainer
|
||||
commandLine 'docker', 'stop', "${imageName}-service-serve"
|
||||
ignoreExitValue true
|
||||
}
|
||||
|
||||
task serve(type: Task) {
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
[project]
|
||||
name = "service"
|
||||
version = "0.1.0"
|
||||
description = "Add your description here"
|
||||
readme = "README.md"
|
||||
requires-python = ">=3.12"
|
||||
dependencies = [
|
||||
"cryptography~=42.0.0",
|
||||
"dotenv>=0.9.9",
|
||||
"elasticsearch~=9.4.0",
|
||||
"fastapi~=0.115.0",
|
||||
"httpx~=0.27.0",
|
||||
"pydantic~=2.7.1",
|
||||
"pydantic-settings~=2.2.1",
|
||||
"pyjwt~=2.8.0",
|
||||
"pytest~=8.1.0",
|
||||
"python-multipart~=0.0.19",
|
||||
"pyyaml~=6.0.1",
|
||||
"sqlalchemy~=2.0.0",
|
||||
"uvicorn~=0.29.0",
|
||||
]
|
||||
@@ -0,0 +1,6 @@
|
||||
ELASTICSEARCH_URL=https://project.nes.uni-due.de/elastic/
|
||||
ELASTICSEARCH_API_KEY=am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ
|
||||
|
||||
LLM_API_URL=https://project.nes.uni-due.de/llm2/api/generate
|
||||
LLM_API_KEY=c2d5e7ccf7a4760dd3d19bed2caed9d85ff7437400e0ea82a6d6f912ebc2f212
|
||||
LLM_MODEL=gemma4:e4b
|
||||
@@ -1,9 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
Standalone account service that provides identity and access
|
||||
token endpoints for authentication.
|
||||
Standalone account service that provides identity and access
|
||||
token endpoints for authentication.
|
||||
"""
|
||||
|
||||
import logging
|
||||
import fastapi
|
||||
import typing
|
||||
@@ -17,62 +18,109 @@ from starlette.status import HTTP_500_INTERNAL_SERVER_ERROR
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
app = fastapi.FastAPI(docs_url='/api',
|
||||
title='My App Account Service',
|
||||
version='1.0.0')
|
||||
router = fastapi.APIRouter(
|
||||
prefix="/inse-account",
|
||||
tags=["INSE Account Service"],
|
||||
responses={404: {"description": "Not found"}},
|
||||
)
|
||||
|
||||
|
||||
@app.post('/auth/id', responses={
|
||||
HTTP_200_OK: {'model': model.IdentityGrant},
|
||||
HTTP_400_BAD_REQUEST: {'model': None, 'description': 'Invalid request parameters.'},
|
||||
HTTP_403_FORBIDDEN: {'model': None, 'description': 'Account login not successful.'},
|
||||
HTTP_500_INTERNAL_SERVER_ERROR: {'model': None, 'description': 'Token generation failed.'}
|
||||
})
|
||||
async def get_identity_grant(username: typing.Annotated[str, fastapi.Form()], password: typing.Annotated[str, fastapi.Form()]):
|
||||
@router.post(
|
||||
"/auth/id",
|
||||
responses={
|
||||
HTTP_200_OK: {"model": model.IdentityGrant},
|
||||
HTTP_400_BAD_REQUEST: {
|
||||
"model": None,
|
||||
"description": "Invalid request parameters.",
|
||||
},
|
||||
HTTP_403_FORBIDDEN: {
|
||||
"model": None,
|
||||
"description": "Account login not successful.",
|
||||
},
|
||||
HTTP_500_INTERNAL_SERVER_ERROR: {
|
||||
"model": None,
|
||||
"description": "Token generation failed.",
|
||||
},
|
||||
},
|
||||
)
|
||||
async def get_identity_grant(
|
||||
username: typing.Annotated[str, fastapi.Form()],
|
||||
password: typing.Annotated[str, fastapi.Form()],
|
||||
):
|
||||
user = logic.validate_user(username, password)
|
||||
if user is None:
|
||||
logger.info('Invalid login attempt (%s).', username)
|
||||
logger.info("Invalid login attempt (%s).", username)
|
||||
raise fastapi.HTTPException(status_code=HTTP_403_FORBIDDEN)
|
||||
try:
|
||||
exp = 12 * 60 * 60
|
||||
token = security.id_token(user, exp=exp)
|
||||
account = model.AuthAccount(i=user.account, l=user.username, o=user.organization)
|
||||
scope = model.AuthScope(t='ID', a=account, d=None, r=[])
|
||||
grant = model.IdentityGrant(token_type='bearer', access_token=token, expires_in=exp, scope=scope)
|
||||
logger.info('Identity token generated (%s).', username)
|
||||
account = model.AuthAccount(
|
||||
i=user.account, l=user.username, o=user.organization
|
||||
)
|
||||
scope = model.AuthScope(t="ID", a=account, d=None, r=[])
|
||||
grant = model.IdentityGrant(
|
||||
token_type="bearer", access_token=token, expires_in=exp, scope=scope
|
||||
)
|
||||
logger.info("Identity token generated (%s).", username)
|
||||
return grant
|
||||
except Exception as e:
|
||||
logger.error('Token generation failed (%s).', username, exc_info=e)
|
||||
logger.error("Token generation failed (%s).", username, exc_info=e)
|
||||
raise fastapi.HTTPException(status_code=HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
|
||||
@app.post('/auth/access', responses={
|
||||
HTTP_200_OK: {'model': model.AccessGrant},
|
||||
HTTP_400_BAD_REQUEST: {'model': None, 'description': 'Invalid request parameters.'},
|
||||
HTTP_403_FORBIDDEN: {'model': None, 'description': 'Access not allowed.'},
|
||||
HTTP_500_INTERNAL_SERVER_ERROR: {'model': None, 'description': 'Token generation failed.'}
|
||||
})
|
||||
async def get_access_grant(secret: typing.Annotated[str, fastapi.Form()], account: typing.Annotated[int, fastapi.Form()], organization: typing.Annotated[int, fastapi.Form()]):
|
||||
@router.post(
|
||||
"/auth/access",
|
||||
responses={
|
||||
HTTP_200_OK: {"model": model.AccessGrant},
|
||||
HTTP_400_BAD_REQUEST: {
|
||||
"model": None,
|
||||
"description": "Invalid request parameters.",
|
||||
},
|
||||
HTTP_403_FORBIDDEN: {"model": None, "description": "Access not allowed."},
|
||||
HTTP_500_INTERNAL_SERVER_ERROR: {
|
||||
"model": None,
|
||||
"description": "Token generation failed.",
|
||||
},
|
||||
},
|
||||
)
|
||||
async def get_access_grant(
|
||||
secret: typing.Annotated[str, fastapi.Form()],
|
||||
account: typing.Annotated[int, fastapi.Form()],
|
||||
organization: typing.Annotated[int, fastapi.Form()],
|
||||
):
|
||||
principal = security.principal(secret)
|
||||
if principal is None:
|
||||
logger.info('Invalid access attempt without principal (%s).', account)
|
||||
logger.info("Invalid access attempt without principal (%s).", account)
|
||||
raise fastapi.HTTPException(status_code=HTTP_400_BAD_REQUEST)
|
||||
user = logic.get_user(principal.account.login)
|
||||
if user is None:
|
||||
logger.info('Invalid access attempt without user (%s).', account)
|
||||
logger.info("Invalid access attempt without user (%s).", account)
|
||||
raise fastapi.HTTPException(status_code=HTTP_403_FORBIDDEN)
|
||||
if user.organization != organization or user.account != account:
|
||||
logger.info('Invalid personation attempt (%s).', account)
|
||||
logger.info("Invalid personation attempt (%s).", account)
|
||||
raise fastapi.HTTPException(status_code=HTTP_403_FORBIDDEN)
|
||||
try:
|
||||
exp = 10 * 60
|
||||
token = security.access_token(user, exp=exp)
|
||||
refresh = security.refresh_token(user, exp=exp)
|
||||
auth_account = model.AuthAccount(i=user.account, l=user.username, o=user.organization)
|
||||
scope = model.AuthScope(t='ACCESS', a=auth_account, d=None, r=['SUPER_ADMIN'] if user.superadmin else ['UNI_ADMIN'])
|
||||
grant = model.AccessGrant(token_type='bearer', access_token=token, expires_in=exp, scope=scope, refresh_token=refresh)
|
||||
logger.info('Access token generated (%s).', user.username)
|
||||
auth_account = model.AuthAccount(
|
||||
i=user.account, l=user.username, o=user.organization
|
||||
)
|
||||
scope = model.AuthScope(
|
||||
t="ACCESS",
|
||||
a=auth_account,
|
||||
d=None,
|
||||
r=["SUPER_ADMIN"] if user.superadmin else ["UNI_ADMIN"],
|
||||
)
|
||||
grant = model.AccessGrant(
|
||||
token_type="bearer",
|
||||
access_token=token,
|
||||
expires_in=exp,
|
||||
scope=scope,
|
||||
refresh_token=refresh,
|
||||
)
|
||||
logger.info("Access token generated (%s).", user.username)
|
||||
return grant
|
||||
except Exception as e:
|
||||
logger.error('Token generation failed (%s).', user.username, exc_info=e)
|
||||
logger.error("Token generation failed (%s).", user.username, exc_info=e)
|
||||
raise fastapi.HTTPException(status_code=HTTP_500_INTERNAL_SERVER_ERROR)
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
from typing import Annotated, Optional
|
||||
|
||||
from fastapi import APIRouter, Body, Path, status
|
||||
|
||||
from inse.collaboration_network.schemas import (
|
||||
CollaborationNetwork,
|
||||
FilterProperties,
|
||||
)
|
||||
from inse.tags import Tags
|
||||
import inse.collaboration_network.service as collaboration_network_service
|
||||
|
||||
|
||||
router = APIRouter(
|
||||
prefix="/api/person/network", tags=[Tags.PERSON_NETWORK]
|
||||
)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/{raw_user_id}",
|
||||
summary="Get a person's collaboration network.",
|
||||
description="Returns a person's collaboration network based on their works and co-authors.",
|
||||
operation_id="getCollaborationNetwork",
|
||||
responses={
|
||||
status.HTTP_200_OK: {
|
||||
"description": "Successful Response",
|
||||
"model": CollaborationNetwork,
|
||||
},
|
||||
status.HTTP_404_NOT_FOUND: {"description": "Person not found"},
|
||||
},
|
||||
)
|
||||
async def get_collaboration_network(
|
||||
raw_user_id: Annotated[str, Path(description="The raw user ID of the person.")],
|
||||
filter_properties: Annotated[
|
||||
Optional[FilterProperties],
|
||||
Body(
|
||||
description="The filter properties for the collaboration network.",
|
||||
),
|
||||
] = None,
|
||||
) -> CollaborationNetwork:
|
||||
return await collaboration_network_service.get_collaboration_network(
|
||||
raw_user_id=raw_user_id,
|
||||
filter_properties=filter_properties,
|
||||
)
|
||||
@@ -0,0 +1,199 @@
|
||||
from enum import Enum
|
||||
from typing import List, Optional
|
||||
|
||||
from pydantic import BaseModel, Field
|
||||
|
||||
from inse.models.work_topic import WorkTopic
|
||||
from inse.utils import extract_raw_topic_id
|
||||
|
||||
|
||||
class InstitutionInformation(BaseModel):
|
||||
raw_id: str = Field(
|
||||
title="Raw Institution ID",
|
||||
description="The raw institution ID of the institution.",
|
||||
)
|
||||
display_name: str = Field(
|
||||
title="Institution Display Name",
|
||||
description="The display name of the institution.",
|
||||
)
|
||||
|
||||
def __eq__(self, value: object) -> bool:
|
||||
if isinstance(value, InstitutionInformation):
|
||||
return self.raw_id == value.raw_id
|
||||
return False
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return hash(self.raw_id)
|
||||
|
||||
|
||||
class WorkTopicInformation(BaseModel):
|
||||
raw_topic_id: str = Field(
|
||||
title="Topic ID",
|
||||
description="The ID of the topic.",
|
||||
)
|
||||
display_name: str = Field(
|
||||
title="Topic Name",
|
||||
description="The name of the topic.",
|
||||
)
|
||||
|
||||
def __eq__(self, value: object) -> bool:
|
||||
if isinstance(value, WorkTopicInformation):
|
||||
return self.raw_topic_id == value.raw_topic_id
|
||||
return False
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return hash(self.raw_topic_id)
|
||||
|
||||
@classmethod
|
||||
def from_topic(cls, topic: WorkTopic) -> "WorkTopicInformation":
|
||||
"""Creates a WorkTopicInformation instance from a WorkTopic instance.
|
||||
|
||||
Args:
|
||||
topic (WorkTopic): The WorkTopic instance to create the WorkTopicInformation from.
|
||||
Returns:
|
||||
WorkTopicInformation: The created WorkTopicInformation instance.
|
||||
"""
|
||||
return cls(
|
||||
raw_topic_id=extract_raw_topic_id(str(topic.id)),
|
||||
display_name=str(topic.display_name),
|
||||
)
|
||||
|
||||
|
||||
class CollaborationNetworkNodeType(str, Enum):
|
||||
AUTHOR = "author"
|
||||
INSTITUTION = "institution"
|
||||
WORK = "work"
|
||||
|
||||
|
||||
class FilterInformation(BaseModel):
|
||||
min_possible_year: int = Field(
|
||||
title="Minimum Year",
|
||||
description="The minimum publication year of the works in the collaboration network.",
|
||||
)
|
||||
max_possible_year: int = Field(
|
||||
title="Maximum Year",
|
||||
description="The maximum publication year of the works in the collaboration network.",
|
||||
)
|
||||
institutions: List[InstitutionInformation] = Field(
|
||||
title="Institutions",
|
||||
description="The list of institutions associated with the works in the collaboration network.",
|
||||
)
|
||||
topics: List[WorkTopicInformation] = Field(
|
||||
title="Topics",
|
||||
description="The list of topics associated with the works in the collaboration network.",
|
||||
)
|
||||
|
||||
|
||||
class FilterProperties(BaseModel):
|
||||
start_year: Optional[int] = Field(
|
||||
title="Start Year",
|
||||
description="The start publication year for the works to include in the collaboration network.",
|
||||
)
|
||||
end_year: Optional[int] = Field(
|
||||
title="End Year",
|
||||
description="The end publication year for the works to include in the collaboration network.",
|
||||
)
|
||||
allowed_institutions: Optional[List[str]] = Field(
|
||||
title="Allowed Institutions",
|
||||
description="The list of raw institution IDs to include in the collaboration network. If not provided, all institutions will be included.",
|
||||
)
|
||||
allowed_topics: Optional[List[str]] = Field(
|
||||
title="Allowed Topics",
|
||||
description="The list of raw topic IDs to include in the collaboration network. If not provided, all topics will be included.",
|
||||
)
|
||||
min_collaborators: Optional[int] = Field(
|
||||
title="Minimum Collaborators",
|
||||
description="The minimum number of collaborators required for a work to be included in the collaboration network. If not provided, all works will be included regardless of the number of collaborators.",
|
||||
)
|
||||
max_collaborators: Optional[int] = Field(
|
||||
title="Maximum Collaborators",
|
||||
description="The maximum number of collaborators allowed for a work to be included in the collaboration network. If not provided, all works will be included regardless of the number of collaborators.",
|
||||
)
|
||||
min_collaborations: Optional[int] = Field(
|
||||
title="Minimum Collaborations",
|
||||
description="The minimum number of collaborations required for a collaboration edge to be included in the collaboration network. If not provided, all collaboration edges will be included regardless of the number of collaborations.",
|
||||
)
|
||||
max_collaborations: Optional[int] = Field(
|
||||
title="Maximum Collaborations",
|
||||
description="The maximum number of collaborations allowed for a collaboration edge to be included in the collaboration network. If not provided, all collaboration edges will be included regardless of the number of collaborations.",
|
||||
)
|
||||
|
||||
|
||||
class CollaborationNetworkNode(BaseModel):
|
||||
raw_id: str = Field(
|
||||
title="Raw ID",
|
||||
description="The raw ID of the node. For an author node, this is the raw person ID. For an institution node, this is the raw institution ID. For a work node, this is the raw work ID.",
|
||||
)
|
||||
display_name: str = Field(
|
||||
title="Display Name", description="The display name of the node."
|
||||
)
|
||||
category: CollaborationNetworkNodeType = Field(
|
||||
title="Category",
|
||||
description="The category of the node, either 'author', 'institution', or 'work'.",
|
||||
)
|
||||
|
||||
def __eq__(self, value: object) -> bool:
|
||||
if isinstance(value, CollaborationNetworkNode):
|
||||
return self.raw_id == value.raw_id
|
||||
return False
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return hash(self.raw_id)
|
||||
|
||||
|
||||
class CollaborationNetworkEdge(BaseModel):
|
||||
raw_source_id: str = Field(
|
||||
title="Source Raw ID",
|
||||
description="The raw ID of the source node.",
|
||||
)
|
||||
raw_target_id: str = Field(
|
||||
title="Target Raw ID",
|
||||
description="The raw ID of the target node.",
|
||||
)
|
||||
|
||||
def __eq__(self, value: object) -> bool:
|
||||
if isinstance(value, CollaborationNetworkEdge):
|
||||
return self.same_collaboration(self, value)
|
||||
return False
|
||||
|
||||
def __hash__(self) -> int:
|
||||
return hash((self.raw_source_id, self.raw_target_id))
|
||||
|
||||
@classmethod
|
||||
def same_collaboration(
|
||||
cls, edge1: "CollaborationNetworkEdge", edge2: "CollaborationNetworkEdge"
|
||||
) -> bool:
|
||||
"""Checks if two edges have the same source and target person IDs, regardless of order.
|
||||
|
||||
Args:
|
||||
edge1 (CollaborationNetworkEdge): The first collaboration edge.
|
||||
edge2 (CollaborationNetworkEdge): The second collaboration edge.
|
||||
Returns:
|
||||
bool: True if the edges have the same source and target person IDs (undirected), False otherwise.
|
||||
"""
|
||||
return (
|
||||
edge1.raw_source_id == edge2.raw_source_id
|
||||
and edge1.raw_target_id == edge2.raw_target_id
|
||||
) or (
|
||||
edge1.raw_source_id == edge2.raw_target_id
|
||||
and edge1.raw_target_id == edge2.raw_source_id
|
||||
)
|
||||
|
||||
|
||||
class CollaborationNetwork(BaseModel):
|
||||
raw_person_id: str = Field(
|
||||
title="Raw Person ID",
|
||||
description="The raw person ID of the person whose collaboration network this is.",
|
||||
)
|
||||
nodes: List[CollaborationNetworkNode] = Field(
|
||||
title="Collaboration Network Nodes",
|
||||
description="The nodes in the collaboration network.",
|
||||
)
|
||||
edges: List[CollaborationNetworkEdge] = Field(
|
||||
title="Collaboration Network Edges",
|
||||
description="The edges in the collaboration network.",
|
||||
)
|
||||
filter_information: FilterInformation = Field(
|
||||
title="Filter Information",
|
||||
description="The filter information for the collaboration network, including the minimum and maximum publication years of the works in the collaboration network.",
|
||||
)
|
||||
@@ -0,0 +1,550 @@
|
||||
from collections import defaultdict
|
||||
import logging
|
||||
from typing import List, Optional, Set, Tuple
|
||||
|
||||
from inse.collaboration_network.schemas import (
|
||||
CollaborationNetwork,
|
||||
CollaborationNetworkEdge,
|
||||
CollaborationNetworkNode,
|
||||
CollaborationNetworkNodeType,
|
||||
FilterInformation,
|
||||
FilterProperties,
|
||||
InstitutionInformation,
|
||||
WorkTopicInformation,
|
||||
)
|
||||
|
||||
from inse.works import logic as work_logic
|
||||
from inse.works.model import Work
|
||||
|
||||
from inse.utils import (
|
||||
extract_raw_author_id,
|
||||
extract_raw_institution_id,
|
||||
extract_raw_topic_id,
|
||||
extract_raw_work_id,
|
||||
)
|
||||
from inse.models.author import Author
|
||||
from inse.models.authorship import Authorship
|
||||
from inse.models.dehydrated_author import DehydratedAuthor
|
||||
from inse.models.dehydrated_institution import DehydratedInstitution
|
||||
from inse.models.institution import Institution
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
async def get_collaboration_network(
|
||||
raw_user_id: str,
|
||||
filter_properties: Optional[FilterProperties] = None,
|
||||
) -> CollaborationNetwork:
|
||||
"""Gets the collaboration network for a given user ID.
|
||||
|
||||
Args:
|
||||
raw_user_id (str): The raw user ID for whom to get the collaboration network.
|
||||
filter_properties (Optional[FilterProperties]): The filter properties for the collaboration network.
|
||||
|
||||
Returns:
|
||||
CollaborationNetwork: The collaboration network for the given user.
|
||||
"""
|
||||
|
||||
raw_user_id = raw_user_id.strip().upper()
|
||||
|
||||
work_page = await work_logic.get_all_author_works(author_id=raw_user_id)
|
||||
|
||||
works: List[Work] = work_page.results or []
|
||||
return build_collaboration_network(
|
||||
raw_user_id=raw_user_id, works=works, filter_properties=filter_properties
|
||||
)
|
||||
|
||||
|
||||
def get_work_year(work: Work) -> int:
|
||||
"""Extracts the publication year from a given work.
|
||||
|
||||
Args:
|
||||
work (Work): The work from which to extract the publication year.
|
||||
|
||||
Returns:
|
||||
int: The publication year of the work, or -1 if it cannot be extracted.
|
||||
"""
|
||||
if not work.publication_year:
|
||||
return -1
|
||||
try:
|
||||
return int(work.publication_year)
|
||||
except ValueError:
|
||||
return -1
|
||||
|
||||
|
||||
def filter_works(
|
||||
min_year: Optional[int],
|
||||
max_year: Optional[int],
|
||||
works: List[Work],
|
||||
) -> List[Work]:
|
||||
"""Filters a list of works based on a given year range.
|
||||
|
||||
Args:
|
||||
min_year (Optional[int]): The minimum publication year for the works to include.
|
||||
max_year (Optional[int]): The maximum publication year for the works to include.
|
||||
works (List[Work]): The list of works to filter.
|
||||
|
||||
Returns:
|
||||
List[Work]: A list of works that fall within the specified year range.
|
||||
"""
|
||||
filtered_works = []
|
||||
for work in works:
|
||||
work_year = get_work_year(work)
|
||||
if min_year is not None and work_year < min_year:
|
||||
continue
|
||||
if max_year is not None and work_year > max_year:
|
||||
continue
|
||||
filtered_works.append(work)
|
||||
return filtered_works
|
||||
|
||||
|
||||
def get_year_range(works: List[Work]) -> Tuple[int, int]:
|
||||
"""Determines the minimum and maximum publication years from a list of works.
|
||||
|
||||
Args:
|
||||
works (List[Work]): The list of works from which to determine the year range.
|
||||
|
||||
Returns:
|
||||
Tuple[int, int]: A tuple containing the minimum and maximum publication years, respectively.
|
||||
"""
|
||||
min_year = float("inf")
|
||||
max_year = float("-inf")
|
||||
|
||||
for work in works:
|
||||
work_year = get_work_year(work)
|
||||
if work_year != -1: # Only consider valid years
|
||||
min_year = min(min_year, work_year)
|
||||
max_year = max(max_year, work_year)
|
||||
|
||||
return int(min_year), int(max_year)
|
||||
|
||||
|
||||
def build_collaboration_network(
|
||||
raw_user_id: str,
|
||||
works: List[Work],
|
||||
filter_properties: Optional[FilterProperties] = None,
|
||||
) -> CollaborationNetwork:
|
||||
"""Builds a collaboration network for a given user based on their works.
|
||||
|
||||
Args:
|
||||
raw_user_id (str): The raw user ID for whom the collaboration network is being built.
|
||||
works (List[Work]): A list of works for which to build the collaboration network.
|
||||
filter_properties (Optional[FilterProperties]): The filter properties for the collaboration network.
|
||||
|
||||
Returns:
|
||||
CollaborationNetwork: The built collaboration network.
|
||||
"""
|
||||
collaboration_nodes: Set[CollaborationNetworkNode] = set()
|
||||
collaboration_edges: Set[CollaborationNetworkEdge] = set()
|
||||
|
||||
min_possible_year, max_possible_year = get_year_range(works)
|
||||
|
||||
min_year = (
|
||||
filter_properties.start_year
|
||||
if filter_properties
|
||||
and filter_properties.start_year is not None
|
||||
and filter_properties.start_year >= min_possible_year
|
||||
else min_possible_year
|
||||
)
|
||||
max_year = (
|
||||
filter_properties.end_year
|
||||
if filter_properties
|
||||
and filter_properties.end_year is not None
|
||||
and filter_properties.end_year <= max_possible_year
|
||||
else max_possible_year
|
||||
)
|
||||
|
||||
filtered_works = filter_works(
|
||||
min_year=min_year,
|
||||
max_year=max_year,
|
||||
works=works,
|
||||
)
|
||||
|
||||
for work in filtered_works:
|
||||
nodes, edges = process_work(work=work, filter_properties=filter_properties)
|
||||
|
||||
work_year = get_work_year(work)
|
||||
min_possible_year = min(min_possible_year, work_year)
|
||||
max_possible_year = max(max_possible_year, work_year)
|
||||
|
||||
collaboration_nodes.update(nodes)
|
||||
collaboration_edges.update(edges)
|
||||
|
||||
filter_information = FilterInformation(
|
||||
min_possible_year=int(min_possible_year),
|
||||
max_possible_year=int(max_possible_year),
|
||||
institutions=sorted(
|
||||
extract_institutions(works=works), key=lambda inst: inst.display_name
|
||||
),
|
||||
topics=sorted(
|
||||
extract_topics(works=works), key=lambda topic: topic.display_name
|
||||
),
|
||||
)
|
||||
|
||||
collaboration_nodes, collaboration_edges = reduce_collaboration_network(
|
||||
collaboration_nodes=collaboration_nodes,
|
||||
collaboration_edges=collaboration_edges,
|
||||
filter_properties=filter_properties,
|
||||
)
|
||||
|
||||
return CollaborationNetwork(
|
||||
raw_person_id=raw_user_id,
|
||||
nodes=list(collaboration_nodes),
|
||||
edges=list(collaboration_edges),
|
||||
filter_information=filter_information,
|
||||
)
|
||||
|
||||
|
||||
def reduce_collaboration_network(
|
||||
collaboration_nodes: Set[CollaborationNetworkNode],
|
||||
collaboration_edges: Set[CollaborationNetworkEdge],
|
||||
filter_properties: Optional[FilterProperties],
|
||||
) -> Tuple[Set[CollaborationNetworkNode], Set[CollaborationNetworkEdge]]:
|
||||
if not filter_properties or (
|
||||
filter_properties.min_collaborations is None
|
||||
and filter_properties.max_collaborations is None
|
||||
):
|
||||
return collaboration_nodes, collaboration_edges
|
||||
|
||||
collaboration_counts = defaultdict(int)
|
||||
for collaboration_edge in collaboration_edges:
|
||||
# only count works as collaborations, not institution affiliations
|
||||
if collaboration_edge.raw_target_id.lower().startswith("w"):
|
||||
collaboration_counts[collaboration_edge.raw_source_id] += 1
|
||||
|
||||
min_collaborations = filter_properties.min_collaborations or 0
|
||||
max_collaborations = filter_properties.max_collaborations or float("inf")
|
||||
valid_node_ids = {
|
||||
node_id
|
||||
for node_id, count in collaboration_counts.items()
|
||||
if min_collaborations <= count <= max_collaborations
|
||||
}
|
||||
|
||||
collaboration_nodes = {
|
||||
node
|
||||
for node in collaboration_nodes
|
||||
if node.raw_id.startswith("W")
|
||||
or node.raw_id.startswith("I")
|
||||
or node.raw_id in valid_node_ids
|
||||
}
|
||||
|
||||
return collaboration_nodes, {edge for edge in collaboration_edges if edge.raw_source_id in valid_node_ids}
|
||||
|
||||
|
||||
def extract_institutions(works: List[Work]) -> Set[InstitutionInformation]:
|
||||
"""Extracts a set of unique institutions from a list of works.
|
||||
|
||||
Args:
|
||||
works (List[Work]): The list of works from which to extract institutions.
|
||||
|
||||
Returns:
|
||||
Set[InstitutionInformation]: A set of unique institution information associated with the works.
|
||||
"""
|
||||
institutions: Set[InstitutionInformation] = set()
|
||||
for work in works:
|
||||
if work.authorships:
|
||||
for authorship in work.authorships:
|
||||
if authorship.institutions:
|
||||
for institution in authorship.institutions:
|
||||
if not institution.id or not institution.display_name:
|
||||
continue
|
||||
institution_id = extract_raw_institution_id(institution.id)
|
||||
institution_info = InstitutionInformation(
|
||||
raw_id=institution_id,
|
||||
display_name=str(institution.display_name),
|
||||
)
|
||||
institutions.add(institution_info)
|
||||
return institutions
|
||||
|
||||
|
||||
def extract_topics(works: List[Work]) -> Set[WorkTopicInformation]:
|
||||
"""Extracts a set of unique topics from a list of works.
|
||||
|
||||
Args:
|
||||
works (List[Work]): The list of works from which to extract topics.
|
||||
|
||||
Returns:
|
||||
Set[WorkTopicInformation]: A set of unique topic information associated with the works.
|
||||
"""
|
||||
topics: Set[WorkTopicInformation] = set()
|
||||
for work in works:
|
||||
if work.topics:
|
||||
for topic in work.topics:
|
||||
if not topic.id or not topic.display_name:
|
||||
continue
|
||||
topic_info = WorkTopicInformation.from_topic(topic)
|
||||
topics.add(topic_info)
|
||||
return topics
|
||||
|
||||
|
||||
def process_authorship(
|
||||
authorship: Authorship,
|
||||
) -> Tuple[
|
||||
Optional[CollaborationNetworkNode],
|
||||
Set[CollaborationNetworkNode],
|
||||
Set[CollaborationNetworkEdge],
|
||||
]:
|
||||
"""Processes an authorship to extract the corresponding collaboration network node and associated institutions.
|
||||
|
||||
Args:
|
||||
authorship (Authorship): The authorship to process.
|
||||
Returns:
|
||||
Tuple[CollaborationNetworkNode, List[CollaborationNetworkNode]]: A tuple containing the collaboration network node and a list of associated institution nodes.
|
||||
"""
|
||||
author = authorship.author
|
||||
if not author or not author.id or not author.display_name:
|
||||
return None, set(), set()
|
||||
|
||||
author_node = get_author_node(author)
|
||||
if not author_node:
|
||||
return None, set(), set()
|
||||
|
||||
institution_nodes = get_institution_nodes(authorship.institutions or [])
|
||||
|
||||
associated_institution_edges = {
|
||||
CollaborationNetworkEdge(
|
||||
raw_source_id=author_node.raw_id,
|
||||
raw_target_id=institution_node.raw_id,
|
||||
)
|
||||
for institution_node in institution_nodes
|
||||
}
|
||||
|
||||
return author_node, institution_nodes, associated_institution_edges
|
||||
|
||||
|
||||
def get_institution_nodes(
|
||||
institutions: List[Institution] | List[DehydratedInstitution],
|
||||
) -> Set[CollaborationNetworkNode]:
|
||||
"""Processes a list of institutions to extract the corresponding collaboration network nodes.
|
||||
|
||||
Args:
|
||||
institutions (List[Institution]): The list of institutions to process.
|
||||
|
||||
Returns:
|
||||
Set[CollaborationNetworkNode]: A set of collaboration network nodes corresponding to the institutions.
|
||||
"""
|
||||
institution_nodes: Set[CollaborationNetworkNode] = set()
|
||||
for institution in institutions:
|
||||
institution_node = get_institution_node(institution)
|
||||
if institution_node:
|
||||
institution_nodes.add(institution_node)
|
||||
return institution_nodes
|
||||
|
||||
|
||||
def get_institution_node(
|
||||
institution: Institution | DehydratedInstitution,
|
||||
) -> Optional[CollaborationNetworkNode]:
|
||||
"""Processes an institution to extract the corresponding collaboration network node.
|
||||
|
||||
Args:
|
||||
institution (Institution): The institution to process.
|
||||
|
||||
Returns:
|
||||
CollaborationNetworkNode: The collaboration network node corresponding to the institution, or None if the institution is invalid.
|
||||
"""
|
||||
if not institution or not institution.id or not institution.display_name:
|
||||
return None
|
||||
|
||||
institution_id = extract_raw_institution_id(institution.id)
|
||||
display_name = institution.display_name
|
||||
|
||||
return CollaborationNetworkNode(
|
||||
raw_id=institution_id,
|
||||
display_name=display_name,
|
||||
category=CollaborationNetworkNodeType.INSTITUTION,
|
||||
)
|
||||
|
||||
|
||||
def get_work_node(
|
||||
work: Work, filter_properties: Optional[FilterProperties]
|
||||
) -> Optional[CollaborationNetworkNode]:
|
||||
"""Processes a work to extract the corresponding collaboration network node.
|
||||
|
||||
Args:
|
||||
work (Work): The work to process.
|
||||
filter_properties (Optional[FilterProperties]): The filter properties containing the list of allowed topics. Defaults to None.
|
||||
|
||||
Returns:
|
||||
Optional[CollaborationNetworkNode]: The collaboration network node corresponding to the work, or None if the work is invalid.
|
||||
"""
|
||||
if not work or not work.id or not work.display_name:
|
||||
return None
|
||||
|
||||
if not has_allowed_topic(work=work, filter_properties=filter_properties):
|
||||
return None
|
||||
|
||||
work_id = extract_raw_work_id(work.id)
|
||||
display_name = work.display_name
|
||||
|
||||
return CollaborationNetworkNode(
|
||||
raw_id=work_id,
|
||||
display_name=display_name,
|
||||
category=CollaborationNetworkNodeType.WORK,
|
||||
)
|
||||
|
||||
|
||||
def get_author_node(
|
||||
author: Author | DehydratedAuthor,
|
||||
) -> Optional[CollaborationNetworkNode]:
|
||||
"""Processes an author to extract the corresponding collaboration network node.
|
||||
|
||||
Args:
|
||||
author (Author): The author to process.
|
||||
|
||||
Returns:
|
||||
CollaborationNetworkNode: The collaboration network node corresponding to the author, or None if the author is invalid.
|
||||
"""
|
||||
if not author or not author.id or not author.display_name:
|
||||
return None
|
||||
|
||||
author_id = extract_raw_author_id(author.id)
|
||||
display_name = author.display_name
|
||||
|
||||
return CollaborationNetworkNode(
|
||||
raw_id=author_id,
|
||||
display_name=display_name,
|
||||
category=CollaborationNetworkNodeType.AUTHOR,
|
||||
)
|
||||
|
||||
|
||||
def process_work(
|
||||
work: Work,
|
||||
filter_properties: Optional[FilterProperties] = None,
|
||||
) -> Tuple[Set[CollaborationNetworkNode], Set[CollaborationNetworkEdge]]:
|
||||
"""Processes a work to extract the corresponding collaboration network nodes and edges.
|
||||
|
||||
Args:
|
||||
work (Work): The work to process.
|
||||
|
||||
Returns:
|
||||
Tuple[Set[CollaborationNetworkNode], Set[CollaborationNetworkEdge]]: A tuple containing a set of collaboration network nodes and edges.
|
||||
"""
|
||||
work_node = get_work_node(work=work, filter_properties=filter_properties)
|
||||
if not work_node:
|
||||
return set(), set()
|
||||
|
||||
authorships = work.authorships
|
||||
if not authorships:
|
||||
return set(), set()
|
||||
|
||||
collaboration_nodes: Set[CollaborationNetworkNode] = {work_node}
|
||||
collaboration_edges: Set[CollaborationNetworkEdge] = set()
|
||||
|
||||
for authorship in authorships:
|
||||
author_node, institution_nodes, associated_institution_edges = (
|
||||
process_authorship(authorship)
|
||||
)
|
||||
if not author_node:
|
||||
continue
|
||||
|
||||
if not is_member_of_allowed_institution(
|
||||
institution_nodes=institution_nodes, filter_properties=filter_properties
|
||||
):
|
||||
continue
|
||||
|
||||
work_author_edge = CollaborationNetworkEdge(
|
||||
raw_source_id=author_node.raw_id,
|
||||
raw_target_id=work_node.raw_id,
|
||||
)
|
||||
|
||||
collaboration_nodes.add(author_node)
|
||||
collaboration_edges.add(work_author_edge)
|
||||
collaboration_nodes.update(institution_nodes)
|
||||
collaboration_edges.update(associated_institution_edges)
|
||||
|
||||
author_nodes = {
|
||||
node
|
||||
for node in collaboration_nodes
|
||||
if node.category == CollaborationNetworkNodeType.AUTHOR
|
||||
}
|
||||
|
||||
if not has_enough_contributors(
|
||||
contributors=author_nodes, filter_properties=filter_properties
|
||||
):
|
||||
return set(), set()
|
||||
|
||||
return collaboration_nodes, collaboration_edges
|
||||
|
||||
|
||||
def has_enough_contributors(
|
||||
contributors: Set[CollaborationNetworkNode],
|
||||
filter_properties: Optional[FilterProperties],
|
||||
) -> bool:
|
||||
"""Determines whether a work has enough contributors to be included in the collaboration network based on the provided filter properties.
|
||||
|
||||
Args:
|
||||
contributors (Set[CollaborationNetworkNode]): The set of contributor nodes.
|
||||
filter_properties (Optional[FilterProperties]): The filter properties containing the minimum and maximum collaborator thresholds.
|
||||
|
||||
Returns:
|
||||
bool: True if the work has enough contributors to be included in the collaboration network, False otherwise.
|
||||
"""
|
||||
if not filter_properties:
|
||||
return True
|
||||
|
||||
num_contributors = len(contributors)
|
||||
|
||||
if (
|
||||
filter_properties.min_collaborators
|
||||
and num_contributors < filter_properties.min_collaborators
|
||||
):
|
||||
return False
|
||||
|
||||
if (
|
||||
filter_properties.max_collaborators
|
||||
and num_contributors > filter_properties.max_collaborators
|
||||
):
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
|
||||
def has_allowed_topic(
|
||||
work: Work, filter_properties: Optional[FilterProperties]
|
||||
) -> bool:
|
||||
"""Determines whether a work is associated with at least one topic that is in the list of allowed topics specified in the filter properties.
|
||||
|
||||
Args:
|
||||
work (Work): The work for which to check the topics.
|
||||
filter_properties (Optional[FilterProperties]): The filter properties containing the list of allowed topics. Defaults to None.
|
||||
|
||||
Returns:
|
||||
bool: True if at least one of the work's topics is in the list of allowed topics, False otherwise.
|
||||
"""
|
||||
if not filter_properties or not filter_properties.allowed_topics:
|
||||
return True
|
||||
|
||||
if not work.topics:
|
||||
return False
|
||||
|
||||
for topic in work.topics:
|
||||
if not topic.id:
|
||||
continue
|
||||
topic_id = extract_raw_topic_id(topic.id)
|
||||
if topic_id in filter_properties.allowed_topics:
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def is_member_of_allowed_institution(
|
||||
institution_nodes: Set[CollaborationNetworkNode],
|
||||
filter_properties: Optional[FilterProperties] = None,
|
||||
) -> bool:
|
||||
"""Determines whether an author is affiliated with at least one institution that is in the list of allowed institutions specified in the filter properties.
|
||||
|
||||
Args:
|
||||
institution_nodes (Set[CollaborationNetworkNode]): The set of institution nodes associated with a work.
|
||||
filter_properties (Optional[FilterProperties], optional): The filter properties containing the list of allowed institutions. Defaults to None.
|
||||
|
||||
Returns:
|
||||
bool: True if at least one of the institution nodes is in the list of allowed institutions, False otherwise.
|
||||
"""
|
||||
|
||||
if not filter_properties or not filter_properties.allowed_institutions:
|
||||
return True
|
||||
|
||||
for institution_node in institution_nodes:
|
||||
if institution_node.raw_id in filter_properties.allowed_institutions:
|
||||
return True
|
||||
return False
|
||||
@@ -1,34 +1,65 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
This module contains the configuration properties
|
||||
that can be adjusted via environment variables.
|
||||
This module contains the configuration properties
|
||||
that can be adjusted via environment variables.
|
||||
"""
|
||||
|
||||
from functools import lru_cache
|
||||
import logging
|
||||
from typing import Dict, List, Optional
|
||||
from pydantic_settings import BaseSettings, SettingsConfigDict
|
||||
from dotenv import load_dotenv
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
load_dotenv()
|
||||
|
||||
|
||||
class Settings(BaseSettings):
|
||||
model_config = SettingsConfigDict(env_prefix='inse_')
|
||||
# database config
|
||||
database_url: str = 'sqlite:///../data/inse-sqlite.db'
|
||||
database_url: str = "sqlite:///../data/inse-sqlite.db"
|
||||
database_debug: bool = False
|
||||
database_init: bool = True
|
||||
# authorization config
|
||||
# authorization config
|
||||
auth_disabled: bool = False
|
||||
auth_standalone: bool = True
|
||||
auth_secret: str = 'change-me-to-a-secure-secret-key'
|
||||
auth_secret: str = "change-me-to-a-secure-secret-key"
|
||||
# OpenAlex works search config
|
||||
openalex_works_search_base_url: str = 'https://project.nes.uni-due.de/elastic'
|
||||
openalex_works_search_index: str = 'openalex-works'
|
||||
openalex_works_api_key: str = 'am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ=='
|
||||
openalex_works_search_base_url: str = "https://project.nes.uni-due.de/elastic"
|
||||
# IMPORTANT: wildcard * needed to query all work indices
|
||||
openalex_works_search_index: str = "openalex-works*"
|
||||
openalex_works_api_key: str = (
|
||||
"am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ=="
|
||||
)
|
||||
openalex_works_search_timeout_seconds: float = 30.0
|
||||
llm_api_url: str = 'https://project.nes.uni-due.de/llm2/api/generate'
|
||||
llm_api_token: str = 'c2d5e7ccf7a4760dd3d19bed2caed9d85ff7437400e0ea82a6d6f912ebc2f212'
|
||||
llm_model: str = 'gemma4:e4b'
|
||||
elasticsearch_url: str = 'https://project.nes.uni-due.de/elastic/'
|
||||
elasticsearch_api_key: str = 'am1wWXBaMEJEVWJoZkE5MnBaUlk6TWlvbW1LRlMzNjdDUHgzYmVkUmI5UQ=='
|
||||
|
||||
# LLM config
|
||||
llm_api_url: Optional[str] = None
|
||||
llm_api_key: Optional[str] = None
|
||||
llm_model: Optional[str] = None
|
||||
|
||||
# elasticsearch config
|
||||
elasticsearch_url: Optional[str] = None
|
||||
elasticsearch_api_key: Optional[str] = None
|
||||
|
||||
model_config = SettingsConfigDict(env_file=".env")
|
||||
|
||||
allowed_origins: List[str] = ["http://localhost:4200"]
|
||||
|
||||
servers: List[Dict[str, str]] = [
|
||||
{"url": "http://localhost:8000", "description": "Local development server"},
|
||||
]
|
||||
|
||||
|
||||
settings = Settings()
|
||||
|
||||
|
||||
@lru_cache
|
||||
def get_settings() -> Settings:
|
||||
return settings
|
||||
|
||||
|
||||
logger.info(f"Database URL: {settings.database_url}.")
|
||||
logger.info(f"Serves at: {settings.servers}.")
|
||||
|
||||
+297
-125
@@ -1,38 +1,76 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
This module defines the business logic for our
|
||||
web service.
|
||||
This module defines the business logic for our
|
||||
web service.
|
||||
"""
|
||||
|
||||
from typing import List
|
||||
from typing import TypeVar
|
||||
from typing import Optional
|
||||
from typing import Type
|
||||
from sqlalchemy.orm import Session
|
||||
from sqlalchemy import select
|
||||
from sqlalchemy import delete
|
||||
from sqlalchemy import insert
|
||||
from sqlalchemy import update
|
||||
from sqlalchemy import func
|
||||
from fastapi import HTTPException
|
||||
import logging
|
||||
import httpx
|
||||
import json
|
||||
import time
|
||||
from . import schema
|
||||
from . import model
|
||||
from . import config
|
||||
from .integrations import elasticsearch
|
||||
from .integrations import llm
|
||||
from . import util
|
||||
from elasticsearch import Elasticsearch, helpers, NotFoundError, ApiError
|
||||
|
||||
|
||||
from inse.models.author import Author
|
||||
from inse.models.authors_list_response import AuthorsListResponse
|
||||
from inse.models.meta import Meta
|
||||
from inse.models.topic import Topic
|
||||
from inse.models.topic_subfield import TopicSubfield
|
||||
from inse.models.topic_field import TopicField
|
||||
from inse.models.topic_domain import TopicDomain
|
||||
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
|
||||
def _init_es_client() -> Optional[Elasticsearch]:
|
||||
es_url = config.settings.elasticsearch_url
|
||||
if not es_url:
|
||||
logger.warning("Elasticsearch URL not configured; skipping client init.")
|
||||
return None
|
||||
client = Elasticsearch(
|
||||
hosts=[str(es_url)],
|
||||
api_key=config.settings.elasticsearch_api_key,
|
||||
)
|
||||
logger.info("Elasticsearch client initialized with URL: %s", es_url)
|
||||
return client
|
||||
|
||||
|
||||
es_client = _init_es_client()
|
||||
|
||||
topic_cache_filename: str = "topic_hierarchy_cache.json"
|
||||
|
||||
S = TypeVar('S', bound=schema.Base)
|
||||
M = TypeVar('M', bound=model.BaseModel)
|
||||
S = TypeVar("S", bound=schema.Base)
|
||||
M = TypeVar("M", bound=model.BaseModel)
|
||||
|
||||
|
||||
def filter_none():
|
||||
return True
|
||||
|
||||
def get_page(db: Session, schema_type: Type[S], model_type: Type[M], offset: int, limit: int, filter=filter_none) -> model.Page[M]:
|
||||
|
||||
def get_page(
|
||||
db: Session,
|
||||
schema_type: Type[S],
|
||||
model_type: Type[M],
|
||||
offset: int,
|
||||
limit: int,
|
||||
filter=filter_none,
|
||||
) -> model.Page[M]:
|
||||
result = model.Page[model_type]()
|
||||
result.offset = offset
|
||||
result.total = get_count(db, schema_type, filter)
|
||||
@@ -43,27 +81,39 @@ def get_page(db: Session, schema_type: Type[S], model_type: Type[M], offset: int
|
||||
result.elements = []
|
||||
return result
|
||||
|
||||
|
||||
def get_count(db: Session, schema_type: Type[S], filter=filter_none) -> int:
|
||||
return db.scalar(select(func.count()).select_from(schema_type).where(filter))
|
||||
|
||||
def get_elements(db: Session, schema_type: Type[S], offset: int, limit: int, filter=filter_none) -> List[S]:
|
||||
return db.scalars(select(schema_type).where(filter).offset(offset).limit(limit)).all()
|
||||
|
||||
def get_elements(
|
||||
db: Session, schema_type: Type[S], offset: int, limit: int, filter=filter_none
|
||||
) -> List[S]:
|
||||
return db.scalars(
|
||||
select(schema_type).where(filter).offset(offset).limit(limit)
|
||||
).all()
|
||||
|
||||
|
||||
def get_element(db: Session, schema_type: Type[S], element_id: int) -> Optional[S]:
|
||||
return db.scalars(select(schema_type).where(schema_type.id == element_id).limit(1)).first()
|
||||
return db.scalars(
|
||||
select(schema_type).where(schema_type.id == element_id).limit(1)
|
||||
).first()
|
||||
|
||||
|
||||
def delete_element(db: Session, schema_type: Type[S], element_id: int):
|
||||
element = get_element(db, schema_type, element_id)
|
||||
db.delete(element)
|
||||
|
||||
|
||||
def insert_element(db: Session, value: S) -> S:
|
||||
db.add(value)
|
||||
db.flush()
|
||||
db.refresh(value)
|
||||
return value
|
||||
|
||||
|
||||
def _load_topic_cache() -> dict:
|
||||
"""Loads the topic hierarchy cache from a JSON file. """
|
||||
"""Loads the topic hierarchy cache from a JSON file."""
|
||||
try:
|
||||
cache_path = "/data/" + topic_cache_filename
|
||||
with open(cache_path, "r", encoding="utf-8") as f:
|
||||
@@ -72,22 +122,22 @@ def _load_topic_cache() -> dict:
|
||||
logger.warning("Failed to load topic hierarchy cache: %s", exc)
|
||||
return {}
|
||||
|
||||
def build_topic_cache(page_size: int = 200,
|
||||
save_json: bool = True) -> dict:
|
||||
|
||||
def build_topic_cache(page_size: int = 200, save_json: bool = True) -> dict:
|
||||
"""
|
||||
Fetch topics from the hosted OpenAlex topics index and build a lookup cache (scheduled task).
|
||||
|
||||
Arguments:
|
||||
page_size (int): Number of topics to fetch per request (default: 200)
|
||||
save_json (bool): Whether to save the cache as a JSON file (default: True)
|
||||
|
||||
|
||||
Returns:
|
||||
taxonomy_cache (dict): The topic hierarchy dictionary.
|
||||
"""
|
||||
output_filename: str = "topic_hierarchy_cache.json"
|
||||
headers = {
|
||||
"Authorization": f"ApiKey {config.settings.elasticsearch_api_key}",
|
||||
"Content-Type": "application/json"
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
|
||||
taxonomy_cache = {}
|
||||
@@ -95,12 +145,12 @@ def build_topic_cache(page_size: int = 200,
|
||||
|
||||
with httpx.Client(timeout=30.0) as client:
|
||||
while True:
|
||||
payload = {
|
||||
"query": {"match_all": {}},
|
||||
"from": offset,
|
||||
"size": page_size
|
||||
}
|
||||
response = client.post(config.settings.elasticsearch_url + '/openalex-topics/_search', json=payload, headers=headers)
|
||||
payload = {"query": {"match_all": {}}, "from": offset, "size": page_size}
|
||||
response = client.post(
|
||||
config.settings.elasticsearch_url + "/openalex-topics/_search",
|
||||
json=payload,
|
||||
headers=headers,
|
||||
)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
|
||||
@@ -118,7 +168,7 @@ def build_topic_cache(page_size: int = 200,
|
||||
"topic_id": source.get("id") or hit.get("_id", ""),
|
||||
"subfield": source.get("subfield", {}).get("display_name", ""),
|
||||
"field": source.get("field", {}).get("display_name", ""),
|
||||
"domain": source.get("domain", {}).get("display_name", "")
|
||||
"domain": source.get("domain", {}).get("display_name", ""),
|
||||
}
|
||||
|
||||
offset += len(hits)
|
||||
@@ -136,13 +186,14 @@ def build_topic_cache(page_size: int = 200,
|
||||
|
||||
return taxonomy_cache
|
||||
|
||||
def get_topics_from_cache(topic_names: List[str]) -> List[model.Topic]:
|
||||
|
||||
def get_topics_from_cache(topic_names: List[str]) -> List[Topic]:
|
||||
"""
|
||||
Given a list of topic names, retrieves their hierarchy information from the cache and returns a list of Topic models.
|
||||
Arguments:
|
||||
topic_names (List[str]): A list of topic names to retrieve.
|
||||
Returns:
|
||||
List[model.Topic]: A list of Topic models.
|
||||
List[Topic]: A list of Topic models.
|
||||
"""
|
||||
cache = _load_topic_cache()
|
||||
topics = []
|
||||
@@ -150,15 +201,24 @@ def get_topics_from_cache(topic_names: List[str]) -> List[model.Topic]:
|
||||
data = cache.get(name)
|
||||
if not data:
|
||||
continue
|
||||
topics.append(model.Topic(
|
||||
id=data.get("topic_id", ""),
|
||||
name=name,
|
||||
subfield=data.get("subfield", ""),
|
||||
field=data.get("field", ""),
|
||||
domain=data.get("domain", "")
|
||||
))
|
||||
subfield_name = data.get("subfield", "")
|
||||
field_name = data.get("field", "")
|
||||
domain_name = data.get("domain", "")
|
||||
topics.append(
|
||||
Topic(
|
||||
id=data.get("topic_id", ""),
|
||||
display_name=name,
|
||||
works_count=data.get("count", 1),
|
||||
subfield=TopicSubfield(display_name=subfield_name)
|
||||
if subfield_name
|
||||
else None,
|
||||
field=TopicField(display_name=field_name) if field_name else None,
|
||||
domain=TopicDomain(display_name=domain_name) if domain_name else None,
|
||||
)
|
||||
)
|
||||
return topics
|
||||
|
||||
|
||||
def count_topic_hierarchy(topic_names: List[str]) -> dict:
|
||||
"""
|
||||
Given a list of topic names, counts the occurrences of each topic and their hierarchy levels (subfield, field, domain) using the cache.
|
||||
@@ -168,12 +228,7 @@ def count_topic_hierarchy(topic_names: List[str]) -> dict:
|
||||
dict: A dictionary containing the counts of each hierarchy level.
|
||||
"""
|
||||
cache = _load_topic_cache()
|
||||
counts = {
|
||||
"topics": {},
|
||||
"subfields": {},
|
||||
"fields": {},
|
||||
"domains": {}
|
||||
}
|
||||
counts = {"topics": {}, "subfields": {}, "fields": {}, "domains": {}}
|
||||
|
||||
for name in topic_names:
|
||||
data = cache.get(name)
|
||||
@@ -197,49 +252,44 @@ def count_topic_hierarchy(topic_names: List[str]) -> dict:
|
||||
return counts
|
||||
|
||||
|
||||
|
||||
### persons
|
||||
|
||||
def list_persons(page_offset: int = 0, page_size: int = 20, query: Optional[str] = None,
|
||||
include: Optional[set[str]] = None) -> model.PersonPage:
|
||||
|
||||
def list_persons(
|
||||
page_offset: int = 0,
|
||||
page_size: int = 20,
|
||||
query: Optional[str] = None,
|
||||
include: Optional[set[str]] = None,
|
||||
) -> AuthorsListResponse:
|
||||
payload = _author_list_query(page_offset, page_size, query)
|
||||
data = elasticsearch.search(index="openalex-authors", payload=payload)
|
||||
persons = _parse_person_hits(data, include)
|
||||
hits = data.get("hits", {}).get("hits", [])
|
||||
persons = [util.get_persons_data(hit) for hit in hits]
|
||||
total = _extract_total_hits(data)
|
||||
return model.PersonPage(
|
||||
elements=persons,
|
||||
offset=page_offset,
|
||||
size=page_size,
|
||||
total=total
|
||||
return AuthorsListResponse(
|
||||
results=persons,
|
||||
meta=Meta(
|
||||
count=total,
|
||||
page=page_offset // page_size + 1 if page_size > 0 else 1,
|
||||
per_page=page_size,
|
||||
),
|
||||
)
|
||||
|
||||
def search_persons(author_id: Optional[str] = None, query: Optional[str] = None,
|
||||
include: Optional[set[str]] = None) -> model.PersonSearchResult:
|
||||
if author_id:
|
||||
query_field = "_id"
|
||||
query_value = author_id
|
||||
elif query:
|
||||
query_field = "display_name"
|
||||
query_value = query
|
||||
else:
|
||||
return "Either author_id or query must be provided"
|
||||
|
||||
data = elasticsearch.search(
|
||||
index="openalex-authors",
|
||||
query_field=query_field,
|
||||
query_value=query_value
|
||||
)
|
||||
|
||||
persons = _parse_person_hits(data, include)
|
||||
return model.PersonSearchResult(persons=persons)
|
||||
|
||||
def _author_list_query(page_offset: int, page_size: int, query: Optional[str] = None) -> dict:
|
||||
def _author_list_query(
|
||||
page_offset: int, page_size: int, query: Optional[str] = None
|
||||
) -> dict:
|
||||
search_query = {"match_all": {}}
|
||||
if query:
|
||||
search_query = {
|
||||
"query_string": {
|
||||
"fields": ["display_name^3", "display_name_alternatives", "_id", "ids.orcid"],
|
||||
"query": query
|
||||
"fields": [
|
||||
"display_name^3",
|
||||
"display_name_alternatives",
|
||||
"_id",
|
||||
"ids.orcid",
|
||||
],
|
||||
"query": query,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -249,82 +299,204 @@ def _author_list_query(page_offset: int, page_size: int, query: Optional[str] =
|
||||
"query": search_query,
|
||||
"sort": [
|
||||
{"works_count": {"order": "desc", "missing": "_last"}},
|
||||
{"cited_by_count": {"order": "desc", "missing": "_last"}}
|
||||
]
|
||||
{"cited_by_count": {"order": "desc", "missing": "_last"}},
|
||||
],
|
||||
}
|
||||
|
||||
|
||||
def _extract_total_hits(data: dict) -> int:
|
||||
total = data.get("hits", {}).get("total", 0)
|
||||
if isinstance(total, dict):
|
||||
return total.get("value", 0)
|
||||
return total
|
||||
|
||||
def _parse_person_hits(data: dict, include: Optional[set[str]] = None) -> List[model.Person]:
|
||||
include_set = {tag.strip().lower() for tag in include} if include else set()
|
||||
persons = []
|
||||
|
||||
def search_persons(
|
||||
author_id: Optional[str] = None,
|
||||
query: Optional[str] = None,
|
||||
include: Optional[set[str]] = None,
|
||||
) -> AuthorsListResponse:
|
||||
if author_id:
|
||||
query_field = "_id"
|
||||
query_value = author_id
|
||||
elif query:
|
||||
query_field = "display_name"
|
||||
query_value = query
|
||||
else:
|
||||
return AuthorsListResponse(results=[], meta=Meta(count=0))
|
||||
|
||||
data = elasticsearch.search(
|
||||
index="openalex-authors", query_field=query_field, query_value=query_value
|
||||
)
|
||||
|
||||
authors = []
|
||||
for hit in data.get("hits", {}).get("hits", []):
|
||||
source = hit.get("_source", {})
|
||||
source_copy = dict(source)
|
||||
source_copy["id"] = source_copy.get("id") or hit.get("_id", "")
|
||||
|
||||
affiliations = []
|
||||
for aff in source.get("affiliations", []):
|
||||
institution = aff.get("institution", {})
|
||||
affiliations.append(model.Affiliation(
|
||||
institution=institution.get("display_name", ""),
|
||||
country_code=institution.get("country_code", "")
|
||||
))
|
||||
# Resilient sanitization of IDs to protect against model regeneration type conflicts (#Generated)
|
||||
ids = source_copy.get("ids")
|
||||
if isinstance(ids, dict):
|
||||
ids_copy = dict(ids)
|
||||
for str_field in ["openalex", "orcid", "scopus"]:
|
||||
val = ids_copy.get(str_field)
|
||||
if val is not None and not isinstance(val, str):
|
||||
ids_copy[str_field] = str(val)
|
||||
source_copy["ids"] = ids_copy
|
||||
|
||||
topics = [t.get("display_name", "") for t in source.get("topics", [])]
|
||||
author = Author.from_dict(source_copy)
|
||||
if author:
|
||||
authors.append(author)
|
||||
|
||||
person_data = {
|
||||
"id": hit.get("_id", ""),
|
||||
"name": source.get("display_name", ""),
|
||||
"works_count": source.get("works_count", 0),
|
||||
"cited_by_count": source.get("cited_by_count", 0),
|
||||
"affiliations": affiliations,
|
||||
"topics": topics
|
||||
}
|
||||
return AuthorsListResponse(results=authors, meta=Meta(count=len(authors)))
|
||||
|
||||
# Include optional fields based on the include_set
|
||||
if "topics_full" in include_set:
|
||||
person_data["topics_full"] = source.get("topics", [])
|
||||
if "topic_share" in include_set:
|
||||
person_data["topic_share"] = source.get("topic_share", [])
|
||||
if "summary_stats" in include_set:
|
||||
person_data["summary_stats"] = source.get("summary_stats")
|
||||
if "ids" in include_set:
|
||||
person_data["ids"] = source.get("ids")
|
||||
if "last_known_institutions" in include_set:
|
||||
person_data["last_known_institutions"] = source.get("last_known_institutions", [])
|
||||
if "sources" in include_set:
|
||||
person_data["sources"] = source.get("sources", [])
|
||||
if "counts_by_year" in include_set:
|
||||
person_data["counts_by_year"] = source.get("counts_by_year", [])
|
||||
if "works_api_url" in include_set:
|
||||
person_data["works_api_url"] = source.get("works_api_url")
|
||||
if "dates" in include_set:
|
||||
person_data["dates"] = {
|
||||
"created_date": source.get("created_date"),
|
||||
"updated_date": source.get("updated_date")
|
||||
}
|
||||
if "cited_by_count_boost" in include_set:
|
||||
person_data["cited_by_count_boost"] = source.get("cited_by_count_boost")
|
||||
|
||||
persons.append(model.Person(**person_data))
|
||||
|
||||
return persons
|
||||
|
||||
def generate_person_bio(author_id: str) -> str:
|
||||
def generate_person_bio(author_id: str, include: Optional[set[str]] = None) -> str:
|
||||
start_time = time.time()
|
||||
search_result = search_persons(author_id=author_id)
|
||||
if not search_result.persons:
|
||||
if not search_result.results:
|
||||
return "No person found."
|
||||
if len(search_result.persons) > 1:
|
||||
if len(search_result.results) > 1:
|
||||
return "Multiple persons found, cannot generate bio."
|
||||
|
||||
person = search_result.persons[0]
|
||||
person_json = json.dumps(person.model_dump())
|
||||
person = search_result.results[0]
|
||||
person_json = json.dumps(person.model_dump_json())
|
||||
|
||||
system_prompt = """\
|
||||
Erstelle auf Basis der bereitgestellten OpenAlex-Daten ein kurzes Porträt der Person in 3-5 Sätzen. Die Person selbst ist das Subjekt: Beginne mit ihrem Namen und beschreibe sie als Forschende:n (z. B. „{name} ist ein:e Forscher:in im Bereich …"). Schreibe nicht über „die Forschung" oder „die Arbeit" im Abstrakten, sondern durchgehend über die Person.
|
||||
|
||||
Gehe dabei auf folgende drei Punkte ein:
|
||||
|
||||
1. Besonderheiten: Was hebt die Person im Vergleich zu anderen Forschenden ähnlicher Karrierephase und ähnlichen Feldes hervor? (z. B. überdurchschnittlicher Impact gemessen an der aktiven Zeit, hoher Erst-/Korrespondenzautor-Anteil, einzelnes Breakout-Paper, frühe Positionierung in einem später gewachsenen Thema)
|
||||
2. Wirtschaftliche Relevanz: Arbeitet die Person in einem grundsätzlich anwendungsnahen/kommerziell interessanten Themenfeld oder eher in der Grundlagenforschung?
|
||||
3. Dynamik: Entwickelt sich ihr Publikations-/Zitationsverlauf zuletzt steigend, konstant oder abflachend?
|
||||
|
||||
Stütze jede Aussage auf konkrete Werte aus den Daten und formuliere nichts, was sich nicht belegen lässt. Wenn die Daten für einen Punkt keine klare Aussage zulassen, formuliere ihn entsprechend zurückhaltend oder lasse ihn weg, statt zu spekulieren. Gib nur das Porträt zurück, ohne Einleitung oder Schluss.\
|
||||
"""
|
||||
|
||||
system_prompt = "Erstelle eine Beschreibung der Person in 3-5 Sätzen. Gebe nur die Beschreibung zurück, ohne Einleitung oder Schluss."
|
||||
user_prompt = f"Daten zur Person:\n{person_json}"
|
||||
|
||||
return llm.call(system_prompt=system_prompt, user_prompt=user_prompt)
|
||||
headers = {
|
||||
"Authorization": f"Bearer {config.settings.llm_api_key}",
|
||||
"Content-Type": "application/json",
|
||||
}
|
||||
payload = {
|
||||
"model": config.settings.llm_model,
|
||||
"prompt": f"{system_prompt}\n{user_prompt}",
|
||||
"stream": False,
|
||||
}
|
||||
|
||||
with httpx.Client(timeout=30.0) as client:
|
||||
response = client.post(
|
||||
config.settings.llm_api_url, json=payload, headers=headers
|
||||
)
|
||||
response.raise_for_status()
|
||||
data = response.json()
|
||||
bio = data.get("response", "")
|
||||
|
||||
elapsed_time = time.time() - start_time
|
||||
logger.info(
|
||||
f"Bio generation for author {author_id} took {elapsed_time:.2f} seconds"
|
||||
)
|
||||
|
||||
return bio
|
||||
|
||||
|
||||
def get_person_by_id(
|
||||
author_id: str, include: Optional[str] = None
|
||||
) -> AuthorsListResponse:
|
||||
try:
|
||||
hit = es_client.get(
|
||||
index="openalex-authors",
|
||||
id=author_id,
|
||||
source=include.split(",") if include else True,
|
||||
)
|
||||
|
||||
except NotFoundError:
|
||||
raise HTTPException(
|
||||
status_code=404, detail=f"Person with id {author_id} not found"
|
||||
)
|
||||
|
||||
except ApiError as e:
|
||||
raise HTTPException(status_code=500, detail=f"Elasticsearch error: {str(e)}")
|
||||
persons = [util.get_persons_data(hit)]
|
||||
|
||||
return AuthorsListResponse(results=persons)
|
||||
|
||||
|
||||
def search_persons_by_name(
|
||||
author_name: str, limit: Optional[int] = 10, include: Optional[str] = None
|
||||
) -> AuthorsListResponse:
|
||||
if not author_name:
|
||||
raise HTTPException(status_code=400, detail="name must be provided")
|
||||
|
||||
search_query = {
|
||||
"bool": {
|
||||
"should": [
|
||||
{"match_phrase": {"display_name": {"query": author_name, "boost": 5}}},
|
||||
{
|
||||
"match_phrase_prefix": {
|
||||
"display_name": {"query": author_name, "boost": 3}
|
||||
}
|
||||
},
|
||||
{"match": {"display_name": {"query": author_name, "fuzziness": 1}}},
|
||||
],
|
||||
"minimum_should_match": 1,
|
||||
}
|
||||
}
|
||||
try:
|
||||
response = es_client.search(
|
||||
index="openalex-authors",
|
||||
query=search_query,
|
||||
source=include.split(",") if include else True,
|
||||
size=limit,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
status_code=500, detail=f"Elasticsearch search failed: {str(e)}"
|
||||
)
|
||||
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
|
||||
persons = [util.get_persons_data(hit) for hit in hits]
|
||||
|
||||
return AuthorsListResponse(results=persons)
|
||||
|
||||
|
||||
def search_persons_by_institution(
|
||||
institution_name: str, limit: Optional[int] = 10, include: Optional[str] = None
|
||||
) -> AuthorsListResponse:
|
||||
|
||||
if not institution_name:
|
||||
raise HTTPException(status_code=400, detail="institution_name must be provided")
|
||||
|
||||
search_query = {
|
||||
"nested": {
|
||||
"path": "affiliations",
|
||||
"query": {
|
||||
"match_phrase": {
|
||||
"affiliations.institution.display_name": institution_name
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
print(include, institution_name)
|
||||
try:
|
||||
response = es_client.search(
|
||||
index="openalex-authors",
|
||||
source=include.split(",") if include else True,
|
||||
query=search_query,
|
||||
size=limit,
|
||||
sort=[{"works_count": {"order": "desc"}}],
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
raise HTTPException(
|
||||
status_code=500, detail=f"Elasticsearch search failed: {str(e)}"
|
||||
)
|
||||
|
||||
hits = response.get("hits", {}).get("hits", [])
|
||||
persons = [util.get_persons_data(hit) for hit in hits]
|
||||
return AuthorsListResponse(results=persons)
|
||||
|
||||
@@ -1,26 +1,48 @@
|
||||
#!/usr/bin/env python
|
||||
# -*- coding: utf-8 -*-
|
||||
"""
|
||||
This module contains the bootstrapping code
|
||||
for fastapi that loads the service and the
|
||||
webapp.
|
||||
This module contains the bootstrapping code
|
||||
for fastapi that loads the service and the
|
||||
webapp.
|
||||
"""
|
||||
|
||||
import logging
|
||||
from fastapi import FastAPI
|
||||
from fastapi.responses import RedirectResponse
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
from inse.collaboration_network.router import router as collaboration_network_router
|
||||
from inse.works.service import router as works_service_router
|
||||
|
||||
from . import config
|
||||
from . import service
|
||||
from . import webapp
|
||||
from .account import service as account
|
||||
from .service import router as service_router
|
||||
from .account.service import router as account_router
|
||||
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
### startup
|
||||
|
||||
app = FastAPI(redoc_url=None, docs_url=None)
|
||||
app.mount("/inse-service", service.app)
|
||||
app.mount("/inse-webapp", webapp.app)
|
||||
app.mount("/inse-account", account.app)
|
||||
settings = config.get_settings()
|
||||
|
||||
app = FastAPI(
|
||||
redoc_url=None,
|
||||
title="Innovation Search Engine API",
|
||||
description="API for the Innovation Search Engine (INSE) application.",
|
||||
version="0.1.0",
|
||||
servers=settings.servers,
|
||||
)
|
||||
app.include_router(collaboration_network_router)
|
||||
app.include_router(works_service_router)
|
||||
app.include_router(service_router)
|
||||
app.include_router(account_router)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=settings.allowed_origins,
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
|
||||
@app.exception_handler(404)
|
||||
async def redirect(_, __):
|
||||
|
||||
@@ -36,41 +36,5 @@ class Page(BaseModel, Generic[T]):
|
||||
class ItemPage(Page[Item]):
|
||||
pass
|
||||
|
||||
class Topic(BaseModel):
|
||||
id: str = Field(description="The openalex topic id.")
|
||||
name: str = Field(description="The topic name.")
|
||||
subfield: str = Field(description="The subfield of the topic.")
|
||||
field: str = Field(description="The field of the topic.")
|
||||
domain: str = Field(description="The domain of the topic.")
|
||||
|
||||
class PersonBio(BaseModel):
|
||||
bio: str = Field(description="The generated biography.")
|
||||
|
||||
class Affiliation(BaseModel):
|
||||
institution: str = Field(description="Institution name.")
|
||||
country_code: Optional[str] = Field(default=None, description="Country code.")
|
||||
|
||||
class Person(BaseModel):
|
||||
id: str = Field(description="The person id.")
|
||||
name: str = Field(description="The person name.")
|
||||
works_count: int = Field(description="Number of works.")
|
||||
cited_by_count: int = Field(description="Number of citations.")
|
||||
affiliations: List[Affiliation] = Field(default=[], description="Affiliations.")
|
||||
topics: List[str] = Field(default=[], description="Research topics.")
|
||||
# Optional detailed information
|
||||
topics_full: Optional[List[dict]] = Field(default=None, description="Detailed topics with hierarchy.")
|
||||
topic_share: Optional[List[dict]] = Field(default=None, description="Topic share distribution.")
|
||||
summary_stats: Optional[dict] = Field(default=None, description="Summary statistics.")
|
||||
ids: Optional[dict] = Field(default=None, description="External identifiers.")
|
||||
last_known_institutions: Optional[List[dict]] = Field(default=None, description="Last known institutions.")
|
||||
sources: Optional[List[dict]] = Field(default=None, description="Sources list.")
|
||||
counts_by_year: Optional[List[dict]] = Field(default=None, description="Counts by year.")
|
||||
works_api_url: Optional[str] = Field(default=None, description="Works API URL.")
|
||||
dates: Optional[dict] = Field(default=None, description="Created and updated dates.")
|
||||
cited_by_count_boost: Optional[int] = Field(default=None, description="Cited by count boost.")
|
||||
|
||||
class PersonSearchResult(BaseModel):
|
||||
persons: List[Person] = Field(default=[], description="List of found persons.")
|
||||
|
||||
class PersonPage(Page[Person]):
|
||||
pass
|
||||
|
||||
Binary file not shown.
@@ -0,0 +1,128 @@
|
||||
# coding: utf-8
|
||||
|
||||
# flake8: noqa
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
# import models into model package
|
||||
from inse.models.author import Author
|
||||
from inse.models.author_affiliations_inner import AuthorAffiliationsInner
|
||||
from inse.models.author_counts_by_year_inner import AuthorCountsByYearInner
|
||||
from inse.models.author_ids import AuthorIds
|
||||
from inse.models.author_parsed_longest_name import AuthorParsedLongestName
|
||||
from inse.models.author_summary_stats import AuthorSummaryStats
|
||||
from inse.models.author_topics_inner import AuthorTopicsInner
|
||||
from inse.models.authors_list_response import AuthorsListResponse
|
||||
from inse.models.authorship import Authorship
|
||||
from inse.models.autocomplete_response import AutocompleteResponse
|
||||
from inse.models.autocomplete_response_meta import AutocompleteResponseMeta
|
||||
from inse.models.autocomplete_response_results_inner import AutocompleteResponseResultsInner
|
||||
from inse.models.award import Award
|
||||
from inse.models.award_full import AwardFull
|
||||
from inse.models.award_full_funder import AwardFullFunder
|
||||
from inse.models.awards_list_response import AwardsListResponse
|
||||
from inse.models.concept import Concept
|
||||
from inse.models.concept_ids import ConceptIds
|
||||
from inse.models.concepts_list_response import ConceptsListResponse
|
||||
from inse.models.continent import Continent
|
||||
from inse.models.continent_ids import ContinentIds
|
||||
from inse.models.continents_list_response import ContinentsListResponse
|
||||
from inse.models.countries_list_response import CountriesListResponse
|
||||
from inse.models.country import Country
|
||||
from inse.models.country_continent import CountryContinent
|
||||
from inse.models.country_ids import CountryIds
|
||||
from inse.models.dehydrated_author import DehydratedAuthor
|
||||
from inse.models.dehydrated_funder import DehydratedFunder
|
||||
from inse.models.dehydrated_institution import DehydratedInstitution
|
||||
from inse.models.dehydrated_source import DehydratedSource
|
||||
from inse.models.domain import Domain
|
||||
from inse.models.domain_fields_inner import DomainFieldsInner
|
||||
from inse.models.domain_ids import DomainIds
|
||||
from inse.models.domains_list_response import DomainsListResponse
|
||||
from inse.models.error import Error
|
||||
from inse.models.fields_list_response import FieldsListResponse
|
||||
from inse.models.funder import Funder
|
||||
from inse.models.funder_ids import FunderIds
|
||||
from inse.models.funders_list_response import FundersListResponse
|
||||
from inse.models.get_changefile200_response import GetChangefile200Response
|
||||
from inse.models.get_changefile200_response_meta import GetChangefile200ResponseMeta
|
||||
from inse.models.get_changefile200_response_results_inner import GetChangefile200ResponseResultsInner
|
||||
from inse.models.get_changefile200_response_results_inner_formats import GetChangefile200ResponseResultsInnerFormats
|
||||
from inse.models.get_changefile200_response_results_inner_formats_jsonl import GetChangefile200ResponseResultsInnerFormatsJsonl
|
||||
from inse.models.get_changefile200_response_results_inner_formats_parquet import GetChangefile200ResponseResultsInnerFormatsParquet
|
||||
from inse.models.group_by_result import GroupByResult
|
||||
from inse.models.institution import Institution
|
||||
from inse.models.institution_geo import InstitutionGeo
|
||||
from inse.models.institution_ids import InstitutionIds
|
||||
from inse.models.institution_type import InstitutionType
|
||||
from inse.models.institution_types_list_response import InstitutionTypesListResponse
|
||||
from inse.models.institutions_list_response import InstitutionsListResponse
|
||||
from inse.models.keyword import Keyword
|
||||
from inse.models.keywords_list_response import KeywordsListResponse
|
||||
from inse.models.language import Language
|
||||
from inse.models.languages_list_response import LanguagesListResponse
|
||||
from inse.models.license import License
|
||||
from inse.models.licenses_list_response import LicensesListResponse
|
||||
from inse.models.list_changefiles200_response import ListChangefiles200Response
|
||||
from inse.models.list_changefiles200_response_meta import ListChangefiles200ResponseMeta
|
||||
from inse.models.list_changefiles200_response_results_inner import ListChangefiles200ResponseResultsInner
|
||||
from inse.models.location import Location
|
||||
from inse.models.meta import Meta
|
||||
from inse.models.model_field import ModelField
|
||||
from inse.models.open_access import OpenAccess
|
||||
from inse.models.publisher import Publisher
|
||||
from inse.models.publisher_ids import PublisherIds
|
||||
from inse.models.publisher_parent_publisher import PublisherParentPublisher
|
||||
from inse.models.publishers_list_response import PublishersListResponse
|
||||
from inse.models.rate_limit_response import RateLimitResponse
|
||||
from inse.models.rate_limit_response_rate_limit import RateLimitResponseRateLimit
|
||||
from inse.models.rate_limit_response_rate_limit_endpoint_costs_usd import RateLimitResponseRateLimitEndpointCostsUsd
|
||||
from inse.models.sdg import Sdg
|
||||
from inse.models.sdg_ids import SdgIds
|
||||
from inse.models.sdgs_list_response import SdgsListResponse
|
||||
from inse.models.source import Source
|
||||
from inse.models.source_ids import SourceIds
|
||||
from inse.models.source_type import SourceType
|
||||
from inse.models.source_types_list_response import SourceTypesListResponse
|
||||
from inse.models.sources_list_response import SourcesListResponse
|
||||
from inse.models.subfield import Subfield
|
||||
from inse.models.subfield_domain import SubfieldDomain
|
||||
from inse.models.subfield_field import SubfieldField
|
||||
from inse.models.subfields_list_response import SubfieldsListResponse
|
||||
from inse.models.text_classification_response import TextClassificationResponse
|
||||
from inse.models.text_classification_response_meta import TextClassificationResponseMeta
|
||||
from inse.models.topic import Topic
|
||||
from inse.models.topic_domain import TopicDomain
|
||||
from inse.models.topic_field import TopicField
|
||||
from inse.models.topic_ids import TopicIds
|
||||
from inse.models.topic_subfield import TopicSubfield
|
||||
from inse.models.topics_list_response import TopicsListResponse
|
||||
from inse.models.work import Work
|
||||
from inse.models.work_biblio import WorkBiblio
|
||||
from inse.models.work_citation_normalized_percentile import WorkCitationNormalizedPercentile
|
||||
from inse.models.work_cited_by_percentile_year import WorkCitedByPercentileYear
|
||||
from inse.models.work_counts_by_year_inner import WorkCountsByYearInner
|
||||
from inse.models.work_has_content import WorkHasContent
|
||||
from inse.models.work_ids import WorkIds
|
||||
from inse.models.work_keyword import WorkKeyword
|
||||
from inse.models.work_mesh_inner import WorkMeshInner
|
||||
from inse.models.work_sustainable_development_goals_inner import WorkSustainableDevelopmentGoalsInner
|
||||
from inse.models.work_topic import WorkTopic
|
||||
from inse.models.work_topic_domain import WorkTopicDomain
|
||||
from inse.models.work_topic_field import WorkTopicField
|
||||
from inse.models.work_topic_subfield import WorkTopicSubfield
|
||||
from inse.models.work_type import WorkType
|
||||
from inse.models.work_types_list_response import WorkTypesListResponse
|
||||
from inse.models.works_list_response import WorksListResponse
|
||||
from inse.models.work_page import WorkPage
|
||||
|
||||
|
||||
@@ -0,0 +1,166 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.author_affiliations_inner import AuthorAffiliationsInner
|
||||
from inse.models.author_counts_by_year_inner import AuthorCountsByYearInner
|
||||
from inse.models.author_ids import AuthorIds
|
||||
from inse.models.author_parsed_longest_name import AuthorParsedLongestName
|
||||
from inse.models.author_summary_stats import AuthorSummaryStats
|
||||
from inse.models.work_topic import WorkTopic
|
||||
from inse.models.dehydrated_institution import DehydratedInstitution
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Author(BaseModel):
|
||||
"""
|
||||
A person who creates scholarly works
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this author.")
|
||||
orcid: Optional[StrictStr] = Field(default=None, description="The ORCID ID for this author. This is the Canonical External ID for authors.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The name of the author as a single string.")
|
||||
display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Other ways this author's name has been displayed.")
|
||||
longest_name: Optional[StrictStr] = Field(default=None, description="The longest name variant found for this author across all their works.")
|
||||
parsed_longest_name: Optional[AuthorParsedLongestName] = None
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works this author has created.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="The total number of works that cite a work this author has created.")
|
||||
summary_stats: Optional[AuthorSummaryStats] = None
|
||||
affiliations: Optional[List[AuthorAffiliationsInner]] = Field(default=None, description="List of affiliations this author has claimed in their publications. Each object has:")
|
||||
last_known_institutions: Optional[List[DehydratedInstitution]] = Field(default=None, description="This author's last known institutional affiliations. Each item is a dehydrated Institution object.")
|
||||
topics: Optional[List[WorkTopic]] = None
|
||||
counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.")
|
||||
ids: Optional[AuthorIds] = None
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that will get you a list of all this author's works.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this author was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this author was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "orcid", "display_name", "display_name_alternatives", "longest_name", "parsed_longest_name", "works_count", "cited_by_count", "summary_stats", "affiliations", "last_known_institutions", "topics", "counts_by_year", "ids", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Author from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of parsed_longest_name
|
||||
if self.parsed_longest_name:
|
||||
_dict['parsed_longest_name'] = self.parsed_longest_name.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of summary_stats
|
||||
if self.summary_stats:
|
||||
_dict['summary_stats'] = self.summary_stats.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in affiliations (list)
|
||||
_items = []
|
||||
if self.affiliations:
|
||||
for _item_affiliations in self.affiliations:
|
||||
if _item_affiliations:
|
||||
_items.append(_item_affiliations.to_dict())
|
||||
_dict['affiliations'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in last_known_institutions (list)
|
||||
_items = []
|
||||
if self.last_known_institutions:
|
||||
for _item_last_known_institutions in self.last_known_institutions:
|
||||
if _item_last_known_institutions:
|
||||
_items.append(_item_last_known_institutions.to_dict())
|
||||
_dict['last_known_institutions'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in topics (list)
|
||||
_items = []
|
||||
if self.topics:
|
||||
for _item_topics in self.topics:
|
||||
if _item_topics:
|
||||
_items.append(_item_topics.to_dict())
|
||||
_dict['topics'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in counts_by_year (list)
|
||||
_items = []
|
||||
if self.counts_by_year:
|
||||
for _item_counts_by_year in self.counts_by_year:
|
||||
if _item_counts_by_year:
|
||||
_items.append(_item_counts_by_year.to_dict())
|
||||
_dict['counts_by_year'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Author from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"orcid": obj.get("orcid"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"display_name_alternatives": obj.get("display_name_alternatives"),
|
||||
"longest_name": obj.get("longest_name"),
|
||||
"parsed_longest_name": AuthorParsedLongestName.from_dict(obj["parsed_longest_name"]) if obj.get("parsed_longest_name") is not None else None,
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"summary_stats": AuthorSummaryStats.from_dict(obj["summary_stats"]) if obj.get("summary_stats") is not None else None,
|
||||
"affiliations": [AuthorAffiliationsInner.from_dict(_item) for _item in obj["affiliations"]] if obj.get("affiliations") is not None else None,
|
||||
"last_known_institutions": [DehydratedInstitution.from_dict(_item) for _item in obj["last_known_institutions"]] if obj.get("last_known_institutions") is not None else None,
|
||||
"topics": [WorkTopic.from_dict(_item) for _item in obj["topics"]] if obj.get("topics") is not None else None,
|
||||
"counts_by_year": [AuthorCountsByYearInner.from_dict(_item) for _item in obj["counts_by_year"]] if obj.get("counts_by_year") is not None else None,
|
||||
"ids": AuthorIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.dehydrated_institution import DehydratedInstitution
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
|
||||
class AuthorAffiliationsInner(BaseModel):
|
||||
"""
|
||||
AuthorAffiliationsInner
|
||||
""" # noqa: E501
|
||||
|
||||
institution: Optional[DehydratedInstitution] = Field(
|
||||
default=None,
|
||||
description="[Dehydrated institution](/api-reference/institutions#the-dehydratedinstitution-object)",
|
||||
)
|
||||
years: Optional[List[StrictInt]] = None
|
||||
__properties: ClassVar[List[str]] = ["institution", "years"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AuthorAffiliationsInner from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of institution
|
||||
if self.institution:
|
||||
_dict["institution"] = self.institution.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AuthorAffiliationsInner from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate(
|
||||
{
|
||||
"institution": DehydratedInstitution.from_dict(obj["institution"])
|
||||
if obj.get("institution") is not None
|
||||
else None,
|
||||
"years": obj.get("years"),
|
||||
}
|
||||
)
|
||||
return _obj
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AuthorCountsByYearInner(BaseModel):
|
||||
"""
|
||||
AuthorCountsByYearInner
|
||||
""" # noqa: E501
|
||||
year: Optional[StrictInt] = None
|
||||
works_count: Optional[StrictInt] = None
|
||||
cited_by_count: Optional[StrictInt] = None
|
||||
__properties: ClassVar[List[str]] = ["year", "works_count", "cited_by_count"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AuthorCountsByYearInner from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AuthorCountsByYearInner from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"year": obj.get("year"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AuthorIds(BaseModel):
|
||||
"""
|
||||
External identifiers:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
orcid: Optional[StrictStr] = None
|
||||
scopus: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "orcid", "scopus"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AuthorIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AuthorIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
openalex_val = obj.get("openalex")
|
||||
if openalex_val is not None and not isinstance(openalex_val, str):
|
||||
openalex_val = str(openalex_val)
|
||||
|
||||
orcid_val = obj.get("orcid")
|
||||
if orcid_val is not None and not isinstance(orcid_val, str):
|
||||
orcid_val = str(orcid_val)
|
||||
|
||||
scopus_val = obj.get("scopus")
|
||||
if scopus_val is not None and not isinstance(scopus_val, str):
|
||||
scopus_val = str(scopus_val)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": openalex_val,
|
||||
"orcid": orcid_val,
|
||||
"scopus": scopus_val
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AuthorParsedLongestName(BaseModel):
|
||||
"""
|
||||
The longest name parsed into its component parts.
|
||||
""" # noqa: E501
|
||||
first: Optional[StrictStr] = Field(default=None, description="First name (lowercased).")
|
||||
middle: Optional[StrictStr] = Field(default=None, description="Middle name or initial (lowercased).")
|
||||
last: Optional[StrictStr] = Field(default=None, description="Last name (lowercased).")
|
||||
suffix: Optional[StrictStr] = Field(default=None, description="Name suffix (e.g., Jr., III).")
|
||||
nickname: Optional[StrictStr] = Field(default=None, description="Nickname, if any.")
|
||||
__properties: ClassVar[List[str]] = ["first", "middle", "last", "suffix", "nickname"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AuthorParsedLongestName from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AuthorParsedLongestName from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"first": obj.get("first"),
|
||||
"middle": obj.get("middle"),
|
||||
"last": obj.get("last"),
|
||||
"suffix": obj.get("suffix"),
|
||||
"nickname": obj.get("nickname")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AuthorSummaryStats(BaseModel):
|
||||
"""
|
||||
Citation metrics:
|
||||
""" # noqa: E501
|
||||
var_2yr_mean_citedness: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, alias="2yr_mean_citedness")
|
||||
h_index: Optional[StrictInt] = None
|
||||
i10_index: Optional[StrictInt] = None
|
||||
__properties: ClassVar[List[str]] = ["2yr_mean_citedness", "h_index", "i10_index"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AuthorSummaryStats from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AuthorSummaryStats from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"2yr_mean_citedness": obj.get("2yr_mean_citedness"),
|
||||
"h_index": obj.get("h_index"),
|
||||
"i10_index": obj.get("i10_index")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AuthorTopicsInner(BaseModel):
|
||||
"""
|
||||
AuthorTopicsInner
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
count: Optional[StrictInt] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "count"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AuthorTopicsInner from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AuthorTopicsInner from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"count": obj.get("count")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.author import Author
|
||||
from inse.models.group_by_result import GroupByResult
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AuthorsListResponse(BaseModel):
|
||||
"""
|
||||
AuthorsListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Author]] = None
|
||||
group_by: Optional[List[GroupByResult]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results", "group_by"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AuthorsListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in group_by (list)
|
||||
_items = []
|
||||
if self.group_by:
|
||||
for _item_group_by in self.group_by:
|
||||
if _item_group_by:
|
||||
_items.append(_item_group_by.to_dict())
|
||||
_dict['group_by'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AuthorsListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Author.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None,
|
||||
"group_by": [GroupByResult.from_dict(_item) for _item in obj["group_by"]] if obj.get("group_by") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,123 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.dehydrated_author import DehydratedAuthor
|
||||
from inse.models.dehydrated_institution import DehydratedInstitution
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Authorship(BaseModel):
|
||||
"""
|
||||
Author and their affiliation for a work
|
||||
""" # noqa: E501
|
||||
author_position: Optional[StrictStr] = Field(default=None, description="Position in author list")
|
||||
author: Optional[DehydratedAuthor] = Field(default=None, description="[Dehydrated author](/api-reference/authors#the-dehydratedauthor-object)")
|
||||
institutions: Optional[List[DehydratedInstitution]] = Field(default=None, description="[Dehydrated institutions](/api-reference/institutions#the-dehydratedinstitution-object)")
|
||||
countries: Optional[List[StrictStr]] = Field(default=None, description="Country codes of affiliations")
|
||||
is_corresponding: Optional[StrictBool] = Field(default=None, description="Whether this is the corresponding author")
|
||||
raw_author_name: Optional[StrictStr] = Field(default=None, description="Author name as it appears in the work")
|
||||
raw_affiliation_strings: Optional[List[StrictStr]] = None
|
||||
__properties: ClassVar[List[str]] = ["author_position", "author", "institutions", "countries", "is_corresponding", "raw_author_name", "raw_affiliation_strings"]
|
||||
|
||||
@field_validator('author_position')
|
||||
def author_position_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in set(['first', 'middle', 'last']):
|
||||
raise ValueError("must be one of enum values ('first', 'middle', 'last')")
|
||||
return value
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Authorship from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of author
|
||||
if self.author:
|
||||
_dict['author'] = self.author.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in institutions (list)
|
||||
_items = []
|
||||
if self.institutions:
|
||||
for _item_institutions in self.institutions:
|
||||
if _item_institutions:
|
||||
_items.append(_item_institutions.to_dict())
|
||||
_dict['institutions'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Authorship from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"author_position": obj.get("author_position"),
|
||||
"author": DehydratedAuthor.from_dict(obj["author"]) if obj.get("author") is not None else None,
|
||||
"institutions": [DehydratedInstitution.from_dict(_item) for _item in obj["institutions"]] if obj.get("institutions") is not None else None,
|
||||
"countries": obj.get("countries"),
|
||||
"is_corresponding": obj.get("is_corresponding"),
|
||||
"raw_author_name": obj.get("raw_author_name"),
|
||||
"raw_affiliation_strings": obj.get("raw_affiliation_strings")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.autocomplete_response_meta import AutocompleteResponseMeta
|
||||
from inse.models.autocomplete_response_results_inner import AutocompleteResponseResultsInner
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AutocompleteResponse(BaseModel):
|
||||
"""
|
||||
AutocompleteResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[AutocompleteResponseMeta] = None
|
||||
results: Optional[List[AutocompleteResponseResultsInner]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AutocompleteResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AutocompleteResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": AutocompleteResponseMeta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [AutocompleteResponseResultsInner.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AutocompleteResponseMeta(BaseModel):
|
||||
"""
|
||||
AutocompleteResponseMeta
|
||||
""" # noqa: E501
|
||||
count: Optional[StrictInt] = None
|
||||
db_response_time_ms: Optional[StrictInt] = None
|
||||
__properties: ClassVar[List[str]] = ["count", "db_response_time_ms"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AutocompleteResponseMeta from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AutocompleteResponseMeta from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"count": obj.get("count"),
|
||||
"db_response_time_ms": obj.get("db_response_time_ms")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AutocompleteResponseResultsInner(BaseModel):
|
||||
"""
|
||||
AutocompleteResponseResultsInner
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
hint: Optional[StrictStr] = None
|
||||
cited_by_count: Optional[StrictInt] = None
|
||||
works_count: Optional[StrictInt] = None
|
||||
entity_type: Optional[StrictStr] = None
|
||||
external_id: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "hint", "cited_by_count", "works_count", "entity_type", "external_id"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AutocompleteResponseResultsInner from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AutocompleteResponseResultsInner from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"hint": obj.get("hint"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"entity_type": obj.get("entity_type"),
|
||||
"external_id": obj.get("external_id")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Award(BaseModel):
|
||||
"""
|
||||
Award
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
funder_award_id: Optional[StrictStr] = None
|
||||
funder_id: Optional[StrictStr] = None
|
||||
funder_display_name: Optional[StrictStr] = None
|
||||
doi: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "funder_award_id", "funder_id", "funder_display_name", "doi"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Award from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Award from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"funder_award_id": obj.get("funder_award_id"),
|
||||
"funder_id": obj.get("funder_id"),
|
||||
"funder_display_name": obj.get("funder_display_name"),
|
||||
"doi": obj.get("doi")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,140 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
from inse.models.award_full_funder import AwardFullFunder
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AwardFull(BaseModel):
|
||||
"""
|
||||
Research grant or funding award
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this award.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The name of the award, if available.")
|
||||
description: Optional[StrictStr] = Field(default=None, description="A description of the award, if available.")
|
||||
funder_award_id: Optional[StrictStr] = Field(default=None, description="The funder's internal ID for this award.")
|
||||
funder: Optional[AwardFullFunder] = None
|
||||
funded_outputs: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs of works funded by this award (first 100).")
|
||||
funded_outputs_count: Optional[StrictInt] = Field(default=None, description="Total number of works funded by this award.")
|
||||
amount: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="The funding amount, if available.")
|
||||
currency: Optional[StrictStr] = Field(default=None, description="The currency of the funding amount, if available.")
|
||||
funding_type: Optional[StrictStr] = Field(default=None, description="The type of funding, if available.")
|
||||
funder_scheme: Optional[StrictStr] = Field(default=None, description="The funder's scheme or program, if available.")
|
||||
start_date: Optional[date] = Field(default=None, description="Start date of the award (ISO 8601), if available.")
|
||||
end_date: Optional[date] = Field(default=None, description="End date of the award (ISO 8601), if available.")
|
||||
start_year: Optional[StrictInt] = Field(default=None, description="Start year of the award, if available.")
|
||||
end_year: Optional[StrictInt] = Field(default=None, description="End year of the award, if available.")
|
||||
landing_page_url: Optional[StrictStr] = Field(default=None, description="URL to the award's landing page, if available.")
|
||||
doi: Optional[StrictStr] = Field(default=None, description="DOI for this award, if available.")
|
||||
provenance: Optional[StrictStr] = Field(default=None, description="The source of this award data.")
|
||||
lead_investigator: Optional[Dict[str, Any]] = Field(default=None, description="The lead investigator for this award, if available.")
|
||||
co_lead_investigator: Optional[Dict[str, Any]] = Field(default=None, description="The co-lead investigator, if available.")
|
||||
investigators: Optional[List[Any]] = Field(default=None, description="List of investigators on this award, if available.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works funded by this award.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this award was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this award was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "description", "funder_award_id", "funder", "funded_outputs", "funded_outputs_count", "amount", "currency", "funding_type", "funder_scheme", "start_date", "end_date", "start_year", "end_year", "landing_page_url", "doi", "provenance", "lead_investigator", "co_lead_investigator", "investigators", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AwardFull from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of funder
|
||||
if self.funder:
|
||||
_dict['funder'] = self.funder.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AwardFull from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"description": obj.get("description"),
|
||||
"funder_award_id": obj.get("funder_award_id"),
|
||||
"funder": AwardFullFunder.from_dict(obj["funder"]) if obj.get("funder") is not None else None,
|
||||
"funded_outputs": obj.get("funded_outputs"),
|
||||
"funded_outputs_count": obj.get("funded_outputs_count"),
|
||||
"amount": obj.get("amount"),
|
||||
"currency": obj.get("currency"),
|
||||
"funding_type": obj.get("funding_type"),
|
||||
"funder_scheme": obj.get("funder_scheme"),
|
||||
"start_date": obj.get("start_date"),
|
||||
"end_date": obj.get("end_date"),
|
||||
"start_year": obj.get("start_year"),
|
||||
"end_year": obj.get("end_year"),
|
||||
"landing_page_url": obj.get("landing_page_url"),
|
||||
"doi": obj.get("doi"),
|
||||
"provenance": obj.get("provenance"),
|
||||
"lead_investigator": obj.get("lead_investigator"),
|
||||
"co_lead_investigator": obj.get("co_lead_investigator"),
|
||||
"investigators": obj.get("investigators"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AwardFullFunder(BaseModel):
|
||||
"""
|
||||
The [funder](/api-reference/funders) of this award
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
doi: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "doi"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AwardFullFunder from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AwardFullFunder from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"doi": obj.get("doi")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.award_full import AwardFull
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class AwardsListResponse(BaseModel):
|
||||
"""
|
||||
AwardsListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[AwardFull]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of AwardsListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of AwardsListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [AwardFull.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,124 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.concept_ids import ConceptIds
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Concept(BaseModel):
|
||||
"""
|
||||
Legacy research area taxonomy (deprecated)
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this concept.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The name of the concept.")
|
||||
description: Optional[StrictStr] = Field(default=None, description="A description of this concept.")
|
||||
level: Optional[StrictInt] = Field(default=None, description="The hierarchical level (0 = top level, higher = more specific).")
|
||||
wikidata: Optional[StrictStr] = Field(default=None, description="The Wikidata ID for this concept.")
|
||||
ids: Optional[ConceptIds] = None
|
||||
image_url: Optional[StrictStr] = Field(default=None, description="URL for an image representing this concept.")
|
||||
image_thumbnail_url: Optional[StrictStr] = Field(default=None, description="Smaller version of `image_url`.")
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with this concept.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works tagged with this concept.")
|
||||
ancestors: Optional[List[Any]] = Field(default=None, description="Parent concepts in the hierarchy.")
|
||||
related_concepts: Optional[List[Any]] = Field(default=None, description="Related concepts with similarity scores.")
|
||||
counts_by_year: Optional[List[Any]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this concept.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this concept was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this concept was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "description", "level", "wikidata", "ids", "image_url", "image_thumbnail_url", "works_count", "cited_by_count", "ancestors", "related_concepts", "counts_by_year", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Concept from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Concept from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"description": obj.get("description"),
|
||||
"level": obj.get("level"),
|
||||
"wikidata": obj.get("wikidata"),
|
||||
"ids": ConceptIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"image_url": obj.get("image_url"),
|
||||
"image_thumbnail_url": obj.get("image_thumbnail_url"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"ancestors": obj.get("ancestors"),
|
||||
"related_concepts": obj.get("related_concepts"),
|
||||
"counts_by_year": obj.get("counts_by_year"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class ConceptIds(BaseModel):
|
||||
"""
|
||||
External identifiers:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
wikidata: Optional[StrictStr] = None
|
||||
wikipedia: Optional[StrictStr] = None
|
||||
mag: Optional[StrictInt] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "wikidata", "wikipedia", "mag"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ConceptIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of ConceptIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": obj.get("openalex"),
|
||||
"wikidata": obj.get("wikidata"),
|
||||
"wikipedia": obj.get("wikipedia"),
|
||||
"mag": obj.get("mag")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.concept import Concept
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class ConceptsListResponse(BaseModel):
|
||||
"""
|
||||
ConceptsListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Concept]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ConceptsListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of ConceptsListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Concept.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,116 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.continent_ids import ContinentIds
|
||||
from inse.models.domain_fields_inner import DomainFieldsInner
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Continent(BaseModel):
|
||||
"""
|
||||
Geographic continent (7 total)
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this continent (uses Wikidata Q-IDs).")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The name of the continent.")
|
||||
description: Optional[StrictStr] = Field(default=None, description="A brief description of the continent.")
|
||||
display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this continent.")
|
||||
countries: Optional[List[DomainFieldsInner]] = Field(default=None, description="The countries within this continent. Each object has `id` and `display_name`.")
|
||||
ids: Optional[ContinentIds] = None
|
||||
created_date: Optional[date] = Field(default=None, description="When this continent was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this continent was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "description", "display_name_alternatives", "countries", "ids", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Continent from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in countries (list)
|
||||
_items = []
|
||||
if self.countries:
|
||||
for _item_countries in self.countries:
|
||||
if _item_countries:
|
||||
_items.append(_item_countries.to_dict())
|
||||
_dict['countries'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Continent from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"description": obj.get("description"),
|
||||
"display_name_alternatives": obj.get("display_name_alternatives"),
|
||||
"countries": [DomainFieldsInner.from_dict(_item) for _item in obj["countries"]] if obj.get("countries") is not None else None,
|
||||
"ids": ContinentIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class ContinentIds(BaseModel):
|
||||
"""
|
||||
External identifiers:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
wikidata: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "wikidata"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ContinentIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of ContinentIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": obj.get("openalex"),
|
||||
"wikidata": obj.get("wikidata")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.continent import Continent
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class ContinentsListResponse(BaseModel):
|
||||
"""
|
||||
ContinentsListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Continent]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ContinentsListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of ContinentsListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Continent.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.country import Country
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class CountriesListResponse(BaseModel):
|
||||
"""
|
||||
CountriesListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Country]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of CountriesListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of CountriesListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Country.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,126 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.country_continent import CountryContinent
|
||||
from inse.models.country_ids import CountryIds
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Country(BaseModel):
|
||||
"""
|
||||
Geographic country
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this country.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The full name of the country.")
|
||||
country_code: Optional[StrictStr] = Field(default=None, description="ISO 3166-1 alpha-2 country code.")
|
||||
description: Optional[StrictStr] = Field(default=None, description="A brief description of the country.")
|
||||
display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this country.")
|
||||
continent: Optional[CountryContinent] = None
|
||||
is_global_south: Optional[StrictBool] = Field(default=None, description="Whether this country is part of the Global South.")
|
||||
ids: Optional[CountryIds] = None
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works with authors affiliated with institutions in this country.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works from this country.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works from authors in this country.")
|
||||
authors_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all authors with affiliations in this country.")
|
||||
institutions_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all institutions in this country.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this country was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this country was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "country_code", "description", "display_name_alternatives", "continent", "is_global_south", "ids", "works_count", "cited_by_count", "works_api_url", "authors_api_url", "institutions_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Country from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of continent
|
||||
if self.continent:
|
||||
_dict['continent'] = self.continent.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Country from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"country_code": obj.get("country_code"),
|
||||
"description": obj.get("description"),
|
||||
"display_name_alternatives": obj.get("display_name_alternatives"),
|
||||
"continent": CountryContinent.from_dict(obj["continent"]) if obj.get("continent") is not None else None,
|
||||
"is_global_south": obj.get("is_global_south"),
|
||||
"ids": CountryIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"authors_api_url": obj.get("authors_api_url"),
|
||||
"institutions_api_url": obj.get("institutions_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class CountryContinent(BaseModel):
|
||||
"""
|
||||
The [continent](/api-reference/continents)
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of CountryContinent from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of CountryContinent from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class CountryIds(BaseModel):
|
||||
"""
|
||||
External identifiers:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
iso: Optional[StrictStr] = None
|
||||
wikidata: Optional[StrictStr] = None
|
||||
wikipedia: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "iso", "wikidata", "wikipedia"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of CountryIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of CountryIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": obj.get("openalex"),
|
||||
"iso": obj.get("iso"),
|
||||
"wikidata": obj.get("wikidata"),
|
||||
"wikipedia": obj.get("wikipedia")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class DehydratedAuthor(BaseModel):
|
||||
"""
|
||||
[Dehydrated Author](/api-reference/authors#the-dehydratedauthor-object) — reduced-field version used in nested contexts
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
orcid: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "orcid"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DehydratedAuthor from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of DehydratedAuthor from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"orcid": obj.get("orcid")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class DehydratedFunder(BaseModel):
|
||||
"""
|
||||
[Dehydrated Funder](/api-reference/funders) — reduced-field version used in nested contexts
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
ror: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "ror"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DehydratedFunder from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of DehydratedFunder from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"ror": obj.get("ror")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class DehydratedInstitution(BaseModel):
|
||||
"""
|
||||
[Dehydrated Institution](/api-reference/institutions#the-dehydratedinstitution-object) — reduced-field version used in nested contexts
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
ror: Optional[StrictStr] = None
|
||||
country_code: Optional[StrictStr] = Field(default=None, description="[Country](/api-reference/countries) code")
|
||||
type: Optional[StrictStr] = Field(default=None, description="The [institution type](/api-reference/institution-types)")
|
||||
lineage: Optional[List[StrictStr]] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "ror", "country_code", "type", "lineage"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DehydratedInstitution from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of DehydratedInstitution from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"ror": obj.get("ror"),
|
||||
"country_code": obj.get("country_code"),
|
||||
"type": obj.get("type"),
|
||||
"lineage": obj.get("lineage")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,109 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class DehydratedSource(BaseModel):
|
||||
"""
|
||||
[Dehydrated Source](/api-reference/sources#the-dehydratedsource-object) — reduced-field version used in nested contexts
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
issn_l: Optional[StrictStr] = None
|
||||
issn: Optional[List[StrictStr]] = None
|
||||
is_oa: Optional[StrictBool] = None
|
||||
is_in_doaj: Optional[StrictBool] = None
|
||||
is_core: Optional[StrictBool] = None
|
||||
host_organization: Optional[StrictStr] = None
|
||||
host_organization_name: Optional[StrictStr] = None
|
||||
host_organization_lineage: Optional[List[StrictStr]] = None
|
||||
type: Optional[StrictStr] = Field(default=None, description="The [source type](/api-reference/source-types)")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "issn_l", "issn", "is_oa", "is_in_doaj", "is_core", "host_organization", "host_organization_name", "host_organization_lineage", "type"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DehydratedSource from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of DehydratedSource from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"issn_l": obj.get("issn_l"),
|
||||
"issn": obj.get("issn"),
|
||||
"is_oa": obj.get("is_oa"),
|
||||
"is_in_doaj": obj.get("is_in_doaj"),
|
||||
"is_core": obj.get("is_core"),
|
||||
"host_organization": obj.get("host_organization"),
|
||||
"host_organization_name": obj.get("host_organization_name"),
|
||||
"host_organization_lineage": obj.get("host_organization_lineage"),
|
||||
"type": obj.get("type")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,131 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.domain_fields_inner import DomainFieldsInner
|
||||
from inse.models.domain_ids import DomainIds
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Domain(BaseModel):
|
||||
"""
|
||||
Top-level category in the topic hierarchy (4 total)
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this domain.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The English-language label of the domain.")
|
||||
description: Optional[StrictStr] = Field(default=None, description="A description of this domain.")
|
||||
display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this domain.")
|
||||
fields: Optional[List[DomainFieldsInner]] = Field(default=None, description="The fields within this domain. Each object has `id` and `display_name`.")
|
||||
siblings: Optional[List[DomainFieldsInner]] = Field(default=None, description="Other domains at the same level. Each object has `id` and `display_name`.")
|
||||
ids: Optional[DomainIds] = None
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with topics in this domain.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works in this domain.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this domain.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this domain was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this domain was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "description", "display_name_alternatives", "fields", "siblings", "ids", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Domain from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in fields (list)
|
||||
_items = []
|
||||
if self.fields:
|
||||
for _item_fields in self.fields:
|
||||
if _item_fields:
|
||||
_items.append(_item_fields.to_dict())
|
||||
_dict['fields'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in siblings (list)
|
||||
_items = []
|
||||
if self.siblings:
|
||||
for _item_siblings in self.siblings:
|
||||
if _item_siblings:
|
||||
_items.append(_item_siblings.to_dict())
|
||||
_dict['siblings'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Domain from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"description": obj.get("description"),
|
||||
"display_name_alternatives": obj.get("display_name_alternatives"),
|
||||
"fields": [DomainFieldsInner.from_dict(_item) for _item in obj["fields"]] if obj.get("fields") is not None else None,
|
||||
"siblings": [DomainFieldsInner.from_dict(_item) for _item in obj["siblings"]] if obj.get("siblings") is not None else None,
|
||||
"ids": DomainIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class DomainFieldsInner(BaseModel):
|
||||
"""
|
||||
DomainFieldsInner
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DomainFieldsInner from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of DomainFieldsInner from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class DomainIds(BaseModel):
|
||||
"""
|
||||
External identifiers:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
wikidata: Optional[StrictStr] = None
|
||||
wikipedia: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "wikidata", "wikipedia"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DomainIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of DomainIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": obj.get("openalex"),
|
||||
"wikidata": obj.get("wikidata"),
|
||||
"wikipedia": obj.get("wikipedia")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.domain import Domain
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class DomainsListResponse(BaseModel):
|
||||
"""
|
||||
DomainsListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Domain]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of DomainsListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of DomainsListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Domain.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Error(BaseModel):
|
||||
"""
|
||||
Error
|
||||
""" # noqa: E501
|
||||
error: Optional[StrictStr] = Field(default=None, description="Error type")
|
||||
message: Optional[StrictStr] = Field(default=None, description="Human-readable error message")
|
||||
__properties: ClassVar[List[str]] = ["error", "message"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Error from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Error from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"error": obj.get("error"),
|
||||
"message": obj.get("message")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.meta import Meta
|
||||
from inse.models.model_field import ModelField
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class FieldsListResponse(BaseModel):
|
||||
"""
|
||||
FieldsListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[ModelField]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of FieldsListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of FieldsListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [ModelField.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.author_counts_by_year_inner import AuthorCountsByYearInner
|
||||
from inse.models.funder_ids import FunderIds
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Funder(BaseModel):
|
||||
"""
|
||||
An organization that funds research
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this funder.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The primary name of the funder.")
|
||||
alternate_titles: Optional[List[StrictStr]] = Field(default=None, description="A list of alternate titles for this funder.")
|
||||
country_code: Optional[StrictStr] = Field(default=None, description="ISO two-letter country code where this funder is located.")
|
||||
description: Optional[StrictStr] = Field(default=None, description="A short description from Wikidata.")
|
||||
homepage_url: Optional[StrictStr] = Field(default=None, description="URL for this funder's primary homepage.")
|
||||
image_url: Optional[StrictStr] = Field(default=None, description="URL for an image representing this funder (usually from Wikimedia).")
|
||||
image_thumbnail_url: Optional[StrictStr] = Field(default=None, description="Smaller version of `image_url`.")
|
||||
grants_count: Optional[StrictInt] = Field(default=None, description="The number of grants linked to this funder.")
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works linked to this funder.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works linked to this funder.")
|
||||
ids: Optional[FunderIds] = None
|
||||
counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.")
|
||||
works_api_url: Optional[StrictStr] = None
|
||||
created_date: Optional[date] = Field(default=None, description="When this funder was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this funder was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "alternate_titles", "country_code", "description", "homepage_url", "image_url", "image_thumbnail_url", "grants_count", "works_count", "cited_by_count", "ids", "counts_by_year", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Funder from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in counts_by_year (list)
|
||||
_items = []
|
||||
if self.counts_by_year:
|
||||
for _item_counts_by_year in self.counts_by_year:
|
||||
if _item_counts_by_year:
|
||||
_items.append(_item_counts_by_year.to_dict())
|
||||
_dict['counts_by_year'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Funder from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"alternate_titles": obj.get("alternate_titles"),
|
||||
"country_code": obj.get("country_code"),
|
||||
"description": obj.get("description"),
|
||||
"homepage_url": obj.get("homepage_url"),
|
||||
"image_url": obj.get("image_url"),
|
||||
"image_thumbnail_url": obj.get("image_thumbnail_url"),
|
||||
"grants_count": obj.get("grants_count"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"ids": FunderIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"counts_by_year": [AuthorCountsByYearInner.from_dict(_item) for _item in obj["counts_by_year"]] if obj.get("counts_by_year") is not None else None,
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class FunderIds(BaseModel):
|
||||
"""
|
||||
External identifiers for this funder:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
ror: Optional[StrictStr] = None
|
||||
wikidata: Optional[StrictStr] = None
|
||||
crossref: Optional[StrictStr] = None
|
||||
doi: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "ror", "wikidata", "crossref", "doi"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of FunderIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of FunderIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": obj.get("openalex"),
|
||||
"ror": obj.get("ror"),
|
||||
"wikidata": obj.get("wikidata"),
|
||||
"crossref": obj.get("crossref"),
|
||||
"doi": obj.get("doi")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.funder import Funder
|
||||
from inse.models.group_by_result import GroupByResult
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class FundersListResponse(BaseModel):
|
||||
"""
|
||||
FundersListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Funder]] = None
|
||||
group_by: Optional[List[GroupByResult]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results", "group_by"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of FundersListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in group_by (list)
|
||||
_items = []
|
||||
if self.group_by:
|
||||
for _item_group_by in self.group_by:
|
||||
if _item_group_by:
|
||||
_items.append(_item_group_by.to_dict())
|
||||
_dict['group_by'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of FundersListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Funder.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None,
|
||||
"group_by": [GroupByResult.from_dict(_item) for _item in obj["group_by"]] if obj.get("group_by") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.get_changefile200_response_meta import GetChangefile200ResponseMeta
|
||||
from inse.models.get_changefile200_response_results_inner import GetChangefile200ResponseResultsInner
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class GetChangefile200Response(BaseModel):
|
||||
"""
|
||||
GetChangefile200Response
|
||||
""" # noqa: E501
|
||||
meta: Optional[GetChangefile200ResponseMeta] = None
|
||||
results: Optional[List[GetChangefile200ResponseResultsInner]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200Response from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200Response from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": GetChangefile200ResponseMeta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [GetChangefile200ResponseResultsInner.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class GetChangefile200ResponseMeta(BaseModel):
|
||||
"""
|
||||
GetChangefile200ResponseMeta
|
||||
""" # noqa: E501
|
||||
count: Optional[StrictInt] = Field(default=None, description="Number of entity types with changes")
|
||||
var_date: Optional[date] = Field(default=None, description="The changefile date", alias="date")
|
||||
__properties: ClassVar[List[str]] = ["count", "date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseMeta from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseMeta from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"count": obj.get("count"),
|
||||
"date": obj.get("date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.get_changefile200_response_results_inner_formats import GetChangefile200ResponseResultsInnerFormats
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class GetChangefile200ResponseResultsInner(BaseModel):
|
||||
"""
|
||||
GetChangefile200ResponseResultsInner
|
||||
""" # noqa: E501
|
||||
entity: Optional[StrictStr] = Field(default=None, description="The entity type (e.g., works, authors, institutions)")
|
||||
records: Optional[StrictInt] = Field(default=None, description="Number of created or modified records")
|
||||
formats: Optional[GetChangefile200ResponseResultsInnerFormats] = None
|
||||
__properties: ClassVar[List[str]] = ["entity", "records", "formats"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseResultsInner from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of formats
|
||||
if self.formats:
|
||||
_dict['formats'] = self.formats.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseResultsInner from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"entity": obj.get("entity"),
|
||||
"records": obj.get("records"),
|
||||
"formats": GetChangefile200ResponseResultsInnerFormats.from_dict(obj["formats"]) if obj.get("formats") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.get_changefile200_response_results_inner_formats_jsonl import GetChangefile200ResponseResultsInnerFormatsJsonl
|
||||
from inse.models.get_changefile200_response_results_inner_formats_parquet import GetChangefile200ResponseResultsInnerFormatsParquet
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class GetChangefile200ResponseResultsInnerFormats(BaseModel):
|
||||
"""
|
||||
GetChangefile200ResponseResultsInnerFormats
|
||||
""" # noqa: E501
|
||||
jsonl: Optional[GetChangefile200ResponseResultsInnerFormatsJsonl] = None
|
||||
parquet: Optional[GetChangefile200ResponseResultsInnerFormatsParquet] = None
|
||||
__properties: ClassVar[List[str]] = ["jsonl", "parquet"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseResultsInnerFormats from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of jsonl
|
||||
if self.jsonl:
|
||||
_dict['jsonl'] = self.jsonl.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of parquet
|
||||
if self.parquet:
|
||||
_dict['parquet'] = self.parquet.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseResultsInnerFormats from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"jsonl": GetChangefile200ResponseResultsInnerFormatsJsonl.from_dict(obj["jsonl"]) if obj.get("jsonl") is not None else None,
|
||||
"parquet": GetChangefile200ResponseResultsInnerFormatsParquet.from_dict(obj["parquet"]) if obj.get("parquet") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class GetChangefile200ResponseResultsInnerFormatsJsonl(BaseModel):
|
||||
"""
|
||||
GetChangefile200ResponseResultsInnerFormatsJsonl
|
||||
""" # noqa: E501
|
||||
size_bytes: Optional[StrictInt] = Field(default=None, description="File size in bytes")
|
||||
size_display: Optional[StrictStr] = Field(default=None, description="Human-readable file size")
|
||||
url: Optional[StrictStr] = Field(default=None, description="Download URL for gzipped JSONL file")
|
||||
__properties: ClassVar[List[str]] = ["size_bytes", "size_display", "url"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseResultsInnerFormatsJsonl from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseResultsInnerFormatsJsonl from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"size_bytes": obj.get("size_bytes"),
|
||||
"size_display": obj.get("size_display"),
|
||||
"url": obj.get("url")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
+93
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class GetChangefile200ResponseResultsInnerFormatsParquet(BaseModel):
|
||||
"""
|
||||
GetChangefile200ResponseResultsInnerFormatsParquet
|
||||
""" # noqa: E501
|
||||
size_bytes: Optional[StrictInt] = Field(default=None, description="File size in bytes")
|
||||
size_display: Optional[StrictStr] = Field(default=None, description="Human-readable file size")
|
||||
url: Optional[StrictStr] = Field(default=None, description="Download URL for Parquet file")
|
||||
__properties: ClassVar[List[str]] = ["size_bytes", "size_display", "url"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseResultsInnerFormatsParquet from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of GetChangefile200ResponseResultsInnerFormatsParquet from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"size_bytes": obj.get("size_bytes"),
|
||||
"size_display": obj.get("size_display"),
|
||||
"url": obj.get("url")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class GroupByResult(BaseModel):
|
||||
"""
|
||||
GroupByResult
|
||||
""" # noqa: E501
|
||||
key: Optional[StrictStr] = Field(default=None, description="The group key value")
|
||||
key_display_name: Optional[StrictStr] = Field(default=None, description="Human-readable name for the key")
|
||||
count: Optional[StrictInt] = Field(default=None, description="Number of results in this group")
|
||||
__properties: ClassVar[List[str]] = ["key", "key_display_name", "count"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of GroupByResult from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of GroupByResult from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"key": obj.get("key"),
|
||||
"key_display_name": obj.get("key_display_name"),
|
||||
"count": obj.get("count")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.author_counts_by_year_inner import AuthorCountsByYearInner
|
||||
from inse.models.author_summary_stats import AuthorSummaryStats
|
||||
from inse.models.institution_geo import InstitutionGeo
|
||||
from inse.models.institution_ids import InstitutionIds
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Institution(BaseModel):
|
||||
"""
|
||||
A university, research organization, or other affiliation
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this institution.")
|
||||
ror: Optional[StrictStr] = Field(default=None, description="The ROR ID for this institution. This is the Canonical External ID for institutions.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The primary name of the institution.")
|
||||
country_code: Optional[StrictStr] = Field(default=None, description="ISO two-letter country code where this institution is located.")
|
||||
type: Optional[StrictStr] = Field(default=None, description="The institution's primary type (ROR vocabulary): `Education`, `Healthcare`, `Company`, `Archive`, `Nonprofit`, `Government`, `Facility`, `Other`.")
|
||||
homepage_url: Optional[StrictStr] = Field(default=None, description="URL for the institution's primary homepage.")
|
||||
image_url: Optional[StrictStr] = Field(default=None, description="URL for an image representing this institution (usually from Wikimedia).")
|
||||
image_thumbnail_url: Optional[StrictStr] = Field(default=None, description="Smaller version of `image_url`.")
|
||||
display_name_acronyms: Optional[List[StrictStr]] = Field(default=None, description="Acronyms or initialisms for this institution.")
|
||||
display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Other names people may use for this institution.")
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works created by authors affiliated with this institution.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works from authors affiliated with this institution.")
|
||||
summary_stats: Optional[AuthorSummaryStats] = None
|
||||
geo: Optional[InstitutionGeo] = None
|
||||
lineage: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs including this institution and any parent institutions.")
|
||||
ids: Optional[InstitutionIds] = None
|
||||
counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that will get you a list of all works affiliated with this institution.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this institution was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this institution was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "ror", "display_name", "country_code", "type", "homepage_url", "image_url", "image_thumbnail_url", "display_name_acronyms", "display_name_alternatives", "works_count", "cited_by_count", "summary_stats", "geo", "lineage", "ids", "counts_by_year", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
@field_validator('type')
|
||||
def type_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in set(['education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other']):
|
||||
raise ValueError("must be one of enum values ('education', 'healthcare', 'company', 'archive', 'nonprofit', 'government', 'facility', 'other')")
|
||||
return value
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Institution from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of summary_stats
|
||||
if self.summary_stats:
|
||||
_dict['summary_stats'] = self.summary_stats.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of geo
|
||||
if self.geo:
|
||||
_dict['geo'] = self.geo.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in counts_by_year (list)
|
||||
_items = []
|
||||
if self.counts_by_year:
|
||||
for _item_counts_by_year in self.counts_by_year:
|
||||
if _item_counts_by_year:
|
||||
_items.append(_item_counts_by_year.to_dict())
|
||||
_dict['counts_by_year'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Institution from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"ror": obj.get("ror"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"country_code": obj.get("country_code"),
|
||||
"type": obj.get("type"),
|
||||
"homepage_url": obj.get("homepage_url"),
|
||||
"image_url": obj.get("image_url"),
|
||||
"image_thumbnail_url": obj.get("image_thumbnail_url"),
|
||||
"display_name_acronyms": obj.get("display_name_acronyms"),
|
||||
"display_name_alternatives": obj.get("display_name_alternatives"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"summary_stats": AuthorSummaryStats.from_dict(obj["summary_stats"]) if obj.get("summary_stats") is not None else None,
|
||||
"geo": InstitutionGeo.from_dict(obj["geo"]) if obj.get("geo") is not None else None,
|
||||
"lineage": obj.get("lineage"),
|
||||
"ids": InstitutionIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"counts_by_year": [AuthorCountsByYearInner.from_dict(_item) for _item in obj["counts_by_year"]] if obj.get("counts_by_year") is not None else None,
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class InstitutionGeo(BaseModel):
|
||||
"""
|
||||
Location information:
|
||||
""" # noqa: E501
|
||||
city: Optional[StrictStr] = None
|
||||
geonames_city_id: Optional[StrictStr] = None
|
||||
region: Optional[StrictStr] = None
|
||||
country_code: Optional[StrictStr] = None
|
||||
country: Optional[StrictStr] = None
|
||||
latitude: Optional[Union[StrictFloat, StrictInt]] = None
|
||||
longitude: Optional[Union[StrictFloat, StrictInt]] = None
|
||||
__properties: ClassVar[List[str]] = ["city", "geonames_city_id", "region", "country_code", "country", "latitude", "longitude"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionGeo from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionGeo from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"city": obj.get("city"),
|
||||
"geonames_city_id": obj.get("geonames_city_id"),
|
||||
"region": obj.get("region"),
|
||||
"country_code": obj.get("country_code"),
|
||||
"country": obj.get("country"),
|
||||
"latitude": obj.get("latitude"),
|
||||
"longitude": obj.get("longitude")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class InstitutionIds(BaseModel):
|
||||
"""
|
||||
External identifiers:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
ror: Optional[StrictStr] = None
|
||||
mag: Optional[StrictInt] = None
|
||||
grid: Optional[StrictStr] = None
|
||||
wikipedia: Optional[StrictStr] = None
|
||||
wikidata: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "ror", "mag", "grid", "wikipedia", "wikidata"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": obj.get("openalex"),
|
||||
"ror": obj.get("ror"),
|
||||
"mag": obj.get("mag"),
|
||||
"grid": obj.get("grid"),
|
||||
"wikipedia": obj.get("wikipedia"),
|
||||
"wikidata": obj.get("wikidata")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class InstitutionType(BaseModel):
|
||||
"""
|
||||
Type of institution
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
works_count: Optional[StrictInt] = None
|
||||
cited_by_count: Optional[StrictInt] = None
|
||||
works_api_url: Optional[StrictStr] = None
|
||||
created_date: Optional[date] = None
|
||||
updated_date: Optional[datetime] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionType from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionType from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.institution_type import InstitutionType
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class InstitutionTypesListResponse(BaseModel):
|
||||
"""
|
||||
InstitutionTypesListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[InstitutionType]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionTypesListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionTypesListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [InstitutionType.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.group_by_result import GroupByResult
|
||||
from inse.models.institution import Institution
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class InstitutionsListResponse(BaseModel):
|
||||
"""
|
||||
InstitutionsListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Institution]] = None
|
||||
group_by: Optional[List[GroupByResult]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results", "group_by"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionsListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in group_by (list)
|
||||
_items = []
|
||||
if self.group_by:
|
||||
for _item_group_by in self.group_by:
|
||||
if _item_group_by:
|
||||
_items.append(_item_group_by.to_dict())
|
||||
_dict['group_by'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of InstitutionsListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Institution.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None,
|
||||
"group_by": [GroupByResult.from_dict(_item) for _item in obj["group_by"]] if obj.get("group_by") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Keyword(BaseModel):
|
||||
"""
|
||||
A keyword identified from works' topics
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this keyword.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The English-language label of the keyword.")
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with this keyword.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="The total citations to works tagged with this keyword.")
|
||||
works_api_url: Optional[StrictStr] = None
|
||||
created_date: Optional[date] = Field(default=None, description="When this keyword was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this keyword was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Keyword from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Keyword from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.group_by_result import GroupByResult
|
||||
from inse.models.keyword import Keyword
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class KeywordsListResponse(BaseModel):
|
||||
"""
|
||||
KeywordsListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Keyword]] = None
|
||||
group_by: Optional[List[GroupByResult]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results", "group_by"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of KeywordsListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in group_by (list)
|
||||
_items = []
|
||||
if self.group_by:
|
||||
for _item_group_by in self.group_by:
|
||||
if _item_group_by:
|
||||
_items.append(_item_group_by.to_dict())
|
||||
_dict['group_by'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of KeywordsListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Keyword.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None,
|
||||
"group_by": [GroupByResult.from_dict(_item) for _item in obj["group_by"]] if obj.get("group_by") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Language(BaseModel):
|
||||
"""
|
||||
Language of scholarly works
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this language (uses ISO 639-1 codes).")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The name of the language.")
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works written in this language.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works in this language.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works in this language.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this language was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this language was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Language from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Language from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.language import Language
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class LanguagesListResponse(BaseModel):
|
||||
"""
|
||||
LanguagesListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Language]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of LanguagesListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of LanguagesListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Language.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,106 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class License(BaseModel):
|
||||
"""
|
||||
Open access license
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
url: Optional[StrictStr] = None
|
||||
description: Optional[StrictStr] = None
|
||||
works_count: Optional[StrictInt] = None
|
||||
cited_by_count: Optional[StrictInt] = None
|
||||
works_api_url: Optional[StrictStr] = None
|
||||
created_date: Optional[date] = None
|
||||
updated_date: Optional[datetime] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "url", "description", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of License from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of License from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"url": obj.get("url"),
|
||||
"description": obj.get("description"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.license import License
|
||||
from inse.models.meta import Meta
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class LicensesListResponse(BaseModel):
|
||||
"""
|
||||
LicensesListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[License]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of LicensesListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of LicensesListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [License.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.list_changefiles200_response_meta import ListChangefiles200ResponseMeta
|
||||
from inse.models.list_changefiles200_response_results_inner import ListChangefiles200ResponseResultsInner
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class ListChangefiles200Response(BaseModel):
|
||||
"""
|
||||
ListChangefiles200Response
|
||||
""" # noqa: E501
|
||||
meta: Optional[ListChangefiles200ResponseMeta] = None
|
||||
results: Optional[List[ListChangefiles200ResponseResultsInner]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ListChangefiles200Response from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of ListChangefiles200Response from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": ListChangefiles200ResponseMeta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [ListChangefiles200ResponseResultsInner.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,89 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class ListChangefiles200ResponseMeta(BaseModel):
|
||||
"""
|
||||
ListChangefiles200ResponseMeta
|
||||
""" # noqa: E501
|
||||
count: Optional[StrictInt] = Field(default=None, description="Number of available changefile dates")
|
||||
__properties: ClassVar[List[str]] = ["count"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ListChangefiles200ResponseMeta from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of ListChangefiles200ResponseMeta from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"count": obj.get("count")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class ListChangefiles200ResponseResultsInner(BaseModel):
|
||||
"""
|
||||
ListChangefiles200ResponseResultsInner
|
||||
""" # noqa: E501
|
||||
var_date: Optional[date] = Field(default=None, description="The changefile date (YYYY-MM-DD)", alias="date")
|
||||
url: Optional[StrictStr] = Field(default=None, description="URL to get details and download links for this date")
|
||||
__properties: ClassVar[List[str]] = ["date", "url"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ListChangefiles200ResponseResultsInner from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of ListChangefiles200ResponseResultsInner from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"date": obj.get("date"),
|
||||
"url": obj.get("url")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.dehydrated_source import DehydratedSource
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Location(BaseModel):
|
||||
"""
|
||||
Where a work is hosted
|
||||
""" # noqa: E501
|
||||
is_oa: Optional[StrictBool] = Field(default=None, description="Whether this location provides open access")
|
||||
landing_page_url: Optional[StrictStr] = Field(default=None, description="URL to the landing page")
|
||||
pdf_url: Optional[StrictStr] = Field(default=None, description="Direct URL to PDF")
|
||||
source: Optional[DehydratedSource] = Field(default=None, description="[Dehydrated source](/api-reference/sources#the-dehydratedsource-object)")
|
||||
license: Optional[StrictStr] = Field(default=None, description="The [license](/api-reference/licenses) (e.g., cc-by)")
|
||||
license_id: Optional[StrictStr] = None
|
||||
version: Optional[StrictStr] = Field(default=None, description="Version of the work at this location")
|
||||
is_accepted: Optional[StrictBool] = None
|
||||
is_published: Optional[StrictBool] = None
|
||||
__properties: ClassVar[List[str]] = ["is_oa", "landing_page_url", "pdf_url", "source", "license", "license_id", "version", "is_accepted", "is_published"]
|
||||
|
||||
@field_validator('version')
|
||||
def version_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in set(['publishedVersion', 'acceptedVersion', 'submittedVersion']):
|
||||
raise ValueError("must be one of enum values ('publishedVersion', 'acceptedVersion', 'submittedVersion')")
|
||||
return value
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Location from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of source
|
||||
if self.source:
|
||||
_dict['source'] = self.source.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Location from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"is_oa": obj.get("is_oa"),
|
||||
"landing_page_url": obj.get("landing_page_url"),
|
||||
"pdf_url": obj.get("pdf_url"),
|
||||
"source": DehydratedSource.from_dict(obj["source"]) if obj.get("source") is not None else None,
|
||||
"license": obj.get("license"),
|
||||
"license_id": obj.get("license_id"),
|
||||
"version": obj.get("version"),
|
||||
"is_accepted": obj.get("is_accepted"),
|
||||
"is_published": obj.get("is_published")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,101 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Meta(BaseModel):
|
||||
"""
|
||||
Metadata about the query results
|
||||
""" # noqa: E501
|
||||
count: Optional[StrictInt] = Field(default=None, description="Total number of results matching the query")
|
||||
db_response_time_ms: Optional[StrictInt] = Field(default=None, description="Database response time in milliseconds")
|
||||
page: Optional[StrictInt] = Field(default=None, description="Current page number")
|
||||
per_page: Optional[StrictInt] = Field(default=None, description="Number of results per page")
|
||||
next_cursor: Optional[StrictStr] = Field(default=None, description="Cursor for the next page (when using cursor pagination)")
|
||||
groups_count: Optional[StrictInt] = Field(default=None, description="Number of groups when using group_by")
|
||||
cost_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Cost of this request in USD")
|
||||
__properties: ClassVar[List[str]] = ["count", "db_response_time_ms", "page", "per_page", "next_cursor", "groups_count", "cost_usd"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Meta from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Meta from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"count": obj.get("count"),
|
||||
"db_response_time_ms": obj.get("db_response_time_ms"),
|
||||
"page": obj.get("page"),
|
||||
"per_page": obj.get("per_page"),
|
||||
"next_cursor": obj.get("next_cursor"),
|
||||
"groups_count": obj.get("groups_count"),
|
||||
"cost_usd": obj.get("cost_usd")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.domain_fields_inner import DomainFieldsInner
|
||||
from inse.models.domain_ids import DomainIds
|
||||
from inse.models.work_topic_domain import WorkTopicDomain
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class ModelField(BaseModel):
|
||||
"""
|
||||
Second-level category in the topic hierarchy (26 total)
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this field.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The English-language label of the field.")
|
||||
description: Optional[StrictStr] = Field(default=None, description="A description of this field.")
|
||||
display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this field.")
|
||||
domain: Optional[WorkTopicDomain] = None
|
||||
subfields: Optional[List[DomainFieldsInner]] = Field(default=None, description="The subfields within this field. Each object has `id` and `display_name`.")
|
||||
siblings: Optional[List[DomainFieldsInner]] = Field(default=None, description="Other fields at the same level. Each object has `id` and `display_name`.")
|
||||
ids: Optional[DomainIds] = None
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with topics in this field.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works in this field.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this field.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this field was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this field was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "description", "display_name_alternatives", "domain", "subfields", "siblings", "ids", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of ModelField from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of domain
|
||||
if self.domain:
|
||||
_dict['domain'] = self.domain.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in subfields (list)
|
||||
_items = []
|
||||
if self.subfields:
|
||||
for _item_subfields in self.subfields:
|
||||
if _item_subfields:
|
||||
_items.append(_item_subfields.to_dict())
|
||||
_dict['subfields'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in siblings (list)
|
||||
_items = []
|
||||
if self.siblings:
|
||||
for _item_siblings in self.siblings:
|
||||
if _item_siblings:
|
||||
_items.append(_item_siblings.to_dict())
|
||||
_dict['siblings'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of ModelField from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"description": obj.get("description"),
|
||||
"display_name_alternatives": obj.get("display_name_alternatives"),
|
||||
"domain": WorkTopicDomain.from_dict(obj["domain"]) if obj.get("domain") is not None else None,
|
||||
"subfields": [DomainFieldsInner.from_dict(_item) for _item in obj["subfields"]] if obj.get("subfields") is not None else None,
|
||||
"siblings": [DomainFieldsInner.from_dict(_item) for _item in obj["siblings"]] if obj.get("siblings") is not None else None,
|
||||
"ids": DomainIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class OpenAccess(BaseModel):
|
||||
"""
|
||||
Open access information
|
||||
""" # noqa: E501
|
||||
is_oa: Optional[StrictBool] = Field(default=None, description="Whether this work is open access")
|
||||
oa_status: Optional[StrictStr] = Field(default=None, description="Open access status")
|
||||
oa_url: Optional[StrictStr] = Field(default=None, description="Best open access URL")
|
||||
any_repository_has_fulltext: Optional[StrictBool] = Field(default=None, description="Whether any repository has the full text")
|
||||
__properties: ClassVar[List[str]] = ["is_oa", "oa_status", "oa_url", "any_repository_has_fulltext"]
|
||||
|
||||
@field_validator('oa_status')
|
||||
def oa_status_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in set(['diamond', 'gold', 'hybrid', 'bronze', 'green', 'closed']):
|
||||
raise ValueError("must be one of enum values ('diamond', 'gold', 'hybrid', 'bronze', 'green', 'closed')")
|
||||
return value
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of OpenAccess from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of OpenAccess from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"is_oa": obj.get("is_oa"),
|
||||
"oa_status": obj.get("oa_status"),
|
||||
"oa_url": obj.get("oa_url"),
|
||||
"any_repository_has_fulltext": obj.get("any_repository_has_fulltext")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,132 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.author_counts_by_year_inner import AuthorCountsByYearInner
|
||||
from inse.models.publisher_ids import PublisherIds
|
||||
from inse.models.publisher_parent_publisher import PublisherParentPublisher
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Publisher(BaseModel):
|
||||
"""
|
||||
An organization that publishes scholarly works
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this publisher.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The primary name of the publisher.")
|
||||
alternate_titles: Optional[List[StrictStr]] = Field(default=None, description="Alternate titles for this publisher (including translations).")
|
||||
country_codes: Optional[List[StrictStr]] = Field(default=None, description="ISO two-letter country codes where the publisher is primarily located.")
|
||||
hierarchy_level: Optional[StrictInt] = Field(default=None, description="The hierarchy level for this publisher. Level 0 has no parent publishers.")
|
||||
parent_publisher: Optional[PublisherParentPublisher] = None
|
||||
lineage: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs including this publisher and any parent publishers.")
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works published by this publisher.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works linked to this publisher.")
|
||||
sources_api_url: Optional[StrictStr] = Field(default=None, description="A URL that will get you a list of all sources published by this publisher.")
|
||||
ids: Optional[PublisherIds] = None
|
||||
counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this publisher was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this publisher was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "alternate_titles", "country_codes", "hierarchy_level", "parent_publisher", "lineage", "works_count", "cited_by_count", "sources_api_url", "ids", "counts_by_year", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Publisher from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of parent_publisher
|
||||
if self.parent_publisher:
|
||||
_dict['parent_publisher'] = self.parent_publisher.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in counts_by_year (list)
|
||||
_items = []
|
||||
if self.counts_by_year:
|
||||
for _item_counts_by_year in self.counts_by_year:
|
||||
if _item_counts_by_year:
|
||||
_items.append(_item_counts_by_year.to_dict())
|
||||
_dict['counts_by_year'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Publisher from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"alternate_titles": obj.get("alternate_titles"),
|
||||
"country_codes": obj.get("country_codes"),
|
||||
"hierarchy_level": obj.get("hierarchy_level"),
|
||||
"parent_publisher": PublisherParentPublisher.from_dict(obj["parent_publisher"]) if obj.get("parent_publisher") is not None else None,
|
||||
"lineage": obj.get("lineage"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"sources_api_url": obj.get("sources_api_url"),
|
||||
"ids": PublisherIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"counts_by_year": [AuthorCountsByYearInner.from_dict(_item) for _item in obj["counts_by_year"]] if obj.get("counts_by_year") is not None else None,
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class PublisherIds(BaseModel):
|
||||
"""
|
||||
External identifiers:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
ror: Optional[StrictStr] = None
|
||||
wikidata: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "ror", "wikidata"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of PublisherIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of PublisherIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": obj.get("openalex"),
|
||||
"ror": obj.get("ror"),
|
||||
"wikidata": obj.get("wikidata")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class PublisherParentPublisher(BaseModel):
|
||||
"""
|
||||
OpenAlex ID of the direct parent publisher. Null if `hierarchy_level` is 0.
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of PublisherParentPublisher from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of PublisherParentPublisher from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.group_by_result import GroupByResult
|
||||
from inse.models.meta import Meta
|
||||
from inse.models.publisher import Publisher
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class PublishersListResponse(BaseModel):
|
||||
"""
|
||||
PublishersListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Publisher]] = None
|
||||
group_by: Optional[List[GroupByResult]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results", "group_by"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of PublishersListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in group_by (list)
|
||||
_items = []
|
||||
if self.group_by:
|
||||
for _item_group_by in self.group_by:
|
||||
if _item_group_by:
|
||||
_items.append(_item_group_by.to_dict())
|
||||
_dict['group_by'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of PublishersListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Publisher.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None,
|
||||
"group_by": [GroupByResult.from_dict(_item) for _item in obj["group_by"]] if obj.get("group_by") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,95 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.rate_limit_response_rate_limit import RateLimitResponseRateLimit
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class RateLimitResponse(BaseModel):
|
||||
"""
|
||||
RateLimitResponse
|
||||
""" # noqa: E501
|
||||
api_key: Optional[StrictStr] = None
|
||||
rate_limit: Optional[RateLimitResponseRateLimit] = None
|
||||
__properties: ClassVar[List[str]] = ["api_key", "rate_limit"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of RateLimitResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of rate_limit
|
||||
if self.rate_limit:
|
||||
_dict['rate_limit'] = self.rate_limit.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of RateLimitResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"api_key": obj.get("api_key"),
|
||||
"rate_limit": RateLimitResponseRateLimit.from_dict(obj["rate_limit"]) if obj.get("rate_limit") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,118 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictFloat, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
from inse.models.rate_limit_response_rate_limit_endpoint_costs_usd import RateLimitResponseRateLimitEndpointCostsUsd
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class RateLimitResponseRateLimit(BaseModel):
|
||||
"""
|
||||
RateLimitResponseRateLimit
|
||||
""" # noqa: E501
|
||||
daily_budget_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Your daily usage allowance in USD")
|
||||
daily_used_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Amount used today in USD")
|
||||
daily_remaining_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Remaining daily allowance in USD")
|
||||
prepaid_balance_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Total prepaid balance in USD")
|
||||
prepaid_remaining_usd: Optional[Union[StrictFloat, StrictInt]] = Field(default=None, description="Remaining prepaid balance in USD")
|
||||
prepaid_expires_at: Optional[datetime] = Field(default=None, description="When prepaid balance expires")
|
||||
resets_at: Optional[datetime] = None
|
||||
resets_in_seconds: Optional[StrictInt] = None
|
||||
endpoint_costs_usd: Optional[RateLimitResponseRateLimitEndpointCostsUsd] = None
|
||||
credits_limit: Optional[StrictInt] = Field(default=None, description="Deprecated. Use daily_budget_usd instead.")
|
||||
credits_used: Optional[StrictInt] = Field(default=None, description="Deprecated. Use daily_used_usd instead.")
|
||||
credits_remaining: Optional[StrictInt] = Field(default=None, description="Deprecated. Use daily_remaining_usd instead.")
|
||||
credit_costs: Optional[Dict[str, Any]] = Field(default=None, description="Deprecated. Use endpoint_costs_usd instead.")
|
||||
__properties: ClassVar[List[str]] = ["daily_budget_usd", "daily_used_usd", "daily_remaining_usd", "prepaid_balance_usd", "prepaid_remaining_usd", "prepaid_expires_at", "resets_at", "resets_in_seconds", "endpoint_costs_usd", "credits_limit", "credits_used", "credits_remaining", "credit_costs"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of RateLimitResponseRateLimit from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of endpoint_costs_usd
|
||||
if self.endpoint_costs_usd:
|
||||
_dict['endpoint_costs_usd'] = self.endpoint_costs_usd.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of RateLimitResponseRateLimit from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"daily_budget_usd": obj.get("daily_budget_usd"),
|
||||
"daily_used_usd": obj.get("daily_used_usd"),
|
||||
"daily_remaining_usd": obj.get("daily_remaining_usd"),
|
||||
"prepaid_balance_usd": obj.get("prepaid_balance_usd"),
|
||||
"prepaid_remaining_usd": obj.get("prepaid_remaining_usd"),
|
||||
"prepaid_expires_at": obj.get("prepaid_expires_at"),
|
||||
"resets_at": obj.get("resets_at"),
|
||||
"resets_in_seconds": obj.get("resets_in_seconds"),
|
||||
"endpoint_costs_usd": RateLimitResponseRateLimitEndpointCostsUsd.from_dict(obj["endpoint_costs_usd"]) if obj.get("endpoint_costs_usd") is not None else None,
|
||||
"credits_limit": obj.get("credits_limit"),
|
||||
"credits_used": obj.get("credits_used"),
|
||||
"credits_remaining": obj.get("credits_remaining"),
|
||||
"credit_costs": obj.get("credit_costs")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictFloat, StrictInt
|
||||
from typing import Any, ClassVar, Dict, List, Optional, Union
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class RateLimitResponseRateLimitEndpointCostsUsd(BaseModel):
|
||||
"""
|
||||
Cost per request in USD for each endpoint type
|
||||
""" # noqa: E501
|
||||
singleton: Optional[Union[StrictFloat, StrictInt]] = None
|
||||
list: Optional[Union[StrictFloat, StrictInt]] = None
|
||||
search: Optional[Union[StrictFloat, StrictInt]] = None
|
||||
content: Optional[Union[StrictFloat, StrictInt]] = None
|
||||
semantic: Optional[Union[StrictFloat, StrictInt]] = None
|
||||
text: Optional[Union[StrictFloat, StrictInt]] = None
|
||||
__properties: ClassVar[List[str]] = ["singleton", "list", "search", "content", "semantic", "text"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of RateLimitResponseRateLimitEndpointCostsUsd from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of RateLimitResponseRateLimitEndpointCostsUsd from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"singleton": obj.get("singleton"),
|
||||
"list": obj.get("list"),
|
||||
"search": obj.get("search"),
|
||||
"content": obj.get("content"),
|
||||
"semantic": obj.get("semantic"),
|
||||
"text": obj.get("text")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.sdg_ids import SdgIds
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Sdg(BaseModel):
|
||||
"""
|
||||
UN Sustainable Development Goal (17 total)
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this SDG.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The name of the SDG.")
|
||||
description: Optional[StrictStr] = Field(default=None, description="The official UN description of this goal.")
|
||||
ids: Optional[SdgIds] = None
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with this SDG.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works tagged with this SDG.")
|
||||
image_url: Optional[StrictStr] = Field(default=None, description="URL to the official SDG icon image.")
|
||||
image_thumbnail_url: Optional[StrictStr] = Field(default=None, description="Smaller version of `image_url`.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this SDG.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this SDG was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this SDG was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "description", "ids", "works_count", "cited_by_count", "image_url", "image_thumbnail_url", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Sdg from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Sdg from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"description": obj.get("description"),
|
||||
"ids": SdgIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"image_url": obj.get("image_url"),
|
||||
"image_thumbnail_url": obj.get("image_thumbnail_url"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class SdgIds(BaseModel):
|
||||
"""
|
||||
External identifiers:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
un: Optional[StrictStr] = None
|
||||
wikidata: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "un", "wikidata"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SdgIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of SdgIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": obj.get("openalex"),
|
||||
"un": obj.get("un"),
|
||||
"wikidata": obj.get("wikidata")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.meta import Meta
|
||||
from inse.models.sdg import Sdg
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class SdgsListResponse(BaseModel):
|
||||
"""
|
||||
SdgsListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Sdg]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SdgsListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of SdgsListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Sdg.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,154 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictBool, StrictInt, StrictStr, field_validator
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.author_counts_by_year_inner import AuthorCountsByYearInner
|
||||
from inse.models.author_summary_stats import AuthorSummaryStats
|
||||
from inse.models.source_ids import SourceIds
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Source(BaseModel):
|
||||
"""
|
||||
A journal, repository, or other venue for scholarly works
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this source.")
|
||||
issn_l: Optional[StrictStr] = Field(default=None, description="The ISSN-L (linking ISSN) for this source. This is the Canonical External ID for sources.")
|
||||
issn: Optional[List[StrictStr]] = Field(default=None, description="All ISSNs used by this source. Many publications have multiple ISSNs.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The name of the source.")
|
||||
type: Optional[StrictStr] = Field(default=None, description="The type of source: `journal`, `repository`, `conference`, `ebook platform`, `book series`, `metadata`, or `other`.")
|
||||
host_organization: Optional[StrictStr] = Field(default=None, description="The host organization as an OpenAlex ID. This will be an Institution ID if the source is a repository, or a Publisher ID if it's a journal/conference.")
|
||||
host_organization_name: Optional[StrictStr] = Field(default=None, description="The display_name of the host organization.")
|
||||
host_organization_lineage: Optional[List[StrictStr]] = Field(default=None, description="OpenAlex IDs of parent publishers (only for publisher-hosted sources).")
|
||||
is_oa: Optional[StrictBool] = Field(default=None, description="Whether this is currently a fully open-access source.")
|
||||
is_in_doaj: Optional[StrictBool] = Field(default=None, description="Whether this journal is listed in the Directory of Open Access Journals.")
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works this source hosts.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works hosted in this source.")
|
||||
summary_stats: Optional[AuthorSummaryStats] = None
|
||||
apc_usd: Optional[StrictInt] = Field(default=None, description="The source's article processing charge in USD.")
|
||||
homepage_url: Optional[StrictStr] = Field(default=None, description="The homepage URL for this source.")
|
||||
ids: Optional[SourceIds] = None
|
||||
counts_by_year: Optional[List[AuthorCountsByYearInner]] = Field(default=None, description="`works_count` and `cited_by_count` for each of the last ten years.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that will get you a list of all this source's works.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this source was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this source was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "issn_l", "issn", "display_name", "type", "host_organization", "host_organization_name", "host_organization_lineage", "is_oa", "is_in_doaj", "works_count", "cited_by_count", "summary_stats", "apc_usd", "homepage_url", "ids", "counts_by_year", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
@field_validator('type')
|
||||
def type_validate_enum(cls, value):
|
||||
"""Validates the enum"""
|
||||
if value is None:
|
||||
return value
|
||||
|
||||
if value not in set(['journal', 'repository', 'conference', 'ebook platform', 'book series']):
|
||||
raise ValueError("must be one of enum values ('journal', 'repository', 'conference', 'ebook platform', 'book series')")
|
||||
return value
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Source from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of summary_stats
|
||||
if self.summary_stats:
|
||||
_dict['summary_stats'] = self.summary_stats.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in counts_by_year (list)
|
||||
_items = []
|
||||
if self.counts_by_year:
|
||||
for _item_counts_by_year in self.counts_by_year:
|
||||
if _item_counts_by_year:
|
||||
_items.append(_item_counts_by_year.to_dict())
|
||||
_dict['counts_by_year'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Source from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"issn_l": obj.get("issn_l"),
|
||||
"issn": obj.get("issn"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"type": obj.get("type"),
|
||||
"host_organization": obj.get("host_organization"),
|
||||
"host_organization_name": obj.get("host_organization_name"),
|
||||
"host_organization_lineage": obj.get("host_organization_lineage"),
|
||||
"is_oa": obj.get("is_oa"),
|
||||
"is_in_doaj": obj.get("is_in_doaj"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"summary_stats": AuthorSummaryStats.from_dict(obj["summary_stats"]) if obj.get("summary_stats") is not None else None,
|
||||
"apc_usd": obj.get("apc_usd"),
|
||||
"homepage_url": obj.get("homepage_url"),
|
||||
"ids": SourceIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"counts_by_year": [AuthorCountsByYearInner.from_dict(_item) for _item in obj["counts_by_year"]] if obj.get("counts_by_year") is not None else None,
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class SourceIds(BaseModel):
|
||||
"""
|
||||
External identifiers:
|
||||
""" # noqa: E501
|
||||
openalex: Optional[StrictStr] = None
|
||||
issn_l: Optional[StrictStr] = None
|
||||
issn: Optional[List[StrictStr]] = None
|
||||
mag: Optional[StrictInt] = None
|
||||
wikidata: Optional[StrictStr] = None
|
||||
fatcat: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["openalex", "issn_l", "issn", "mag", "wikidata", "fatcat"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SourceIds from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of SourceIds from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"openalex": obj.get("openalex"),
|
||||
"issn_l": obj.get("issn_l"),
|
||||
"issn": obj.get("issn"),
|
||||
"mag": obj.get("mag"),
|
||||
"wikidata": obj.get("wikidata"),
|
||||
"fatcat": obj.get("fatcat")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,102 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class SourceType(BaseModel):
|
||||
"""
|
||||
Type of source
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
works_count: Optional[StrictInt] = None
|
||||
cited_by_count: Optional[StrictInt] = None
|
||||
works_api_url: Optional[StrictStr] = None
|
||||
created_date: Optional[date] = None
|
||||
updated_date: Optional[datetime] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SourceType from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of SourceType from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,103 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.meta import Meta
|
||||
from inse.models.source_type import SourceType
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class SourceTypesListResponse(BaseModel):
|
||||
"""
|
||||
SourceTypesListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[SourceType]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SourceTypesListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of SourceTypesListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [SourceType.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,113 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.group_by_result import GroupByResult
|
||||
from inse.models.meta import Meta
|
||||
from inse.models.source import Source
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class SourcesListResponse(BaseModel):
|
||||
"""
|
||||
SourcesListResponse
|
||||
""" # noqa: E501
|
||||
meta: Optional[Meta] = None
|
||||
results: Optional[List[Source]] = None
|
||||
group_by: Optional[List[GroupByResult]] = None
|
||||
__properties: ClassVar[List[str]] = ["meta", "results", "group_by"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SourcesListResponse from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of meta
|
||||
if self.meta:
|
||||
_dict['meta'] = self.meta.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in results (list)
|
||||
_items = []
|
||||
if self.results:
|
||||
for _item_results in self.results:
|
||||
if _item_results:
|
||||
_items.append(_item_results.to_dict())
|
||||
_dict['results'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in group_by (list)
|
||||
_items = []
|
||||
if self.group_by:
|
||||
for _item_group_by in self.group_by:
|
||||
if _item_group_by:
|
||||
_items.append(_item_group_by.to_dict())
|
||||
_dict['group_by'] = _items
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of SourcesListResponse from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"meta": Meta.from_dict(obj["meta"]) if obj.get("meta") is not None else None,
|
||||
"results": [Source.from_dict(_item) for _item in obj["results"]] if obj.get("results") is not None else None,
|
||||
"group_by": [GroupByResult.from_dict(_item) for _item in obj["group_by"]] if obj.get("group_by") is not None else None
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,143 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from datetime import date, datetime
|
||||
from pydantic import BaseModel, ConfigDict, Field, StrictInt, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from inse.models.domain_fields_inner import DomainFieldsInner
|
||||
from inse.models.domain_ids import DomainIds
|
||||
from inse.models.subfield_domain import SubfieldDomain
|
||||
from inse.models.subfield_field import SubfieldField
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class Subfield(BaseModel):
|
||||
"""
|
||||
Third-level category in the topic hierarchy (254 total)
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = Field(default=None, description="The OpenAlex ID for this subfield.")
|
||||
display_name: Optional[StrictStr] = Field(default=None, description="The English-language label of the subfield.")
|
||||
description: Optional[StrictStr] = Field(default=None, description="A description of this subfield.")
|
||||
display_name_alternatives: Optional[List[StrictStr]] = Field(default=None, description="Alternate names for this subfield.")
|
||||
var_field: Optional[SubfieldField] = Field(default=None, alias="field")
|
||||
domain: Optional[SubfieldDomain] = None
|
||||
topics: Optional[List[DomainFieldsInner]] = Field(default=None, description="The topics within this subfield. Each object has `id` and `display_name`.")
|
||||
siblings: Optional[List[DomainFieldsInner]] = Field(default=None, description="Other subfields at the same level (across all fields). Each object has `id` and `display_name`.")
|
||||
ids: Optional[DomainIds] = None
|
||||
works_count: Optional[StrictInt] = Field(default=None, description="The number of works tagged with topics in this subfield.")
|
||||
cited_by_count: Optional[StrictInt] = Field(default=None, description="Total citations to works in this subfield.")
|
||||
works_api_url: Optional[StrictStr] = Field(default=None, description="A URL that returns all works tagged with this subfield.")
|
||||
created_date: Optional[date] = Field(default=None, description="When this subfield was added to OpenAlex (ISO 8601 date).")
|
||||
updated_date: Optional[datetime] = Field(default=None, description="When this subfield was last updated (ISO 8601 datetime).")
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name", "description", "display_name_alternatives", "field", "domain", "topics", "siblings", "ids", "works_count", "cited_by_count", "works_api_url", "created_date", "updated_date"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of Subfield from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
# override the default output from pydantic by calling `to_dict()` of var_field
|
||||
if self.var_field:
|
||||
_dict['field'] = self.var_field.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of domain
|
||||
if self.domain:
|
||||
_dict['domain'] = self.domain.to_dict()
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in topics (list)
|
||||
_items = []
|
||||
if self.topics:
|
||||
for _item_topics in self.topics:
|
||||
if _item_topics:
|
||||
_items.append(_item_topics.to_dict())
|
||||
_dict['topics'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of each item in siblings (list)
|
||||
_items = []
|
||||
if self.siblings:
|
||||
for _item_siblings in self.siblings:
|
||||
if _item_siblings:
|
||||
_items.append(_item_siblings.to_dict())
|
||||
_dict['siblings'] = _items
|
||||
# override the default output from pydantic by calling `to_dict()` of ids
|
||||
if self.ids:
|
||||
_dict['ids'] = self.ids.to_dict()
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of Subfield from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name"),
|
||||
"description": obj.get("description"),
|
||||
"display_name_alternatives": obj.get("display_name_alternatives"),
|
||||
"field": SubfieldField.from_dict(obj["field"]) if obj.get("field") is not None else None,
|
||||
"domain": SubfieldDomain.from_dict(obj["domain"]) if obj.get("domain") is not None else None,
|
||||
"topics": [DomainFieldsInner.from_dict(_item) for _item in obj["topics"]] if obj.get("topics") is not None else None,
|
||||
"siblings": [DomainFieldsInner.from_dict(_item) for _item in obj["siblings"]] if obj.get("siblings") is not None else None,
|
||||
"ids": DomainIds.from_dict(obj["ids"]) if obj.get("ids") is not None else None,
|
||||
"works_count": obj.get("works_count"),
|
||||
"cited_by_count": obj.get("cited_by_count"),
|
||||
"works_api_url": obj.get("works_api_url"),
|
||||
"created_date": obj.get("created_date"),
|
||||
"updated_date": obj.get("updated_date")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class SubfieldDomain(BaseModel):
|
||||
"""
|
||||
The domain containing this subfield (top level of hierarchy).
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SubfieldDomain from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of SubfieldDomain from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
@@ -0,0 +1,91 @@
|
||||
# coding: utf-8
|
||||
|
||||
"""
|
||||
OpenAlex API
|
||||
|
||||
The OpenAlex API provides access to a comprehensive catalog of scholarly works, authors, sources, institutions, topics, keywords, publishers, and funders. OpenAlex indexes over 250 million scholarly works.
|
||||
|
||||
The version of the OpenAPI document: 1.0.0
|
||||
Contact: support@openalex.org
|
||||
Generated by OpenAPI Generator (https://openapi-generator.tech)
|
||||
|
||||
Do not edit the class manually.
|
||||
""" # noqa: E501
|
||||
|
||||
|
||||
from __future__ import annotations
|
||||
import pprint
|
||||
import re # noqa: F401
|
||||
import json
|
||||
|
||||
from pydantic import BaseModel, ConfigDict, StrictStr
|
||||
from typing import Any, ClassVar, Dict, List, Optional
|
||||
from typing import Optional, Set
|
||||
from typing_extensions import Self
|
||||
from pydantic_core import to_jsonable_python
|
||||
|
||||
class SubfieldField(BaseModel):
|
||||
"""
|
||||
The field containing this subfield (parent level).
|
||||
""" # noqa: E501
|
||||
id: Optional[StrictStr] = None
|
||||
display_name: Optional[StrictStr] = None
|
||||
__properties: ClassVar[List[str]] = ["id", "display_name"]
|
||||
|
||||
model_config = ConfigDict(
|
||||
validate_by_name=True,
|
||||
validate_by_alias=True,
|
||||
validate_assignment=True,
|
||||
protected_namespaces=(),
|
||||
)
|
||||
|
||||
|
||||
def to_str(self) -> str:
|
||||
"""Returns the string representation of the model using alias"""
|
||||
return pprint.pformat(self.model_dump(by_alias=True))
|
||||
|
||||
def to_json(self) -> str:
|
||||
"""Returns the JSON representation of the model using alias"""
|
||||
return json.dumps(to_jsonable_python(self.to_dict()))
|
||||
|
||||
@classmethod
|
||||
def from_json(cls, json_str: str) -> Optional[Self]:
|
||||
"""Create an instance of SubfieldField from a JSON string"""
|
||||
return cls.from_dict(json.loads(json_str))
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
"""Return the dictionary representation of the model using alias.
|
||||
|
||||
This has the following differences from calling pydantic's
|
||||
`self.model_dump(by_alias=True)`:
|
||||
|
||||
* `None` is only added to the output dict for nullable fields that
|
||||
were set at model initialization. Other fields with value `None`
|
||||
are ignored.
|
||||
"""
|
||||
excluded_fields: Set[str] = set([
|
||||
])
|
||||
|
||||
_dict = self.model_dump(
|
||||
by_alias=True,
|
||||
exclude=excluded_fields,
|
||||
exclude_none=True,
|
||||
)
|
||||
return _dict
|
||||
|
||||
@classmethod
|
||||
def from_dict(cls, obj: Optional[Dict[str, Any]]) -> Optional[Self]:
|
||||
"""Create an instance of SubfieldField from a dict"""
|
||||
if obj is None:
|
||||
return None
|
||||
|
||||
if not isinstance(obj, dict):
|
||||
return cls.model_validate(obj)
|
||||
|
||||
_obj = cls.model_validate({
|
||||
"id": obj.get("id"),
|
||||
"display_name": obj.get("display_name")
|
||||
})
|
||||
return _obj
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user