diff --git a/atproto/cid/__init__.py b/atproto/cid/__init__.py index 3230251f..9451721d 100644 --- a/atproto/cid/__init__.py +++ b/atproto/cid/__init__.py @@ -4,6 +4,7 @@ # CID = _CID + class CID(BaseModel): def encode(self, *_, **__): ... diff --git a/atproto/codegen/__init__.py b/atproto/codegen/__init__.py index 18183cba..0baad0d5 100644 --- a/atproto/codegen/__init__.py +++ b/atproto/codegen/__init__.py @@ -3,6 +3,7 @@ import typing as t from pathlib import Path +from atproto.exceptions import InvalidNsidError from atproto.nsid import NSID _DISCLAIMER_LINES = [ @@ -108,3 +109,35 @@ def capitalize_first_symbol(string: str) -> str: return ''.join(chars) return string + + +def get_def_model_name(method_name: str) -> str: + return f'{capitalize_first_symbol(method_name)}' + + +def get_model_path(nsid: NSID, method_name: str) -> str: + return f'models.{get_import_path(nsid)}.{get_def_model_name(method_name)}' + + +def _resolve_nsid_ref(nsid: NSID, ref: str, *, local: bool = False) -> t.Tuple[str, str]: + """Returns the path to the model and model name""" + if '#' in ref: + ref_nsid_str, def_name = ref.split('#', 1) + def_name = get_def_model_name(def_name) + + try: + ref_nsid = NSID.from_str(ref_nsid_str) + return get_model_path(ref_nsid, def_name), def_name + except InvalidNsidError: + if local: + return def_name, def_name + return get_model_path(nsid, def_name), def_name + else: + ref_nsid = NSID.from_str(ref) + def_name = get_def_model_name(nsid.name) + + if local: + return def_name, def_name + + # FIXME(MarshalX): Is it works well? ;d + return get_model_path(ref_nsid, 'Main'), def_name diff --git a/atproto/codegen/models/builder.py b/atproto/codegen/models/builder.py index e261665a..e511954a 100644 --- a/atproto/codegen/models/builder.py +++ b/atproto/codegen/models/builder.py @@ -112,18 +112,9 @@ def build_record_models() -> BuiltRecordModels: return _build_nsid_to_defs_map(lexicon_parse_dir(lexicon_dir.get()), _LEX_DEF_TYPES_FOR_RECORDS) -BuiltRefsModels = t.Dict[NSID, t.Dict[str, t.Union[models.LexXrpcQuery, models.LexXrpcProcedure]]] - - -def build_refs_models() -> BuiltRefsModels: - _LEX_DEF_TYPES_FOR_REFS = {models.LexDefinitionType.QUERY, models.LexDefinitionType.PROCEDURE} - return _build_nsid_to_defs_map(lexicon_parse_dir(lexicon_dir.get()), _LEX_DEF_TYPES_FOR_REFS) - - if __name__ == '__main__': build_params_models() build_data_models() build_response_models() build_def_models() build_record_models() - build_refs_models() diff --git a/atproto/codegen/models/generator.py b/atproto/codegen/models/generator.py index 48f04ad5..b771b9df 100644 --- a/atproto/codegen/models/generator.py +++ b/atproto/codegen/models/generator.py @@ -8,10 +8,11 @@ INPUT_MODEL, OUTPUT_MODEL, PARAMS_MODEL, + _resolve_nsid_ref, append_code, - capitalize_first_symbol, format_code, gen_description_by_camel_case_name, + get_def_model_name, get_file_path_parts, get_import_path, join_code, @@ -19,7 +20,6 @@ ) from atproto.codegen import get_code_intent as _ from atproto.codegen.models import builder -from atproto.exceptions import InvalidNsidError from atproto.lexicon import models from atproto.nsid import NSID @@ -34,14 +34,6 @@ class ModelType(Enum): RECORD = 'Record' -def get_def_model_name(method_name: str) -> str: - return f'{capitalize_first_symbol(method_name)}' - - -def get_model_path(nsid: NSID, method_name: str) -> str: - return f'models.{get_import_path(nsid)}.{get_def_model_name(method_name)}' - - def save_code(nsid: NSID, code: str) -> None: path_to_file = _MODELS_OUTPUT_DIR.joinpath(*get_file_path_parts(nsid)) write_code(_MODELS_OUTPUT_DIR.joinpath(path_to_file), code) @@ -58,6 +50,8 @@ def _get_model_imports() -> str: 'import typing as t', '', 'import typing_extensions as te', + 'from pydantic import Field', + '', 'if t.TYPE_CHECKING:', f'{_(1)}from atproto.xrpc_client import models', f'{_(1)}from atproto.xrpc_client.models.blob_ref import BlobRef', @@ -107,9 +101,10 @@ def _get_model_class_def(name: str, model_type: ModelType) -> str: } -def _get_optional_typehint(type_hint, *, optional: bool) -> str: +def _get_optional_typehint(type_hint, *, optional: bool, with_value: bool = True) -> str: + value = ' = None' if with_value else '' if optional: - return f't.Optional[{type_hint}] = None' + return f't.Optional[{type_hint}]{value}' return type_hint @@ -118,30 +113,6 @@ def _get_ref_typehint(nsid: NSID, field_type_def, *, optional: bool) -> str: return _get_optional_typehint(f"'{model_path}'", optional=optional) -def _resolve_nsid_ref(nsid: NSID, ref: str, *, local: bool = False) -> t.Tuple[str, str]: - """Returns path to the model and model name""" - if '#' in ref: - ref_nsid_str, def_name = ref.split('#', 1) - def_name = get_def_model_name(def_name) - - try: - ref_nsid = NSID.from_str(ref_nsid_str) - return get_model_path(ref_nsid, def_name), def_name - except InvalidNsidError: - if local: - return def_name, def_name - return get_model_path(nsid, def_name), def_name - else: - ref_nsid = NSID.from_str(ref) - def_name = get_def_model_name(nsid.name) - - if local: - return def_name, def_name - - # FIXME(MarshalX): Is it works well? ;d - return get_model_path(ref_nsid, 'Main'), def_name - - def _get_ref_union_typehint(nsid: NSID, field_type_def, *, optional: bool) -> str: def_names = [] for ref in field_type_def.refs: @@ -154,18 +125,21 @@ def _get_ref_union_typehint(nsid: NSID, field_type_def, *, optional: bool) -> st # ref: https://github.com/bluesky-social/atproto/blob/b01e47b61730d05a780f7a42667b91ccaa192e8e/packages/lex-cli/src/codegen/lex-gen.ts#L325 # grep by "{$type: string; [k: string]: unknown}" string # TODO(MarshalX): use 'base.UnknownDict' and convert to DotDict - def_names.append('t.Dict[str, t.Any]') + # def_names.append('t.Dict[str, t.Any]') # FIXME(MarshalX): support pydantic def_names = ', '.join([f"'{name}'" for name in def_names]) - return _get_optional_typehint(f't.Union[{def_names}]', optional=optional) + def_field_meta = 'Field(default=None, discriminator="py_type")' if optional else 'Field(discriminator="py_type")' + + annotated_union = f'te.Annotated[t.Union[{def_names}], {def_field_meta}]' + return _get_optional_typehint(annotated_union, optional=optional) def _get_model_field_typehint(nsid: NSID, field_name: str, field_type_def, *, optional: bool) -> str: field_type = type(field_type_def) if field_type == models.LexUnknown: - # unknown type is a generic response with records or any not described type in the lexicon. for example didDoc - return _get_optional_typehint("'base.UnknownDict'", optional=optional) + # unknown type is a generic response with records or any not described type in the lexicon. for example, didDoc + return _get_optional_typehint("'unknown_type.UnknownRecordTypePydantic'", optional=optional) type_hint = _LEXICON_TYPE_TO_PRIMITIVE_TYPEHINT.get(field_type) if type_hint: @@ -258,21 +232,6 @@ def _get_model(nsid: NSID, lex_object: t.Union[models.LexObject, models.LexXrpcP return join_code(fields) -def _get_model_ref(nsid: NSID, ref: models.LexRef) -> str: - # FIXME(MarshalX): "local=True" Is it works well? ;d - ref_class, _ = _resolve_nsid_ref(nsid, ref.ref, local=True) - - # "Ref" suffix required to fix name collisions from different namespaces - lines = [ - f'#: {OUTPUT_MODEL} reference to :obj:`{ref_class}` model.', - f'{OUTPUT_MODEL}Ref = "{ref_class}"', # FIXME(MarshalX): pydantic support - '', - '', - ] - - return join_code(lines) - - def _get_model_raw_data(name: str) -> str: lines = [f'#: {name} raw data type.', f'{name}: te.TypeAlias = bytes\n\n'] return join_code(lines) @@ -327,8 +286,7 @@ def _generate_def_model(nsid: NSID, def_name: str, def_model: models.LexObject, if def_name == 'main': def_type = str(nsid) - lines.append(f"{_(1)}_type: str = '{def_type}'") - + lines.append(f"{_(1)}py_type: te.Literal['{def_type}'] = Field(default='{def_type}', alias='$type')") lines.append('') return join_code(lines) @@ -431,11 +389,13 @@ def _generate_record_type_database(lex_db: builder.BuiltRecordModels) -> None: unknown_record_type_hint_lines = [ 'import typing as t', 'import typing_extensions as te', + 'from pydantic import Field', 'if t.TYPE_CHECKING:', f'{_(4)}from atproto.xrpc_client import models', '', 'UnknownRecordType: te.TypeAlias = t.Union[', ] + unknown_record_type_pydantic_lines = ['UnknownRecordTypePydantic = te.Annotated[t.Union['] for nsid, defs in lex_db.items(): _save_code_import_if_not_exist(nsid) @@ -451,34 +411,19 @@ def _generate_record_type_database(lex_db: builder.BuiltRecordModels) -> None: type_conversion_lines.append(f"'{record_type}': {path_to_class},") unknown_record_type_hint_lines.append(f"{_(4)}'{path_to_class}',") + unknown_record_type_pydantic_lines.append(f"{_(4)}'{path_to_class}',") type_conversion_lines.append('}') + unknown_record_type_hint_lines.append(']') + unknown_record_type_pydantic_lines.append('], Field(discriminator="py_type")]') + + unknown_record_type_hint_lines.extend(unknown_record_type_pydantic_lines) write_code(_MODELS_OUTPUT_DIR.joinpath('type_conversion.py'), join_code(type_conversion_lines)) write_code(_MODELS_OUTPUT_DIR.joinpath('unknown_type.py'), join_code(unknown_record_type_hint_lines)) -def _generate_ref_models(lex_db: builder.BuiltRefsModels) -> None: - for nsid, defs in lex_db.items(): - definition = defs['main'] - if ( - hasattr(definition, 'input') - and definition.input - and definition.input.schema - and isinstance(definition.input.schema, models.LexRef) - ): - save_code_part(nsid, _get_model_ref(nsid, definition.input.schema)) - - if ( - hasattr(definition, 'output') - and definition.output - and definition.output.schema - and isinstance(definition.output.schema, models.LexRef) - ): - save_code_part(nsid, _get_model_ref(nsid, definition.output.schema)) - - def _generate_init_files(root_package_path: Path) -> None: # One of the ways that I tried. Doesn't work well due to circular imports for root, dirs, files in os.walk(root_package_path): @@ -606,9 +551,6 @@ def generate_models(lexicon_dir: t.Optional[Path] = None, output_dir: t.Optional _generate_record_models(builder.build_record_models()) _generate_record_type_database(builder.build_record_models()) - # refs should be generated at the end! - _generate_ref_models(builder.build_refs_models()) - _generate_empty_init_files(_MODELS_OUTPUT_DIR) _generate_import_aliases(_MODELS_OUTPUT_DIR) diff --git a/atproto/codegen/namespaces/generator.py b/atproto/codegen/namespaces/generator.py index c78ab0e6..e2165234 100644 --- a/atproto/codegen/namespaces/generator.py +++ b/atproto/codegen/namespaces/generator.py @@ -6,6 +6,7 @@ INPUT_MODEL, OUTPUT_MODEL, PARAMS_MODEL, + _resolve_nsid_ref, convert_camel_case_to_snake_case, format_code, gen_description_by_camel_case_name, @@ -248,19 +249,16 @@ def is_optional_arg(lex_obj) -> bool: def _get_namespace_method_return_type(method_info: MethodInfo) -> t.Tuple[str, bool]: - model_name_suffix = '' if method_info.definition.output and isinstance(method_info.definition.output.schema, LexRef): - # fix collisions with type aliases - # example of collisions: com.atproto.admin.getRepo, com.atproto.sync.getRepo - # could be solved by separating models into different folders using segments of NSID - model_name_suffix = 'Ref' + ref_class, _ = _resolve_nsid_ref(method_info.nsid, method_info.definition.output.schema.ref) + return ref_class, True is_model = False return_type = 'bool' # return success of response if method_info.definition.output: # example of methods without response: app.bsky.graph.muteActor, app.bsky.graph.muteActor is_model = True - return_type = f'models.{get_import_path(method_info.nsid)}.{OUTPUT_MODEL}{model_name_suffix}' + return_type = f'models.{get_import_path(method_info.nsid)}.{OUTPUT_MODEL}' return return_type, is_model diff --git a/atproto/xrpc_client/client/async_client.py b/atproto/xrpc_client/client/async_client.py index 857e701a..0c1e0a96 100644 --- a/atproto/xrpc_client/client/async_client.py +++ b/atproto/xrpc_client/client/async_client.py @@ -42,7 +42,7 @@ async def _invoke(self, invoke_type: 'InvokeType', **kwargs) -> 'Response': async def _get_and_set_session(self, login: str, password: str) -> models.ComAtprotoServerCreateSession.Response: session = await self.com.atproto.server.create_session( - models.ComAtprotoServerCreateSession.Data(login, password) + models.ComAtprotoServerCreateSession.Data(identifier=login, password=password) ) self._set_session(session) @@ -72,7 +72,7 @@ async def login(self, login: str, password: str) -> models.AppBskyActorDefs.Prof """ session = await self._get_and_set_session(login, password) - self.me = await self.bsky.actor.get_profile(models.AppBskyActorGetProfile.Params(session.handle)) + self.me = await self.bsky.actor.get_profile(models.AppBskyActorGetProfile.Params(actor=session.handle)) return self.me diff --git a/atproto/xrpc_client/client/client.py b/atproto/xrpc_client/client/client.py index 0265eb28..98649566 100644 --- a/atproto/xrpc_client/client/client.py +++ b/atproto/xrpc_client/client/client.py @@ -35,7 +35,9 @@ def _invoke(self, invoke_type: 'InvokeType', **kwargs) -> 'Response': return super()._invoke(invoke_type, **kwargs) def _get_and_set_session(self, login: str, password: str) -> models.ComAtprotoServerCreateSession.Response: - session = self.com.atproto.server.create_session(models.ComAtprotoServerCreateSession.Data(identifier=login, password=password)) + session = self.com.atproto.server.create_session( + models.ComAtprotoServerCreateSession.Data(identifier=login, password=password) + ) self._set_session(session) return session diff --git a/atproto/xrpc_client/models/app/bsky/actor/defs.py b/atproto/xrpc_client/models/app/bsky/actor/defs.py index 9853f4e6..4fbb54f0 100644 --- a/atproto/xrpc_client/models/app/bsky/actor/defs.py +++ b/atproto/xrpc_client/models/app/bsky/actor/defs.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -23,7 +26,9 @@ class ProfileViewBasic(base.ModelBase): labels: t.Optional[t.List['models.ComAtprotoLabelDefs.Label']] = None #: Labels. viewer: t.Optional['models.AppBskyActorDefs.ViewerState'] = None #: Viewer. - _type: str = 'app.bsky.actor.defs#profileViewBasic' + py_type: te.Literal['app.bsky.actor.defs#profileViewBasic'] = Field( + default='app.bsky.actor.defs#profileViewBasic', alias='$type' + ) class ProfileView(base.ModelBase): @@ -39,7 +44,9 @@ class ProfileView(base.ModelBase): labels: t.Optional[t.List['models.ComAtprotoLabelDefs.Label']] = None #: Labels. viewer: t.Optional['models.AppBskyActorDefs.ViewerState'] = None #: Viewer. - _type: str = 'app.bsky.actor.defs#profileView' + py_type: te.Literal['app.bsky.actor.defs#profileView'] = Field( + default='app.bsky.actor.defs#profileView', alias='$type' + ) class ProfileViewDetailed(base.ModelBase): @@ -59,7 +66,9 @@ class ProfileViewDetailed(base.ModelBase): postsCount: t.Optional[int] = None #: Posts count. viewer: t.Optional['models.AppBskyActorDefs.ViewerState'] = None #: Viewer. - _type: str = 'app.bsky.actor.defs#profileViewDetailed' + py_type: te.Literal['app.bsky.actor.defs#profileViewDetailed'] = Field( + default='app.bsky.actor.defs#profileViewDetailed', alias='$type' + ) class ViewerState(base.ModelBase): @@ -73,15 +82,19 @@ class ViewerState(base.ModelBase): muted: t.Optional[bool] = None #: Muted. mutedByList: t.Optional['models.AppBskyGraphDefs.ListViewBasic'] = None #: Muted by list. - _type: str = 'app.bsky.actor.defs#viewerState' + py_type: te.Literal['app.bsky.actor.defs#viewerState'] = Field( + default='app.bsky.actor.defs#viewerState', alias='$type' + ) Preferences = t.List[ - t.Union[ - 'models.AppBskyActorDefs.AdultContentPref', - 'models.AppBskyActorDefs.ContentLabelPref', - 'models.AppBskyActorDefs.SavedFeedsPref', - 't.Dict[str, t.Any]', + te.Annotated[ + t.Union[ + 'models.AppBskyActorDefs.AdultContentPref', + 'models.AppBskyActorDefs.ContentLabelPref', + 'models.AppBskyActorDefs.SavedFeedsPref', + ], + Field(discriminator='py_type'), ] ] @@ -92,7 +105,9 @@ class AdultContentPref(base.ModelBase): enabled: bool #: Enabled. - _type: str = 'app.bsky.actor.defs#adultContentPref' + py_type: te.Literal['app.bsky.actor.defs#adultContentPref'] = Field( + default='app.bsky.actor.defs#adultContentPref', alias='$type' + ) class ContentLabelPref(base.ModelBase): @@ -102,7 +117,9 @@ class ContentLabelPref(base.ModelBase): label: str #: Label. visibility: str #: Visibility. - _type: str = 'app.bsky.actor.defs#contentLabelPref' + py_type: te.Literal['app.bsky.actor.defs#contentLabelPref'] = Field( + default='app.bsky.actor.defs#contentLabelPref', alias='$type' + ) class SavedFeedsPref(base.ModelBase): @@ -112,4 +129,6 @@ class SavedFeedsPref(base.ModelBase): pinned: t.List[str] #: Pinned. saved: t.List[str] #: Saved. - _type: str = 'app.bsky.actor.defs#savedFeedsPref' + py_type: te.Literal['app.bsky.actor.defs#savedFeedsPref'] = Field( + default='app.bsky.actor.defs#savedFeedsPref', alias='$type' + ) diff --git a/atproto/xrpc_client/models/app/bsky/actor/get_profile.py b/atproto/xrpc_client/models/app/bsky/actor/get_profile.py index 9c5922d1..4b5868d3 100644 --- a/atproto/xrpc_client/models/app/bsky/actor/get_profile.py +++ b/atproto/xrpc_client/models/app/bsky/actor/get_profile.py @@ -17,8 +17,3 @@ class Params(base.ParamsModelBase): """Parameters model for :obj:`app.bsky.actor.getProfile`.""" actor: str #: Actor. - - -#: Response reference to :obj:`models.AppBskyActorDefs.ProfileViewDetailed` model. -from atproto.xrpc_client.models.app.bsky.actor.defs import ProfileViewDetailed -ResponseRef = ProfileViewDetailed diff --git a/atproto/xrpc_client/models/app/bsky/actor/profile.py b/atproto/xrpc_client/models/app/bsky/actor/profile.py index 55842d86..9329af90 100644 --- a/atproto/xrpc_client/models/app/bsky/actor/profile.py +++ b/atproto/xrpc_client/models/app/bsky/actor/profile.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models.blob_ref import BlobRef @@ -21,6 +24,8 @@ class Main(base.RecordModelBase): banner: t.Optional['BlobRef'] = None #: Banner. description: t.Optional[str] = None #: Description. displayName: t.Optional[str] = None #: Display name. - labels: t.Optional[t.Union['models.ComAtprotoLabelDefs.SelfLabels', 't.Dict[str, t.Any]']] = None #: Labels. + labels: t.Optional[ + te.Annotated[t.Union['models.ComAtprotoLabelDefs.SelfLabels'], Field(default=None, discriminator='py_type')] + ] = None #: Labels. - _type: str = 'app.bsky.actor.profile' + py_type: te.Literal['app.bsky.actor.profile'] = Field(default='app.bsky.actor.profile', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/embed/external.py b/atproto/xrpc_client/models/app/bsky/embed/external.py index 16c7a940..a7215f56 100644 --- a/atproto/xrpc_client/models/app/bsky/embed/external.py +++ b/atproto/xrpc_client/models/app/bsky/embed/external.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models.blob_ref import BlobRef @@ -19,7 +22,7 @@ class Main(base.ModelBase): external: 'models.AppBskyEmbedExternal.External' #: External. - _type: str = 'app.bsky.embed.external' + py_type: te.Literal['app.bsky.embed.external'] = Field(default='app.bsky.embed.external', alias='$type') class External(base.ModelBase): @@ -31,7 +34,9 @@ class External(base.ModelBase): uri: str #: Uri. thumb: t.Optional['BlobRef'] = None #: Thumb. - _type: str = 'app.bsky.embed.external#external' + py_type: te.Literal['app.bsky.embed.external#external'] = Field( + default='app.bsky.embed.external#external', alias='$type' + ) class View(base.ModelBase): @@ -40,7 +45,7 @@ class View(base.ModelBase): external: 'models.AppBskyEmbedExternal.ViewExternal' #: External. - _type: str = 'app.bsky.embed.external#view' + py_type: te.Literal['app.bsky.embed.external#view'] = Field(default='app.bsky.embed.external#view', alias='$type') class ViewExternal(base.ModelBase): @@ -52,4 +57,6 @@ class ViewExternal(base.ModelBase): uri: str #: Uri. thumb: t.Optional[str] = None #: Thumb. - _type: str = 'app.bsky.embed.external#viewExternal' + py_type: te.Literal['app.bsky.embed.external#viewExternal'] = Field( + default='app.bsky.embed.external#viewExternal', alias='$type' + ) diff --git a/atproto/xrpc_client/models/app/bsky/embed/images.py b/atproto/xrpc_client/models/app/bsky/embed/images.py index d84ad33d..70ac7457 100644 --- a/atproto/xrpc_client/models/app/bsky/embed/images.py +++ b/atproto/xrpc_client/models/app/bsky/embed/images.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models.blob_ref import BlobRef @@ -19,7 +22,7 @@ class Main(base.ModelBase): images: t.List['models.AppBskyEmbedImages.Image'] #: Images. - _type: str = 'app.bsky.embed.images' + py_type: te.Literal['app.bsky.embed.images'] = Field(default='app.bsky.embed.images', alias='$type') class Image(base.ModelBase): @@ -29,7 +32,7 @@ class Image(base.ModelBase): alt: str #: Alt. image: 'BlobRef' #: Image. - _type: str = 'app.bsky.embed.images#image' + py_type: te.Literal['app.bsky.embed.images#image'] = Field(default='app.bsky.embed.images#image', alias='$type') class View(base.ModelBase): @@ -38,7 +41,7 @@ class View(base.ModelBase): images: t.List['models.AppBskyEmbedImages.ViewImage'] #: Images. - _type: str = 'app.bsky.embed.images#view' + py_type: te.Literal['app.bsky.embed.images#view'] = Field(default='app.bsky.embed.images#view', alias='$type') class ViewImage(base.ModelBase): @@ -49,4 +52,6 @@ class ViewImage(base.ModelBase): fullsize: str #: Fullsize. thumb: str #: Thumb. - _type: str = 'app.bsky.embed.images#viewImage' + py_type: te.Literal['app.bsky.embed.images#viewImage'] = Field( + default='app.bsky.embed.images#viewImage', alias='$type' + ) diff --git a/atproto/xrpc_client/models/app/bsky/embed/record.py b/atproto/xrpc_client/models/app/bsky/embed/record.py index b805523a..1c5ef202 100644 --- a/atproto/xrpc_client/models/app/bsky/embed/record.py +++ b/atproto/xrpc_client/models/app/bsky/embed/record.py @@ -7,9 +7,12 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class Main(base.ModelBase): @@ -18,23 +21,25 @@ class Main(base.ModelBase): record: 'models.ComAtprotoRepoStrongRef.Main' #: Record. - _type: str = 'app.bsky.embed.record' + py_type: te.Literal['app.bsky.embed.record'] = Field(default='app.bsky.embed.record', alias='$type') class View(base.ModelBase): """Definition model for :obj:`app.bsky.embed.record`.""" - record: t.Union[ - 'models.AppBskyEmbedRecord.ViewRecord', - 'models.AppBskyEmbedRecord.ViewNotFound', - 'models.AppBskyEmbedRecord.ViewBlocked', - 'models.AppBskyFeedDefs.GeneratorView', - 'models.AppBskyGraphDefs.ListView', - 't.Dict[str, t.Any]', + record: te.Annotated[ + t.Union[ + 'models.AppBskyEmbedRecord.ViewRecord', + 'models.AppBskyEmbedRecord.ViewNotFound', + 'models.AppBskyEmbedRecord.ViewBlocked', + 'models.AppBskyFeedDefs.GeneratorView', + 'models.AppBskyGraphDefs.ListView', + ], + Field(discriminator='py_type'), ] #: Record. - _type: str = 'app.bsky.embed.record#view' + py_type: te.Literal['app.bsky.embed.record#view'] = Field(default='app.bsky.embed.record#view', alias='$type') class ViewRecord(base.ModelBase): @@ -45,21 +50,25 @@ class ViewRecord(base.ModelBase): cid: str #: Cid. indexedAt: str #: Indexed at. uri: str #: Uri. - value: 'base.UnknownDict' #: Value. + value: 'unknown_type.UnknownRecordTypePydantic' #: Value. embeds: t.Optional[ t.List[ - t.Union[ - 'models.AppBskyEmbedImages.View', - 'models.AppBskyEmbedExternal.View', - 'models.AppBskyEmbedRecord.View', - 'models.AppBskyEmbedRecordWithMedia.View', - 't.Dict[str, t.Any]', + te.Annotated[ + t.Union[ + 'models.AppBskyEmbedImages.View', + 'models.AppBskyEmbedExternal.View', + 'models.AppBskyEmbedRecord.View', + 'models.AppBskyEmbedRecordWithMedia.View', + ], + Field(discriminator='py_type'), ] ] ] = None #: Embeds. labels: t.Optional[t.List['models.ComAtprotoLabelDefs.Label']] = None #: Labels. - _type: str = 'app.bsky.embed.record#viewRecord' + py_type: te.Literal['app.bsky.embed.record#viewRecord'] = Field( + default='app.bsky.embed.record#viewRecord', alias='$type' + ) class ViewNotFound(base.ModelBase): @@ -69,7 +78,9 @@ class ViewNotFound(base.ModelBase): notFound: bool #: Not found. uri: str #: Uri. - _type: str = 'app.bsky.embed.record#viewNotFound' + py_type: te.Literal['app.bsky.embed.record#viewNotFound'] = Field( + default='app.bsky.embed.record#viewNotFound', alias='$type' + ) class ViewBlocked(base.ModelBase): @@ -80,4 +91,6 @@ class ViewBlocked(base.ModelBase): blocked: bool #: Blocked. uri: str #: Uri. - _type: str = 'app.bsky.embed.record#viewBlocked' + py_type: te.Literal['app.bsky.embed.record#viewBlocked'] = Field( + default='app.bsky.embed.record#viewBlocked', alias='$type' + ) diff --git a/atproto/xrpc_client/models/app/bsky/embed/record_with_media.py b/atproto/xrpc_client/models/app/bsky/embed/record_with_media.py index 7e1ca4fc..8a21798d 100644 --- a/atproto/xrpc_client/models/app/bsky/embed/record_with_media.py +++ b/atproto/xrpc_client/models/app/bsky/embed/record_with_media.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -16,21 +19,25 @@ class Main(base.ModelBase): """Definition model for :obj:`app.bsky.embed.recordWithMedia`.""" - media: t.Union[ - 'models.AppBskyEmbedImages.Main', 'models.AppBskyEmbedExternal.Main', 't.Dict[str, t.Any]' + media: te.Annotated[ + t.Union['models.AppBskyEmbedImages.Main', 'models.AppBskyEmbedExternal.Main'], Field(discriminator='py_type') ] #: Media. record: 'models.AppBskyEmbedRecord.Main' #: Record. - _type: str = 'app.bsky.embed.recordWithMedia' + py_type: te.Literal['app.bsky.embed.recordWithMedia'] = Field( + default='app.bsky.embed.recordWithMedia', alias='$type' + ) class View(base.ModelBase): """Definition model for :obj:`app.bsky.embed.recordWithMedia`.""" - media: t.Union[ - 'models.AppBskyEmbedImages.View', 'models.AppBskyEmbedExternal.View', 't.Dict[str, t.Any]' + media: te.Annotated[ + t.Union['models.AppBskyEmbedImages.View', 'models.AppBskyEmbedExternal.View'], Field(discriminator='py_type') ] #: Media. record: 'models.AppBskyEmbedRecord.View' #: Record. - _type: str = 'app.bsky.embed.recordWithMedia#view' + py_type: te.Literal['app.bsky.embed.recordWithMedia#view'] = Field( + default='app.bsky.embed.recordWithMedia#view', alias='$type' + ) diff --git a/atproto/xrpc_client/models/app/bsky/feed/defs.py b/atproto/xrpc_client/models/app/bsky/feed/defs.py index 0bcdc63f..d1f37e23 100644 --- a/atproto/xrpc_client/models/app/bsky/feed/defs.py +++ b/atproto/xrpc_client/models/app/bsky/feed/defs.py @@ -7,9 +7,12 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class PostView(base.ModelBase): @@ -19,15 +22,17 @@ class PostView(base.ModelBase): author: 'models.AppBskyActorDefs.ProfileViewBasic' #: Author. cid: str #: Cid. indexedAt: str #: Indexed at. - record: 'base.UnknownDict' #: Record. + record: 'unknown_type.UnknownRecordTypePydantic' #: Record. uri: str #: Uri. embed: t.Optional[ - t.Union[ - 'models.AppBskyEmbedImages.View', - 'models.AppBskyEmbedExternal.View', - 'models.AppBskyEmbedRecord.View', - 'models.AppBskyEmbedRecordWithMedia.View', - 't.Dict[str, t.Any]', + te.Annotated[ + t.Union[ + 'models.AppBskyEmbedImages.View', + 'models.AppBskyEmbedExternal.View', + 'models.AppBskyEmbedRecord.View', + 'models.AppBskyEmbedRecordWithMedia.View', + ], + Field(default=None, discriminator='py_type'), ] ] = None #: Embed. labels: t.Optional[t.List['models.ComAtprotoLabelDefs.Label']] = None #: Labels. @@ -36,7 +41,7 @@ class PostView(base.ModelBase): repostCount: t.Optional[int] = None #: Repost count. viewer: t.Optional['models.AppBskyFeedDefs.ViewerState'] = None #: Viewer. - _type: str = 'app.bsky.feed.defs#postView' + py_type: te.Literal['app.bsky.feed.defs#postView'] = Field(default='app.bsky.feed.defs#postView', alias='$type') class ViewerState(base.ModelBase): @@ -46,7 +51,9 @@ class ViewerState(base.ModelBase): like: t.Optional[str] = None #: Like. repost: t.Optional[str] = None #: Repost. - _type: str = 'app.bsky.feed.defs#viewerState' + py_type: te.Literal['app.bsky.feed.defs#viewerState'] = Field( + default='app.bsky.feed.defs#viewerState', alias='$type' + ) class FeedViewPost(base.ModelBase): @@ -54,30 +61,38 @@ class FeedViewPost(base.ModelBase): """Definition model for :obj:`app.bsky.feed.defs`.""" post: 'models.AppBskyFeedDefs.PostView' #: Post. - reason: t.Optional[t.Union['models.AppBskyFeedDefs.ReasonRepost', 't.Dict[str, t.Any]']] = None #: Reason. + reason: t.Optional[ + te.Annotated[t.Union['models.AppBskyFeedDefs.ReasonRepost'], Field(default=None, discriminator='py_type')] + ] = None #: Reason. reply: t.Optional['models.AppBskyFeedDefs.ReplyRef'] = None #: Reply. - _type: str = 'app.bsky.feed.defs#feedViewPost' + py_type: te.Literal['app.bsky.feed.defs#feedViewPost'] = Field( + default='app.bsky.feed.defs#feedViewPost', alias='$type' + ) class ReplyRef(base.ModelBase): """Definition model for :obj:`app.bsky.feed.defs`.""" - parent: t.Union[ - 'models.AppBskyFeedDefs.PostView', - 'models.AppBskyFeedDefs.NotFoundPost', - 'models.AppBskyFeedDefs.BlockedPost', - 't.Dict[str, t.Any]', + parent: te.Annotated[ + t.Union[ + 'models.AppBskyFeedDefs.PostView', + 'models.AppBskyFeedDefs.NotFoundPost', + 'models.AppBskyFeedDefs.BlockedPost', + ], + Field(discriminator='py_type'), ] #: Parent. - root: t.Union[ - 'models.AppBskyFeedDefs.PostView', - 'models.AppBskyFeedDefs.NotFoundPost', - 'models.AppBskyFeedDefs.BlockedPost', - 't.Dict[str, t.Any]', + root: te.Annotated[ + t.Union[ + 'models.AppBskyFeedDefs.PostView', + 'models.AppBskyFeedDefs.NotFoundPost', + 'models.AppBskyFeedDefs.BlockedPost', + ], + Field(discriminator='py_type'), ] #: Root. - _type: str = 'app.bsky.feed.defs#replyRef' + py_type: te.Literal['app.bsky.feed.defs#replyRef'] = Field(default='app.bsky.feed.defs#replyRef', alias='$type') class ReasonRepost(base.ModelBase): @@ -87,7 +102,9 @@ class ReasonRepost(base.ModelBase): by: 'models.AppBskyActorDefs.ProfileViewBasic' #: By. indexedAt: str #: Indexed at. - _type: str = 'app.bsky.feed.defs#reasonRepost' + py_type: te.Literal['app.bsky.feed.defs#reasonRepost'] = Field( + default='app.bsky.feed.defs#reasonRepost', alias='$type' + ) class ThreadViewPost(base.ModelBase): @@ -96,25 +113,31 @@ class ThreadViewPost(base.ModelBase): post: 'models.AppBskyFeedDefs.PostView' #: Post. parent: t.Optional[ - t.Union[ - 'models.AppBskyFeedDefs.ThreadViewPost', - 'models.AppBskyFeedDefs.NotFoundPost', - 'models.AppBskyFeedDefs.BlockedPost', - 't.Dict[str, t.Any]', - ] - ] = None #: Parent. - replies: t.Optional[ - t.List[ + te.Annotated[ t.Union[ 'models.AppBskyFeedDefs.ThreadViewPost', 'models.AppBskyFeedDefs.NotFoundPost', 'models.AppBskyFeedDefs.BlockedPost', - 't.Dict[str, t.Any]', + ], + Field(default=None, discriminator='py_type'), + ] + ] = None #: Parent. + replies: t.Optional[ + t.List[ + te.Annotated[ + t.Union[ + 'models.AppBskyFeedDefs.ThreadViewPost', + 'models.AppBskyFeedDefs.NotFoundPost', + 'models.AppBskyFeedDefs.BlockedPost', + ], + Field(discriminator='py_type'), ] ] ] = None #: Replies. - _type: str = 'app.bsky.feed.defs#threadViewPost' + py_type: te.Literal['app.bsky.feed.defs#threadViewPost'] = Field( + default='app.bsky.feed.defs#threadViewPost', alias='$type' + ) class NotFoundPost(base.ModelBase): @@ -124,7 +147,9 @@ class NotFoundPost(base.ModelBase): notFound: bool #: Not found. uri: str #: Uri. - _type: str = 'app.bsky.feed.defs#notFoundPost' + py_type: te.Literal['app.bsky.feed.defs#notFoundPost'] = Field( + default='app.bsky.feed.defs#notFoundPost', alias='$type' + ) class BlockedPost(base.ModelBase): @@ -135,7 +160,9 @@ class BlockedPost(base.ModelBase): blocked: bool #: Blocked. uri: str #: Uri. - _type: str = 'app.bsky.feed.defs#blockedPost' + py_type: te.Literal['app.bsky.feed.defs#blockedPost'] = Field( + default='app.bsky.feed.defs#blockedPost', alias='$type' + ) class BlockedAuthor(base.ModelBase): @@ -145,7 +172,9 @@ class BlockedAuthor(base.ModelBase): did: str #: Did. viewer: t.Optional['models.AppBskyActorDefs.ViewerState'] = None #: Viewer. - _type: str = 'app.bsky.feed.defs#blockedAuthor' + py_type: te.Literal['app.bsky.feed.defs#blockedAuthor'] = Field( + default='app.bsky.feed.defs#blockedAuthor', alias='$type' + ) class GeneratorView(base.ModelBase): @@ -164,7 +193,9 @@ class GeneratorView(base.ModelBase): likeCount: t.Optional[int] = None #: Like count. viewer: t.Optional['models.AppBskyFeedDefs.GeneratorViewerState'] = None #: Viewer. - _type: str = 'app.bsky.feed.defs#generatorView' + py_type: te.Literal['app.bsky.feed.defs#generatorView'] = Field( + default='app.bsky.feed.defs#generatorView', alias='$type' + ) class GeneratorViewerState(base.ModelBase): @@ -173,7 +204,9 @@ class GeneratorViewerState(base.ModelBase): like: t.Optional[str] = None #: Like. - _type: str = 'app.bsky.feed.defs#generatorViewerState' + py_type: te.Literal['app.bsky.feed.defs#generatorViewerState'] = Field( + default='app.bsky.feed.defs#generatorViewerState', alias='$type' + ) class SkeletonFeedPost(base.ModelBase): @@ -181,9 +214,15 @@ class SkeletonFeedPost(base.ModelBase): """Definition model for :obj:`app.bsky.feed.defs`.""" post: str #: Post. - reason: t.Optional[t.Union['models.AppBskyFeedDefs.SkeletonReasonRepost', 't.Dict[str, t.Any]']] = None #: Reason. + reason: t.Optional[ + te.Annotated[ + t.Union['models.AppBskyFeedDefs.SkeletonReasonRepost'], Field(default=None, discriminator='py_type') + ] + ] = None #: Reason. - _type: str = 'app.bsky.feed.defs#skeletonFeedPost' + py_type: te.Literal['app.bsky.feed.defs#skeletonFeedPost'] = Field( + default='app.bsky.feed.defs#skeletonFeedPost', alias='$type' + ) class SkeletonReasonRepost(base.ModelBase): @@ -192,4 +231,6 @@ class SkeletonReasonRepost(base.ModelBase): repost: str #: Repost. - _type: str = 'app.bsky.feed.defs#skeletonReasonRepost' + py_type: te.Literal['app.bsky.feed.defs#skeletonReasonRepost'] = Field( + default='app.bsky.feed.defs#skeletonReasonRepost', alias='$type' + ) diff --git a/atproto/xrpc_client/models/app/bsky/feed/describe_feed_generator.py b/atproto/xrpc_client/models/app/bsky/feed/describe_feed_generator.py index 9ba48385..d3163ef8 100644 --- a/atproto/xrpc_client/models/app/bsky/feed/describe_feed_generator.py +++ b/atproto/xrpc_client/models/app/bsky/feed/describe_feed_generator.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -27,7 +30,9 @@ class Feed(base.ModelBase): uri: str #: Uri. - _type: str = 'app.bsky.feed.describeFeedGenerator#feed' + py_type: te.Literal['app.bsky.feed.describeFeedGenerator#feed'] = Field( + default='app.bsky.feed.describeFeedGenerator#feed', alias='$type' + ) class Links(base.ModelBase): @@ -37,4 +42,6 @@ class Links(base.ModelBase): privacyPolicy: t.Optional[str] = None #: Privacy policy. termsOfService: t.Optional[str] = None #: Terms of service. - _type: str = 'app.bsky.feed.describeFeedGenerator#links' + py_type: te.Literal['app.bsky.feed.describeFeedGenerator#links'] = Field( + default='app.bsky.feed.describeFeedGenerator#links', alias='$type' + ) diff --git a/atproto/xrpc_client/models/app/bsky/feed/generator.py b/atproto/xrpc_client/models/app/bsky/feed/generator.py index f80b9763..7f74b2c4 100644 --- a/atproto/xrpc_client/models/app/bsky/feed/generator.py +++ b/atproto/xrpc_client/models/app/bsky/feed/generator.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models.blob_ref import BlobRef @@ -23,6 +26,8 @@ class Main(base.RecordModelBase): avatar: t.Optional['BlobRef'] = None #: Avatar. description: t.Optional[str] = None #: Description. descriptionFacets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None #: Description facets. - labels: t.Optional[t.Union['models.ComAtprotoLabelDefs.SelfLabels', 't.Dict[str, t.Any]']] = None #: Labels. + labels: t.Optional[ + te.Annotated[t.Union['models.ComAtprotoLabelDefs.SelfLabels'], Field(default=None, discriminator='py_type')] + ] = None #: Labels. - _type: str = 'app.bsky.feed.generator' + py_type: te.Literal['app.bsky.feed.generator'] = Field(default='app.bsky.feed.generator', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/feed/get_likes.py b/atproto/xrpc_client/models/app/bsky/feed/get_likes.py index 790324fc..41cb0e4d 100644 --- a/atproto/xrpc_client/models/app/bsky/feed/get_likes.py +++ b/atproto/xrpc_client/models/app/bsky/feed/get_likes.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -40,4 +43,4 @@ class Like(base.ModelBase): createdAt: str #: Created at. indexedAt: str #: Indexed at. - _type: str = 'app.bsky.feed.getLikes#like' + py_type: te.Literal['app.bsky.feed.getLikes#like'] = Field(default='app.bsky.feed.getLikes#like', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/feed/get_post_thread.py b/atproto/xrpc_client/models/app/bsky/feed/get_post_thread.py index 16da1bab..05e9611e 100644 --- a/atproto/xrpc_client/models/app/bsky/feed/get_post_thread.py +++ b/atproto/xrpc_client/models/app/bsky/feed/get_post_thread.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -25,9 +28,11 @@ class Response(base.ResponseModelBase): """Output data model for :obj:`app.bsky.feed.getPostThread`.""" - thread: t.Union[ - 'models.AppBskyFeedDefs.ThreadViewPost', - 'models.AppBskyFeedDefs.NotFoundPost', - 'models.AppBskyFeedDefs.BlockedPost', - 't.Dict[str, t.Any]', + thread: te.Annotated[ + t.Union[ + 'models.AppBskyFeedDefs.ThreadViewPost', + 'models.AppBskyFeedDefs.NotFoundPost', + 'models.AppBskyFeedDefs.BlockedPost', + ], + Field(discriminator='py_type'), ] #: Thread. diff --git a/atproto/xrpc_client/models/app/bsky/feed/like.py b/atproto/xrpc_client/models/app/bsky/feed/like.py index 3bb3d101..2a42b9cf 100644 --- a/atproto/xrpc_client/models/app/bsky/feed/like.py +++ b/atproto/xrpc_client/models/app/bsky/feed/like.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -19,4 +22,4 @@ class Main(base.RecordModelBase): createdAt: str #: Created at. subject: 'models.ComAtprotoRepoStrongRef.Main' #: Subject. - _type: str = 'app.bsky.feed.like' + py_type: te.Literal['app.bsky.feed.like'] = Field(default='app.bsky.feed.like', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/feed/post.py b/atproto/xrpc_client/models/app/bsky/feed/post.py index 3c070484..0aa03a2c 100644 --- a/atproto/xrpc_client/models/app/bsky/feed/post.py +++ b/atproto/xrpc_client/models/app/bsky/feed/post.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -19,7 +22,7 @@ class ReplyRef(base.ModelBase): parent: 'models.ComAtprotoRepoStrongRef.Main' #: Parent. root: 'models.ComAtprotoRepoStrongRef.Main' #: Root. - _type: str = 'app.bsky.feed.post#replyRef' + py_type: te.Literal['app.bsky.feed.post#replyRef'] = Field(default='app.bsky.feed.post#replyRef', alias='$type') class Entity(base.ModelBase): @@ -30,7 +33,7 @@ class Entity(base.ModelBase): type: str #: Expected values are 'mention' and 'link'. value: str #: Value. - _type: str = 'app.bsky.feed.post#entity' + py_type: te.Literal['app.bsky.feed.post#entity'] = Field(default='app.bsky.feed.post#entity', alias='$type') class TextSlice(base.ModelBase): @@ -40,7 +43,7 @@ class TextSlice(base.ModelBase): end: int #: End. start: int #: Start. - _type: str = 'app.bsky.feed.post#textSlice' + py_type: te.Literal['app.bsky.feed.post#textSlice'] = Field(default='app.bsky.feed.post#textSlice', alias='$type') class Main(base.RecordModelBase): @@ -50,20 +53,24 @@ class Main(base.RecordModelBase): createdAt: str #: Created at. text: str #: Text. embed: t.Optional[ - t.Union[ - 'models.AppBskyEmbedImages.Main', - 'models.AppBskyEmbedExternal.Main', - 'models.AppBskyEmbedRecord.Main', - 'models.AppBskyEmbedRecordWithMedia.Main', - 't.Dict[str, t.Any]', + te.Annotated[ + t.Union[ + 'models.AppBskyEmbedImages.Main', + 'models.AppBskyEmbedExternal.Main', + 'models.AppBskyEmbedRecord.Main', + 'models.AppBskyEmbedRecordWithMedia.Main', + ], + Field(default=None, discriminator='py_type'), ] ] = None #: Embed. entities: t.Optional[ t.List['models.AppBskyFeedPost.Entity'] ] = None #: Deprecated: replaced by app.bsky.richtext.facet. facets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None #: Facets. - labels: t.Optional[t.Union['models.ComAtprotoLabelDefs.SelfLabels', 't.Dict[str, t.Any]']] = None #: Labels. + labels: t.Optional[ + te.Annotated[t.Union['models.ComAtprotoLabelDefs.SelfLabels'], Field(default=None, discriminator='py_type')] + ] = None #: Labels. langs: t.Optional[t.List[str]] = None #: Langs. reply: t.Optional['models.AppBskyFeedPost.ReplyRef'] = None #: Reply. - _type: str = 'app.bsky.feed.post' + py_type: te.Literal['app.bsky.feed.post'] = Field(default='app.bsky.feed.post', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/feed/repost.py b/atproto/xrpc_client/models/app/bsky/feed/repost.py index febdfe48..b644a745 100644 --- a/atproto/xrpc_client/models/app/bsky/feed/repost.py +++ b/atproto/xrpc_client/models/app/bsky/feed/repost.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -19,4 +22,4 @@ class Main(base.RecordModelBase): createdAt: str #: Created at. subject: 'models.ComAtprotoRepoStrongRef.Main' #: Subject. - _type: str = 'app.bsky.feed.repost' + py_type: te.Literal['app.bsky.feed.repost'] = Field(default='app.bsky.feed.repost', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/graph/block.py b/atproto/xrpc_client/models/app/bsky/graph/block.py index b5e05657..8d079d31 100644 --- a/atproto/xrpc_client/models/app/bsky/graph/block.py +++ b/atproto/xrpc_client/models/app/bsky/graph/block.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: pass from atproto.xrpc_client.models import base @@ -19,4 +22,4 @@ class Main(base.RecordModelBase): createdAt: str #: Created at. subject: str #: Subject. - _type: str = 'app.bsky.graph.block' + py_type: te.Literal['app.bsky.graph.block'] = Field(default='app.bsky.graph.block', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/graph/defs.py b/atproto/xrpc_client/models/app/bsky/graph/defs.py index 0f727ee9..0139d8e3 100644 --- a/atproto/xrpc_client/models/app/bsky/graph/defs.py +++ b/atproto/xrpc_client/models/app/bsky/graph/defs.py @@ -8,6 +8,7 @@ import typing as t import typing_extensions as te +from pydantic import Field if t.TYPE_CHECKING: from atproto.xrpc_client import models @@ -26,7 +27,9 @@ class ListViewBasic(base.ModelBase): indexedAt: t.Optional[str] = None #: Indexed at. viewer: t.Optional['models.AppBskyGraphDefs.ListViewerState'] = None #: Viewer. - _type: str = 'app.bsky.graph.defs#listViewBasic' + py_type: te.Literal['app.bsky.graph.defs#listViewBasic'] = Field( + default='app.bsky.graph.defs#listViewBasic', alias='$type' + ) class ListView(base.ModelBase): @@ -44,7 +47,7 @@ class ListView(base.ModelBase): descriptionFacets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None #: Description facets. viewer: t.Optional['models.AppBskyGraphDefs.ListViewerState'] = None #: Viewer. - _type: str = 'app.bsky.graph.defs#listView' + py_type: te.Literal['app.bsky.graph.defs#listView'] = Field(default='app.bsky.graph.defs#listView', alias='$type') class ListItemView(base.ModelBase): @@ -53,7 +56,9 @@ class ListItemView(base.ModelBase): subject: 'models.AppBskyActorDefs.ProfileView' #: Subject. - _type: str = 'app.bsky.graph.defs#listItemView' + py_type: te.Literal['app.bsky.graph.defs#listItemView'] = Field( + default='app.bsky.graph.defs#listItemView', alias='$type' + ) ListPurpose = te.Literal['Modlist'] @@ -67,4 +72,6 @@ class ListViewerState(base.ModelBase): muted: t.Optional[bool] = None #: Muted. - _type: str = 'app.bsky.graph.defs#listViewerState' + py_type: te.Literal['app.bsky.graph.defs#listViewerState'] = Field( + default='app.bsky.graph.defs#listViewerState', alias='$type' + ) diff --git a/atproto/xrpc_client/models/app/bsky/graph/follow.py b/atproto/xrpc_client/models/app/bsky/graph/follow.py index 390716d0..ac94235e 100644 --- a/atproto/xrpc_client/models/app/bsky/graph/follow.py +++ b/atproto/xrpc_client/models/app/bsky/graph/follow.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: pass from atproto.xrpc_client.models import base @@ -19,4 +22,4 @@ class Main(base.RecordModelBase): createdAt: str #: Created at. subject: str #: Subject. - _type: str = 'app.bsky.graph.follow' + py_type: te.Literal['app.bsky.graph.follow'] = Field(default='app.bsky.graph.follow', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/graph/list.py b/atproto/xrpc_client/models/app/bsky/graph/list.py index f288ed23..a052a7e0 100644 --- a/atproto/xrpc_client/models/app/bsky/graph/list.py +++ b/atproto/xrpc_client/models/app/bsky/graph/list.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models.blob_ref import BlobRef @@ -23,6 +26,8 @@ class Main(base.RecordModelBase): avatar: t.Optional['BlobRef'] = None #: Avatar. description: t.Optional[str] = None #: Description. descriptionFacets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None #: Description facets. - labels: t.Optional[t.Union['models.ComAtprotoLabelDefs.SelfLabels', 't.Dict[str, t.Any]']] = None #: Labels. + labels: t.Optional[ + te.Annotated[t.Union['models.ComAtprotoLabelDefs.SelfLabels'], Field(default=None, discriminator='py_type')] + ] = None #: Labels. - _type: str = 'app.bsky.graph.list' + py_type: te.Literal['app.bsky.graph.list'] = Field(default='app.bsky.graph.list', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/graph/listitem.py b/atproto/xrpc_client/models/app/bsky/graph/listitem.py index 2e775f81..a1f0f741 100644 --- a/atproto/xrpc_client/models/app/bsky/graph/listitem.py +++ b/atproto/xrpc_client/models/app/bsky/graph/listitem.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: pass from atproto.xrpc_client.models import base @@ -20,4 +23,4 @@ class Main(base.RecordModelBase): list: str #: List. subject: str #: Subject. - _type: str = 'app.bsky.graph.listitem' + py_type: te.Literal['app.bsky.graph.listitem'] = Field(default='app.bsky.graph.listitem', alias='$type') diff --git a/atproto/xrpc_client/models/app/bsky/notification/list_notifications.py b/atproto/xrpc_client/models/app/bsky/notification/list_notifications.py index 1ced925a..e60ad2f4 100644 --- a/atproto/xrpc_client/models/app/bsky/notification/list_notifications.py +++ b/atproto/xrpc_client/models/app/bsky/notification/list_notifications.py @@ -7,9 +7,12 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class Params(base.ParamsModelBase): @@ -38,9 +41,11 @@ class Notification(base.ModelBase): indexedAt: str #: Indexed at. isRead: bool #: Is read. reason: str #: Expected values are 'like', 'repost', 'follow', 'mention', 'reply', and 'quote'. - record: 'base.UnknownDict' #: Record. + record: 'unknown_type.UnknownRecordTypePydantic' #: Record. uri: str #: Uri. labels: t.Optional[t.List['models.ComAtprotoLabelDefs.Label']] = None #: Labels. reasonSubject: t.Optional[str] = None #: Reason subject. - _type: str = 'app.bsky.notification.listNotifications#notification' + py_type: te.Literal['app.bsky.notification.listNotifications#notification'] = Field( + default='app.bsky.notification.listNotifications#notification', alias='$type' + ) diff --git a/atproto/xrpc_client/models/app/bsky/richtext/facet.py b/atproto/xrpc_client/models/app/bsky/richtext/facet.py index 12e77d60..ee567819 100644 --- a/atproto/xrpc_client/models/app/bsky/richtext/facet.py +++ b/atproto/xrpc_client/models/app/bsky/richtext/facet.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -17,11 +20,14 @@ class Main(base.ModelBase): """Definition model for :obj:`app.bsky.richtext.facet`.""" features: t.List[ - t.Union['models.AppBskyRichtextFacet.Mention', 'models.AppBskyRichtextFacet.Link', 't.Dict[str, t.Any]'] + te.Annotated[ + t.Union['models.AppBskyRichtextFacet.Mention', 'models.AppBskyRichtextFacet.Link'], + Field(discriminator='py_type'), + ] ] #: Features. index: 'models.AppBskyRichtextFacet.ByteSlice' #: Index. - _type: str = 'app.bsky.richtext.facet' + py_type: te.Literal['app.bsky.richtext.facet'] = Field(default='app.bsky.richtext.facet', alias='$type') class Mention(base.ModelBase): @@ -30,7 +36,9 @@ class Mention(base.ModelBase): did: str #: Did. - _type: str = 'app.bsky.richtext.facet#mention' + py_type: te.Literal['app.bsky.richtext.facet#mention'] = Field( + default='app.bsky.richtext.facet#mention', alias='$type' + ) class Link(base.ModelBase): @@ -39,7 +47,7 @@ class Link(base.ModelBase): uri: str #: Uri. - _type: str = 'app.bsky.richtext.facet#link' + py_type: te.Literal['app.bsky.richtext.facet#link'] = Field(default='app.bsky.richtext.facet#link', alias='$type') class ByteSlice(base.ModelBase): @@ -49,4 +57,6 @@ class ByteSlice(base.ModelBase): byteEnd: int #: Byte end. byteStart: int #: Byte start. - _type: str = 'app.bsky.richtext.facet#byteSlice' + py_type: te.Literal['app.bsky.richtext.facet#byteSlice'] = Field( + default='app.bsky.richtext.facet#byteSlice', alias='$type' + ) diff --git a/atproto/xrpc_client/models/base.py b/atproto/xrpc_client/models/base.py index 48da0b2f..fa483ef6 100644 --- a/atproto/xrpc_client/models/base.py +++ b/atproto/xrpc_client/models/base.py @@ -12,6 +12,8 @@ class ModelBase(BaseModel): Provides square brackets [] notation to get attributes like in a dictionary. """ + # TODO enable! + def __getitem__(self, item: str): if hasattr(self, item): return getattr(self, item) diff --git a/atproto/xrpc_client/models/blob_ref.py b/atproto/xrpc_client/models/blob_ref.py index ca816d2c..0e76866d 100644 --- a/atproto/xrpc_client/models/blob_ref.py +++ b/atproto/xrpc_client/models/blob_ref.py @@ -1,41 +1,27 @@ import typing as t -from pydantic import BaseModel +import typing_extensions as te +from pydantic import BaseModel, ConfigDict, Field if t.TYPE_CHECKING: from atproto.cid import CID -class BlobRef(BaseModel): - def __init__(self, blob_type: str, mime_type: str, ref: str, size: int) -> None: - super().__init__() - self.blob_type = blob_type - self.mime_type = mime_type - self.ref = ref - self.size = size - - @property - def cid(self) -> 'CID': - from atproto.cid import CID +class BlobRefLink(BaseModel): + link: str = Field(alias='$link') - return CID.decode(self.ref) - @classmethod - def from_dict(cls, data: dict) -> 'BlobRef': - ref = data['ref'].encode('base58btc') if isinstance(data['ref'], CID) else data['ref']['$link'] +class BlobRef(BaseModel): + model_config = ConfigDict(extra='forbid') - return cls( - blob_type=data['$type'], - mime_type=data['mimeType'], - ref=ref, - size=int(data['size']), - ) + mime_type: str = Field(alias='mimeType') + size: int + ref: BlobRefLink - def to_dict(self) -> dict: - return {'$type': self.blob_type, 'mimeType': self.mime_type, 'size': self.size, 'ref': {'$link': self.ref}} + py_type: te.Literal['blob'] = Field(default='blob', alias='$type') - def __str__(self) -> str: - return str(self.to_dict()) + @property + def cid(self) -> 'CID': + from atproto.cid import CID - def __repr__(self) -> str: - return f'BlobRef({self})' + return CID.decode(self.ref.link) diff --git a/atproto/xrpc_client/models/com/atproto/admin/defs.py b/atproto/xrpc_client/models/com/atproto/admin/defs.py index 13b06932..0bdb97da 100644 --- a/atproto/xrpc_client/models/com/atproto/admin/defs.py +++ b/atproto/xrpc_client/models/com/atproto/admin/defs.py @@ -8,10 +8,11 @@ import typing as t import typing_extensions as te +from pydantic import Field if t.TYPE_CHECKING: from atproto.xrpc_client import models -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class ActionView(base.ModelBase): @@ -24,15 +25,18 @@ class ActionView(base.ModelBase): id: int #: Id. reason: str #: Reason. resolvedReportIds: t.List[int] #: Resolved report ids. - subject: t.Union[ - 'models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main', 't.Dict[str, t.Any]' + subject: te.Annotated[ + t.Union['models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main'], + Field(discriminator='py_type'), ] #: Subject. subjectBlobCids: t.List[str] #: Subject blob cids. createLabelVals: t.Optional[t.List[str]] = None #: Create label vals. negateLabelVals: t.Optional[t.List[str]] = None #: Negate label vals. reversal: t.Optional['models.ComAtprotoAdminDefs.ActionReversal'] = None #: Reversal. - _type: str = 'com.atproto.admin.defs#actionView' + py_type: te.Literal['com.atproto.admin.defs#actionView'] = Field( + default='com.atproto.admin.defs#actionView', alias='$type' + ) class ActionViewDetail(base.ModelBase): @@ -45,19 +49,23 @@ class ActionViewDetail(base.ModelBase): id: int #: Id. reason: str #: Reason. resolvedReports: t.List['models.ComAtprotoAdminDefs.ReportView'] #: Resolved reports. - subject: t.Union[ - 'models.ComAtprotoAdminDefs.RepoView', - 'models.ComAtprotoAdminDefs.RepoViewNotFound', - 'models.ComAtprotoAdminDefs.RecordView', - 'models.ComAtprotoAdminDefs.RecordViewNotFound', - 't.Dict[str, t.Any]', + subject: te.Annotated[ + t.Union[ + 'models.ComAtprotoAdminDefs.RepoView', + 'models.ComAtprotoAdminDefs.RepoViewNotFound', + 'models.ComAtprotoAdminDefs.RecordView', + 'models.ComAtprotoAdminDefs.RecordViewNotFound', + ], + Field(discriminator='py_type'), ] #: Subject. subjectBlobs: t.List['models.ComAtprotoAdminDefs.BlobView'] #: Subject blobs. createLabelVals: t.Optional[t.List[str]] = None #: Create label vals. negateLabelVals: t.Optional[t.List[str]] = None #: Negate label vals. reversal: t.Optional['models.ComAtprotoAdminDefs.ActionReversal'] = None #: Reversal. - _type: str = 'com.atproto.admin.defs#actionViewDetail' + py_type: te.Literal['com.atproto.admin.defs#actionViewDetail'] = Field( + default='com.atproto.admin.defs#actionViewDetail', alias='$type' + ) class ActionViewCurrent(base.ModelBase): @@ -67,7 +75,9 @@ class ActionViewCurrent(base.ModelBase): action: 'models.ComAtprotoAdminDefs.ActionType' #: Action. id: int #: Id. - _type: str = 'com.atproto.admin.defs#actionViewCurrent' + py_type: te.Literal['com.atproto.admin.defs#actionViewCurrent'] = Field( + default='com.atproto.admin.defs#actionViewCurrent', alias='$type' + ) class ActionReversal(base.ModelBase): @@ -78,7 +88,9 @@ class ActionReversal(base.ModelBase): createdBy: str #: Created by. reason: str #: Reason. - _type: str = 'com.atproto.admin.defs#actionReversal' + py_type: te.Literal['com.atproto.admin.defs#actionReversal'] = Field( + default='com.atproto.admin.defs#actionReversal', alias='$type' + ) ActionType = te.Literal['Takedown', 'Flag', 'Acknowledge', 'Escalate'] @@ -101,13 +113,16 @@ class ReportView(base.ModelBase): reasonType: 'models.ComAtprotoModerationDefs.ReasonType' #: Reason type. reportedBy: str #: Reported by. resolvedByActionIds: t.List[int] #: Resolved by action ids. - subject: t.Union[ - 'models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main', 't.Dict[str, t.Any]' + subject: te.Annotated[ + t.Union['models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main'], + Field(discriminator='py_type'), ] #: Subject. reason: t.Optional[str] = None #: Reason. subjectRepoHandle: t.Optional[str] = None #: Subject repo handle. - _type: str = 'com.atproto.admin.defs#reportView' + py_type: te.Literal['com.atproto.admin.defs#reportView'] = Field( + default='com.atproto.admin.defs#reportView', alias='$type' + ) class ReportViewDetail(base.ModelBase): @@ -119,16 +134,20 @@ class ReportViewDetail(base.ModelBase): reasonType: 'models.ComAtprotoModerationDefs.ReasonType' #: Reason type. reportedBy: str #: Reported by. resolvedByActions: t.List['models.ComAtprotoAdminDefs.ActionView'] #: Resolved by actions. - subject: t.Union[ - 'models.ComAtprotoAdminDefs.RepoView', - 'models.ComAtprotoAdminDefs.RepoViewNotFound', - 'models.ComAtprotoAdminDefs.RecordView', - 'models.ComAtprotoAdminDefs.RecordViewNotFound', - 't.Dict[str, t.Any]', + subject: te.Annotated[ + t.Union[ + 'models.ComAtprotoAdminDefs.RepoView', + 'models.ComAtprotoAdminDefs.RepoViewNotFound', + 'models.ComAtprotoAdminDefs.RecordView', + 'models.ComAtprotoAdminDefs.RecordViewNotFound', + ], + Field(discriminator='py_type'), ] #: Subject. reason: t.Optional[str] = None #: Reason. - _type: str = 'com.atproto.admin.defs#reportViewDetail' + py_type: te.Literal['com.atproto.admin.defs#reportViewDetail'] = Field( + default='com.atproto.admin.defs#reportViewDetail', alias='$type' + ) class RepoView(base.ModelBase): @@ -139,13 +158,15 @@ class RepoView(base.ModelBase): handle: str #: Handle. indexedAt: str #: Indexed at. moderation: 'models.ComAtprotoAdminDefs.Moderation' #: Moderation. - relatedRecords: t.List['base.UnknownDict'] #: Related records. + relatedRecords: t.List['unknown_type.UnknownRecordTypePydantic'] #: Related records. email: t.Optional[str] = None #: Email. inviteNote: t.Optional[str] = None #: Invite note. invitedBy: t.Optional['models.ComAtprotoServerDefs.InviteCode'] = None #: Invited by. invitesDisabled: t.Optional[bool] = None #: Invites disabled. - _type: str = 'com.atproto.admin.defs#repoView' + py_type: te.Literal['com.atproto.admin.defs#repoView'] = Field( + default='com.atproto.admin.defs#repoView', alias='$type' + ) class RepoViewDetail(base.ModelBase): @@ -156,7 +177,7 @@ class RepoViewDetail(base.ModelBase): handle: str #: Handle. indexedAt: str #: Indexed at. moderation: 'models.ComAtprotoAdminDefs.ModerationDetail' #: Moderation. - relatedRecords: t.List['base.UnknownDict'] #: Related records. + relatedRecords: t.List['unknown_type.UnknownRecordTypePydantic'] #: Related records. email: t.Optional[str] = None #: Email. inviteNote: t.Optional[str] = None #: Invite note. invitedBy: t.Optional['models.ComAtprotoServerDefs.InviteCode'] = None #: Invited by. @@ -164,7 +185,9 @@ class RepoViewDetail(base.ModelBase): invitesDisabled: t.Optional[bool] = None #: Invites disabled. labels: t.Optional[t.List['models.ComAtprotoLabelDefs.Label']] = None #: Labels. - _type: str = 'com.atproto.admin.defs#repoViewDetail' + py_type: te.Literal['com.atproto.admin.defs#repoViewDetail'] = Field( + default='com.atproto.admin.defs#repoViewDetail', alias='$type' + ) class RepoViewNotFound(base.ModelBase): @@ -173,7 +196,9 @@ class RepoViewNotFound(base.ModelBase): did: str #: Did. - _type: str = 'com.atproto.admin.defs#repoViewNotFound' + py_type: te.Literal['com.atproto.admin.defs#repoViewNotFound'] = Field( + default='com.atproto.admin.defs#repoViewNotFound', alias='$type' + ) class RepoRef(base.ModelBase): @@ -182,7 +207,9 @@ class RepoRef(base.ModelBase): did: str #: Did. - _type: str = 'com.atproto.admin.defs#repoRef' + py_type: te.Literal['com.atproto.admin.defs#repoRef'] = Field( + default='com.atproto.admin.defs#repoRef', alias='$type' + ) class RecordView(base.ModelBase): @@ -195,9 +222,11 @@ class RecordView(base.ModelBase): moderation: 'models.ComAtprotoAdminDefs.Moderation' #: Moderation. repo: 'models.ComAtprotoAdminDefs.RepoView' #: Repo. uri: str #: Uri. - value: 'base.UnknownDict' #: Value. + value: 'unknown_type.UnknownRecordTypePydantic' #: Value. - _type: str = 'com.atproto.admin.defs#recordView' + py_type: te.Literal['com.atproto.admin.defs#recordView'] = Field( + default='com.atproto.admin.defs#recordView', alias='$type' + ) class RecordViewDetail(base.ModelBase): @@ -210,10 +239,12 @@ class RecordViewDetail(base.ModelBase): moderation: 'models.ComAtprotoAdminDefs.ModerationDetail' #: Moderation. repo: 'models.ComAtprotoAdminDefs.RepoView' #: Repo. uri: str #: Uri. - value: 'base.UnknownDict' #: Value. + value: 'unknown_type.UnknownRecordTypePydantic' #: Value. labels: t.Optional[t.List['models.ComAtprotoLabelDefs.Label']] = None #: Labels. - _type: str = 'com.atproto.admin.defs#recordViewDetail' + py_type: te.Literal['com.atproto.admin.defs#recordViewDetail'] = Field( + default='com.atproto.admin.defs#recordViewDetail', alias='$type' + ) class RecordViewNotFound(base.ModelBase): @@ -222,7 +253,9 @@ class RecordViewNotFound(base.ModelBase): uri: str #: Uri. - _type: str = 'com.atproto.admin.defs#recordViewNotFound' + py_type: te.Literal['com.atproto.admin.defs#recordViewNotFound'] = Field( + default='com.atproto.admin.defs#recordViewNotFound', alias='$type' + ) class Moderation(base.ModelBase): @@ -231,7 +264,9 @@ class Moderation(base.ModelBase): currentAction: t.Optional['models.ComAtprotoAdminDefs.ActionViewCurrent'] = None #: Current action. - _type: str = 'com.atproto.admin.defs#moderation' + py_type: te.Literal['com.atproto.admin.defs#moderation'] = Field( + default='com.atproto.admin.defs#moderation', alias='$type' + ) class ModerationDetail(base.ModelBase): @@ -242,7 +277,9 @@ class ModerationDetail(base.ModelBase): reports: t.List['models.ComAtprotoAdminDefs.ReportView'] #: Reports. currentAction: t.Optional['models.ComAtprotoAdminDefs.ActionViewCurrent'] = None #: Current action. - _type: str = 'com.atproto.admin.defs#moderationDetail' + py_type: te.Literal['com.atproto.admin.defs#moderationDetail'] = Field( + default='com.atproto.admin.defs#moderationDetail', alias='$type' + ) class BlobView(base.ModelBase): @@ -254,13 +291,16 @@ class BlobView(base.ModelBase): mimeType: str #: Mime type. size: int #: Size. details: t.Optional[ - t.Union[ - 'models.ComAtprotoAdminDefs.ImageDetails', 'models.ComAtprotoAdminDefs.VideoDetails', 't.Dict[str, t.Any]' + te.Annotated[ + t.Union['models.ComAtprotoAdminDefs.ImageDetails', 'models.ComAtprotoAdminDefs.VideoDetails'], + Field(default=None, discriminator='py_type'), ] ] = None #: Details. moderation: t.Optional['models.ComAtprotoAdminDefs.Moderation'] = None #: Moderation. - _type: str = 'com.atproto.admin.defs#blobView' + py_type: te.Literal['com.atproto.admin.defs#blobView'] = Field( + default='com.atproto.admin.defs#blobView', alias='$type' + ) class ImageDetails(base.ModelBase): @@ -270,7 +310,9 @@ class ImageDetails(base.ModelBase): height: int #: Height. width: int #: Width. - _type: str = 'com.atproto.admin.defs#imageDetails' + py_type: te.Literal['com.atproto.admin.defs#imageDetails'] = Field( + default='com.atproto.admin.defs#imageDetails', alias='$type' + ) class VideoDetails(base.ModelBase): @@ -281,4 +323,6 @@ class VideoDetails(base.ModelBase): length: int #: Length. width: int #: Width. - _type: str = 'com.atproto.admin.defs#videoDetails' + py_type: te.Literal['com.atproto.admin.defs#videoDetails'] = Field( + default='com.atproto.admin.defs#videoDetails', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/admin/get_moderation_action.py b/atproto/xrpc_client/models/com/atproto/admin/get_moderation_action.py index ba46c998..c4142bda 100644 --- a/atproto/xrpc_client/models/com/atproto/admin/get_moderation_action.py +++ b/atproto/xrpc_client/models/com/atproto/admin/get_moderation_action.py @@ -17,7 +17,3 @@ class Params(base.ParamsModelBase): """Parameters model for :obj:`com.atproto.admin.getModerationAction`.""" id: int #: Id. - - -#: Response reference to :obj:`models.ComAtprotoAdminDefs.ActionViewDetail` model. -ResponseRef = 'models.ComAtprotoAdminDefs.ActionViewDetail' diff --git a/atproto/xrpc_client/models/com/atproto/admin/get_moderation_report.py b/atproto/xrpc_client/models/com/atproto/admin/get_moderation_report.py index 33abbd02..c6a04b2a 100644 --- a/atproto/xrpc_client/models/com/atproto/admin/get_moderation_report.py +++ b/atproto/xrpc_client/models/com/atproto/admin/get_moderation_report.py @@ -17,7 +17,3 @@ class Params(base.ParamsModelBase): """Parameters model for :obj:`com.atproto.admin.getModerationReport`.""" id: int #: Id. - - -#: Response reference to :obj:`models.ComAtprotoAdminDefs.ReportViewDetail` model. -ResponseRef = 'models.ComAtprotoAdminDefs.ReportViewDetail' diff --git a/atproto/xrpc_client/models/com/atproto/admin/get_record.py b/atproto/xrpc_client/models/com/atproto/admin/get_record.py index 250aa90a..f00ab62b 100644 --- a/atproto/xrpc_client/models/com/atproto/admin/get_record.py +++ b/atproto/xrpc_client/models/com/atproto/admin/get_record.py @@ -18,7 +18,3 @@ class Params(base.ParamsModelBase): uri: str #: Uri. cid: t.Optional[str] = None #: Cid. - - -#: Response reference to :obj:`models.ComAtprotoAdminDefs.RecordViewDetail` model. -ResponseRef = 'models.ComAtprotoAdminDefs.RecordViewDetail' diff --git a/atproto/xrpc_client/models/com/atproto/admin/get_repo.py b/atproto/xrpc_client/models/com/atproto/admin/get_repo.py index c7f7b1e9..3a5add5c 100644 --- a/atproto/xrpc_client/models/com/atproto/admin/get_repo.py +++ b/atproto/xrpc_client/models/com/atproto/admin/get_repo.py @@ -17,7 +17,3 @@ class Params(base.ParamsModelBase): """Parameters model for :obj:`com.atproto.admin.getRepo`.""" did: str #: Did. - - -#: Response reference to :obj:`models.ComAtprotoAdminDefs.RepoViewDetail` model. -ResponseRef = 'models.ComAtprotoAdminDefs.RepoViewDetail' diff --git a/atproto/xrpc_client/models/com/atproto/admin/resolve_moderation_reports.py b/atproto/xrpc_client/models/com/atproto/admin/resolve_moderation_reports.py index ec3d6742..e54083a3 100644 --- a/atproto/xrpc_client/models/com/atproto/admin/resolve_moderation_reports.py +++ b/atproto/xrpc_client/models/com/atproto/admin/resolve_moderation_reports.py @@ -19,7 +19,3 @@ class Data(base.DataModelBase): actionId: int #: Action id. createdBy: str #: Created by. reportIds: t.List[int] #: Report ids. - - -#: Response reference to :obj:`models.ComAtprotoAdminDefs.ActionView` model. -ResponseRef = 'models.ComAtprotoAdminDefs.ActionView' diff --git a/atproto/xrpc_client/models/com/atproto/admin/reverse_moderation_action.py b/atproto/xrpc_client/models/com/atproto/admin/reverse_moderation_action.py index 302ce296..b3648727 100644 --- a/atproto/xrpc_client/models/com/atproto/admin/reverse_moderation_action.py +++ b/atproto/xrpc_client/models/com/atproto/admin/reverse_moderation_action.py @@ -19,7 +19,3 @@ class Data(base.DataModelBase): createdBy: str #: Created by. id: int #: Id. reason: str #: Reason. - - -#: Response reference to :obj:`models.ComAtprotoAdminDefs.ActionView` model. -ResponseRef = 'models.ComAtprotoAdminDefs.ActionView' diff --git a/atproto/xrpc_client/models/com/atproto/admin/take_moderation_action.py b/atproto/xrpc_client/models/com/atproto/admin/take_moderation_action.py index 538b2698..3fee26ce 100644 --- a/atproto/xrpc_client/models/com/atproto/admin/take_moderation_action.py +++ b/atproto/xrpc_client/models/com/atproto/admin/take_moderation_action.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -19,13 +22,10 @@ class Data(base.DataModelBase): action: str #: Action. createdBy: str #: Created by. reason: str #: Reason. - subject: t.Union[ - 'models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main', 't.Dict[str, t.Any]' + subject: te.Annotated[ + t.Union['models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main'], + Field(discriminator='py_type'), ] #: Subject. createLabelVals: t.Optional[t.List[str]] = None #: Create label vals. negateLabelVals: t.Optional[t.List[str]] = None #: Negate label vals. subjectBlobCids: t.Optional[t.List[str]] = None #: Subject blob cids. - - -#: Response reference to :obj:`models.ComAtprotoAdminDefs.ActionView` model. -ResponseRef = 'models.ComAtprotoAdminDefs.ActionView' diff --git a/atproto/xrpc_client/models/com/atproto/label/defs.py b/atproto/xrpc_client/models/com/atproto/label/defs.py index ead1f7b0..14cd6e43 100644 --- a/atproto/xrpc_client/models/com/atproto/label/defs.py +++ b/atproto/xrpc_client/models/com/atproto/label/defs.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -25,7 +28,7 @@ class Label(base.ModelBase): ] = None #: optionally, CID specifying the specific version of 'uri' resource this label applies to. neg: t.Optional[bool] = None #: if true, this is a negation label, overwriting a previous label. - _type: str = 'com.atproto.label.defs#label' + py_type: te.Literal['com.atproto.label.defs#label'] = Field(default='com.atproto.label.defs#label', alias='$type') class SelfLabels(base.ModelBase): @@ -34,7 +37,9 @@ class SelfLabels(base.ModelBase): values: t.List['models.ComAtprotoLabelDefs.SelfLabel'] #: Values. - _type: str = 'com.atproto.label.defs#selfLabels' + py_type: te.Literal['com.atproto.label.defs#selfLabels'] = Field( + default='com.atproto.label.defs#selfLabels', alias='$type' + ) class SelfLabel(base.ModelBase): @@ -43,4 +48,6 @@ class SelfLabel(base.ModelBase): val: str #: the short string name of the value or type of this label. - _type: str = 'com.atproto.label.defs#selfLabel' + py_type: te.Literal['com.atproto.label.defs#selfLabel'] = Field( + default='com.atproto.label.defs#selfLabel', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/label/subscribe_labels.py b/atproto/xrpc_client/models/com/atproto/label/subscribe_labels.py index a1020634..9a1e6a7a 100644 --- a/atproto/xrpc_client/models/com/atproto/label/subscribe_labels.py +++ b/atproto/xrpc_client/models/com/atproto/label/subscribe_labels.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -26,7 +29,9 @@ class Labels(base.ModelBase): labels: t.List['models.ComAtprotoLabelDefs.Label'] #: Labels. seq: int #: Seq. - _type: str = 'com.atproto.label.subscribeLabels#labels' + py_type: te.Literal['com.atproto.label.subscribeLabels#labels'] = Field( + default='com.atproto.label.subscribeLabels#labels', alias='$type' + ) class Info(base.ModelBase): @@ -36,4 +41,6 @@ class Info(base.ModelBase): name: str #: Name. message: t.Optional[str] = None #: Message. - _type: str = 'com.atproto.label.subscribeLabels#info' + py_type: te.Literal['com.atproto.label.subscribeLabels#info'] = Field( + default='com.atproto.label.subscribeLabels#info', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/moderation/create_report.py b/atproto/xrpc_client/models/com/atproto/moderation/create_report.py index aaad217b..02c91786 100644 --- a/atproto/xrpc_client/models/com/atproto/moderation/create_report.py +++ b/atproto/xrpc_client/models/com/atproto/moderation/create_report.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -17,8 +20,9 @@ class Data(base.DataModelBase): """Input data model for :obj:`com.atproto.moderation.createReport`.""" reasonType: 'models.ComAtprotoModerationDefs.ReasonType' #: Reason type. - subject: t.Union[ - 'models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main', 't.Dict[str, t.Any]' + subject: te.Annotated[ + t.Union['models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main'], + Field(discriminator='py_type'), ] #: Subject. reason: t.Optional[str] = None #: Reason. @@ -31,7 +35,8 @@ class Response(base.ResponseModelBase): id: int #: Id. reasonType: 'models.ComAtprotoModerationDefs.ReasonType' #: Reason type. reportedBy: str #: Reported by. - subject: t.Union[ - 'models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main', 't.Dict[str, t.Any]' + subject: te.Annotated[ + t.Union['models.ComAtprotoAdminDefs.RepoRef', 'models.ComAtprotoRepoStrongRef.Main'], + Field(discriminator='py_type'), ] #: Subject. reason: t.Optional[str] = None #: Reason. diff --git a/atproto/xrpc_client/models/com/atproto/repo/apply_writes.py b/atproto/xrpc_client/models/com/atproto/repo/apply_writes.py index f5a79518..9b7cfcea 100644 --- a/atproto/xrpc_client/models/com/atproto/repo/apply_writes.py +++ b/atproto/xrpc_client/models/com/atproto/repo/apply_writes.py @@ -7,9 +7,12 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class Data(base.DataModelBase): @@ -18,15 +21,17 @@ class Data(base.DataModelBase): repo: str #: The handle or DID of the repo. writes: t.List[ - t.Union[ - 'models.ComAtprotoRepoApplyWrites.Create', - 'models.ComAtprotoRepoApplyWrites.Update', - 'models.ComAtprotoRepoApplyWrites.Delete', - 't.Dict[str, t.Any]', + te.Annotated[ + t.Union[ + 'models.ComAtprotoRepoApplyWrites.Create', + 'models.ComAtprotoRepoApplyWrites.Update', + 'models.ComAtprotoRepoApplyWrites.Delete', + ], + Field(discriminator='py_type'), ] ] #: Writes. swapCommit: t.Optional[str] = None #: Swap commit. - validateFixMe: t.Optional[bool] = None #: Validate the records? + validateAliasMe: t.Optional[bool] = None #: Validate the records? class Create(base.ModelBase): @@ -34,10 +39,12 @@ class Create(base.ModelBase): """Definition model for :obj:`com.atproto.repo.applyWrites`. Create a new record.""" collection: str #: Collection. - value: 'base.UnknownDict' #: Value. + value: 'unknown_type.UnknownRecordTypePydantic' #: Value. rkey: t.Optional[str] = None #: Rkey. - _type: str = 'com.atproto.repo.applyWrites#create' + py_type: te.Literal['com.atproto.repo.applyWrites#create'] = Field( + default='com.atproto.repo.applyWrites#create', alias='$type' + ) class Update(base.ModelBase): @@ -46,9 +53,11 @@ class Update(base.ModelBase): collection: str #: Collection. rkey: str #: Rkey. - value: 'base.UnknownDict' #: Value. + value: 'unknown_type.UnknownRecordTypePydantic' #: Value. - _type: str = 'com.atproto.repo.applyWrites#update' + py_type: te.Literal['com.atproto.repo.applyWrites#update'] = Field( + default='com.atproto.repo.applyWrites#update', alias='$type' + ) class Delete(base.ModelBase): @@ -58,4 +67,6 @@ class Delete(base.ModelBase): collection: str #: Collection. rkey: str #: Rkey. - _type: str = 'com.atproto.repo.applyWrites#delete' + py_type: te.Literal['com.atproto.repo.applyWrites#delete'] = Field( + default='com.atproto.repo.applyWrites#delete', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/repo/create_record.py b/atproto/xrpc_client/models/com/atproto/repo/create_record.py index bd0683bc..bdf9cbfa 100644 --- a/atproto/xrpc_client/models/com/atproto/repo/create_record.py +++ b/atproto/xrpc_client/models/com/atproto/repo/create_record.py @@ -9,7 +9,7 @@ if t.TYPE_CHECKING: pass -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class Data(base.DataModelBase): @@ -17,11 +17,11 @@ class Data(base.DataModelBase): """Input data model for :obj:`com.atproto.repo.createRecord`.""" collection: str #: The NSID of the record collection. - record: 'base.UnknownDict' #: The record to create. + record: 'unknown_type.UnknownRecordTypePydantic' #: The record to create. repo: str #: The handle or DID of the repo. rkey: t.Optional[str] = None #: The key of the record. swapCommit: t.Optional[str] = None #: Compare and swap with the previous commit by cid. - validateFixMe: t.Optional[bool] = None #: Validate the record? + validateAliasMe: t.Optional[bool] = None #: Validate the record? class Response(base.ResponseModelBase): diff --git a/atproto/xrpc_client/models/com/atproto/repo/describe_repo.py b/atproto/xrpc_client/models/com/atproto/repo/describe_repo.py index fa6c7a90..938acb98 100644 --- a/atproto/xrpc_client/models/com/atproto/repo/describe_repo.py +++ b/atproto/xrpc_client/models/com/atproto/repo/describe_repo.py @@ -9,7 +9,7 @@ if t.TYPE_CHECKING: pass -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class Params(base.ParamsModelBase): @@ -25,6 +25,6 @@ class Response(base.ResponseModelBase): collections: t.List[str] #: Collections. did: str #: Did. - didDoc: 'base.UnknownDict' #: Did doc. + didDoc: 'unknown_type.UnknownRecordTypePydantic' #: Did doc. handle: str #: Handle. handleIsCorrect: bool #: Handle is correct. diff --git a/atproto/xrpc_client/models/com/atproto/repo/get_record.py b/atproto/xrpc_client/models/com/atproto/repo/get_record.py index 11e964e1..e3a2373d 100644 --- a/atproto/xrpc_client/models/com/atproto/repo/get_record.py +++ b/atproto/xrpc_client/models/com/atproto/repo/get_record.py @@ -9,7 +9,7 @@ if t.TYPE_CHECKING: pass -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class Params(base.ParamsModelBase): @@ -29,5 +29,5 @@ class Response(base.ResponseModelBase): """Output data model for :obj:`com.atproto.repo.getRecord`.""" uri: str #: Uri. - value: 'base.UnknownDict' #: Value. + value: 'unknown_type.UnknownRecordTypePydantic' #: Value. cid: t.Optional[str] = None #: Cid. diff --git a/atproto/xrpc_client/models/com/atproto/repo/list_records.py b/atproto/xrpc_client/models/com/atproto/repo/list_records.py index c69aef1a..3288c9f5 100644 --- a/atproto/xrpc_client/models/com/atproto/repo/list_records.py +++ b/atproto/xrpc_client/models/com/atproto/repo/list_records.py @@ -7,9 +7,12 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class Params(base.ParamsModelBase): @@ -39,6 +42,8 @@ class Record(base.ModelBase): cid: str #: Cid. uri: str #: Uri. - value: 'base.UnknownDict' #: Value. + value: 'unknown_type.UnknownRecordTypePydantic' #: Value. - _type: str = 'com.atproto.repo.listRecords#record' + py_type: te.Literal['com.atproto.repo.listRecords#record'] = Field( + default='com.atproto.repo.listRecords#record', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/repo/put_record.py b/atproto/xrpc_client/models/com/atproto/repo/put_record.py index 5806716e..7136ac44 100644 --- a/atproto/xrpc_client/models/com/atproto/repo/put_record.py +++ b/atproto/xrpc_client/models/com/atproto/repo/put_record.py @@ -9,7 +9,7 @@ if t.TYPE_CHECKING: pass -from atproto.xrpc_client.models import base +from atproto.xrpc_client.models import base, unknown_type class Data(base.DataModelBase): @@ -17,12 +17,12 @@ class Data(base.DataModelBase): """Input data model for :obj:`com.atproto.repo.putRecord`.""" collection: str #: The NSID of the record collection. - record: 'base.UnknownDict' #: The record to write. + record: 'unknown_type.UnknownRecordTypePydantic' #: The record to write. repo: str #: The handle or DID of the repo. rkey: str #: The key of the record. swapCommit: t.Optional[str] = None #: Compare and swap with the previous commit by cid. swapRecord: t.Optional[str] = None #: Compare and swap with the previous record by cid. - validateFixMe: t.Optional[bool] = None #: Validate the record? + validateAliasMe: t.Optional[bool] = None #: Validate the record? class Response(base.ResponseModelBase): diff --git a/atproto/xrpc_client/models/com/atproto/repo/strong_ref.py b/atproto/xrpc_client/models/com/atproto/repo/strong_ref.py index 5de6322b..7b343574 100644 --- a/atproto/xrpc_client/models/com/atproto/repo/strong_ref.py +++ b/atproto/xrpc_client/models/com/atproto/repo/strong_ref.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: pass from atproto.xrpc_client.models import base @@ -19,4 +22,4 @@ class Main(base.ModelBase): cid: str #: Cid. uri: str #: Uri. - _type: str = 'com.atproto.repo.strongRef' + py_type: te.Literal['com.atproto.repo.strongRef'] = Field(default='com.atproto.repo.strongRef', alias='$type') diff --git a/atproto/xrpc_client/models/com/atproto/server/create_app_password.py b/atproto/xrpc_client/models/com/atproto/server/create_app_password.py index 987d1f87..a9663bf1 100644 --- a/atproto/xrpc_client/models/com/atproto/server/create_app_password.py +++ b/atproto/xrpc_client/models/com/atproto/server/create_app_password.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: pass from atproto.xrpc_client.models import base @@ -27,8 +30,6 @@ class AppPassword(base.ModelBase): name: str #: Name. password: str #: Password. - _type: str = 'com.atproto.server.createAppPassword#appPassword' - - -#: Response reference to :obj:`AppPassword` model. -ResponseRef = 'AppPassword' + py_type: te.Literal['com.atproto.server.createAppPassword#appPassword'] = Field( + default='com.atproto.server.createAppPassword#appPassword', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/server/create_invite_codes.py b/atproto/xrpc_client/models/com/atproto/server/create_invite_codes.py index 09382318..e4839c60 100644 --- a/atproto/xrpc_client/models/com/atproto/server/create_invite_codes.py +++ b/atproto/xrpc_client/models/com/atproto/server/create_invite_codes.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -35,4 +38,6 @@ class AccountCodes(base.ModelBase): account: str #: Account. codes: t.List[str] #: Codes. - _type: str = 'com.atproto.server.createInviteCodes#accountCodes' + py_type: te.Literal['com.atproto.server.createInviteCodes#accountCodes'] = Field( + default='com.atproto.server.createInviteCodes#accountCodes', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/server/defs.py b/atproto/xrpc_client/models/com/atproto/server/defs.py index fe8ad5d2..deb72907 100644 --- a/atproto/xrpc_client/models/com/atproto/server/defs.py +++ b/atproto/xrpc_client/models/com/atproto/server/defs.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -24,7 +27,9 @@ class InviteCode(base.ModelBase): forAccount: str #: For account. uses: t.List['models.ComAtprotoServerDefs.InviteCodeUse'] #: Uses. - _type: str = 'com.atproto.server.defs#inviteCode' + py_type: te.Literal['com.atproto.server.defs#inviteCode'] = Field( + default='com.atproto.server.defs#inviteCode', alias='$type' + ) class InviteCodeUse(base.ModelBase): @@ -34,4 +39,6 @@ class InviteCodeUse(base.ModelBase): usedAt: str #: Used at. usedBy: str #: Used by. - _type: str = 'com.atproto.server.defs#inviteCodeUse' + py_type: te.Literal['com.atproto.server.defs#inviteCodeUse'] = Field( + default='com.atproto.server.defs#inviteCodeUse', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/server/describe_server.py b/atproto/xrpc_client/models/com/atproto/server/describe_server.py index 06345f0f..9d9e84f8 100644 --- a/atproto/xrpc_client/models/com/atproto/server/describe_server.py +++ b/atproto/xrpc_client/models/com/atproto/server/describe_server.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -28,4 +31,6 @@ class Links(base.ModelBase): privacyPolicy: t.Optional[str] = None #: Privacy policy. termsOfService: t.Optional[str] = None #: Terms of service. - _type: str = 'com.atproto.server.describeServer#links' + py_type: te.Literal['com.atproto.server.describeServer#links'] = Field( + default='com.atproto.server.describeServer#links', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/server/list_app_passwords.py b/atproto/xrpc_client/models/com/atproto/server/list_app_passwords.py index f7a9e850..1e1fec83 100644 --- a/atproto/xrpc_client/models/com/atproto/server/list_app_passwords.py +++ b/atproto/xrpc_client/models/com/atproto/server/list_app_passwords.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -26,4 +29,6 @@ class AppPassword(base.ModelBase): createdAt: str #: Created at. name: str #: Name. - _type: str = 'com.atproto.server.listAppPasswords#appPassword' + py_type: te.Literal['com.atproto.server.listAppPasswords#appPassword'] = Field( + default='com.atproto.server.listAppPasswords#appPassword', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/sync/list_repos.py b/atproto/xrpc_client/models/com/atproto/sync/list_repos.py index 86f981a2..7218bb92 100644 --- a/atproto/xrpc_client/models/com/atproto/sync/list_repos.py +++ b/atproto/xrpc_client/models/com/atproto/sync/list_repos.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto.xrpc_client import models from atproto.xrpc_client.models import base @@ -35,4 +38,6 @@ class Repo(base.ModelBase): did: str #: Did. head: str #: Head. - _type: str = 'com.atproto.sync.listRepos#repo' + py_type: te.Literal['com.atproto.sync.listRepos#repo'] = Field( + default='com.atproto.sync.listRepos#repo', alias='$type' + ) diff --git a/atproto/xrpc_client/models/com/atproto/sync/subscribe_repos.py b/atproto/xrpc_client/models/com/atproto/sync/subscribe_repos.py index 6e8a625c..8a2c29e8 100644 --- a/atproto/xrpc_client/models/com/atproto/sync/subscribe_repos.py +++ b/atproto/xrpc_client/models/com/atproto/sync/subscribe_repos.py @@ -7,6 +7,9 @@ import typing as t +import typing_extensions as te +from pydantic import Field + if t.TYPE_CHECKING: from atproto import CID from atproto.xrpc_client import models @@ -35,7 +38,9 @@ class Commit(base.ModelBase): tooBig: bool #: Too big. prev: t.Optional['CID'] = None #: Prev. - _type: str = 'com.atproto.sync.subscribeRepos#commit' + py_type: te.Literal['com.atproto.sync.subscribeRepos#commit'] = Field( + default='com.atproto.sync.subscribeRepos#commit', alias='$type' + ) class Handle(base.ModelBase): @@ -47,7 +52,9 @@ class Handle(base.ModelBase): seq: int #: Seq. time: str #: Time. - _type: str = 'com.atproto.sync.subscribeRepos#handle' + py_type: te.Literal['com.atproto.sync.subscribeRepos#handle'] = Field( + default='com.atproto.sync.subscribeRepos#handle', alias='$type' + ) class Migrate(base.ModelBase): @@ -59,7 +66,9 @@ class Migrate(base.ModelBase): time: str #: Time. migrateTo: t.Optional[str] = None #: Migrate to. - _type: str = 'com.atproto.sync.subscribeRepos#migrate' + py_type: te.Literal['com.atproto.sync.subscribeRepos#migrate'] = Field( + default='com.atproto.sync.subscribeRepos#migrate', alias='$type' + ) class Tombstone(base.ModelBase): @@ -70,7 +79,9 @@ class Tombstone(base.ModelBase): seq: int #: Seq. time: str #: Time. - _type: str = 'com.atproto.sync.subscribeRepos#tombstone' + py_type: te.Literal['com.atproto.sync.subscribeRepos#tombstone'] = Field( + default='com.atproto.sync.subscribeRepos#tombstone', alias='$type' + ) class Info(base.ModelBase): @@ -80,7 +91,9 @@ class Info(base.ModelBase): name: str #: Name. message: t.Optional[str] = None #: Message. - _type: str = 'com.atproto.sync.subscribeRepos#info' + py_type: te.Literal['com.atproto.sync.subscribeRepos#info'] = Field( + default='com.atproto.sync.subscribeRepos#info', alias='$type' + ) class RepoOp(base.ModelBase): @@ -91,4 +104,6 @@ class RepoOp(base.ModelBase): path: str #: Path. cid: t.Optional['CID'] = None #: Cid. - _type: str = 'com.atproto.sync.subscribeRepos#repoOp' + py_type: te.Literal['com.atproto.sync.subscribeRepos#repoOp'] = Field( + default='com.atproto.sync.subscribeRepos#repoOp', alias='$type' + ) diff --git a/atproto/xrpc_client/models/unknown_type.py b/atproto/xrpc_client/models/unknown_type.py index 4042caa6..ccf73f1e 100644 --- a/atproto/xrpc_client/models/unknown_type.py +++ b/atproto/xrpc_client/models/unknown_type.py @@ -1,6 +1,7 @@ import typing as t import typing_extensions as te +from pydantic import Field if t.TYPE_CHECKING: from atproto.xrpc_client import models @@ -16,3 +17,17 @@ 'models.AppBskyGraphBlock.Main', 'models.AppBskyFeedPost.Main', ] +UnknownRecordTypePydantic = te.Annotated[ + t.Union[ + 'models.AppBskyFeedGenerator.Main', + 'models.AppBskyActorProfile.Main', + 'models.AppBskyFeedRepost.Main', + 'models.AppBskyGraphListitem.Main', + 'models.AppBskyFeedLike.Main', + 'models.AppBskyGraphFollow.Main', + 'models.AppBskyGraphList.Main', + 'models.AppBskyGraphBlock.Main', + 'models.AppBskyFeedPost.Main', + ], + Field(discriminator='py_type'), +] diff --git a/atproto/xrpc_client/models/utils.py b/atproto/xrpc_client/models/utils.py index 9757d55b..85eaae21 100644 --- a/atproto/xrpc_client/models/utils.py +++ b/atproto/xrpc_client/models/utils.py @@ -45,7 +45,6 @@ def _decode_cid_hook(ref: t.Union[CID, str]) -> CID: _TYPE_HOOKS = { - BlobRef: lambda ref: BlobRef.from_dict(ref), CID: _decode_cid_hook, UnknownDict: _unknown_type_hook, } @@ -160,8 +159,6 @@ def _handle_dict_key(key: str) -> str: def _handle_dict_value(ref: t.Any) -> t.Any: - if isinstance(ref, BlobRef): - return ref.to_dict() if isinstance(ref, CID): return ref.encode() @@ -174,10 +171,10 @@ def _model_as_dict_factory(value) -> dict: def get_model_as_dict(model: t.Union[BlobRef, ModelBase]) -> dict: - if isinstance(model, (BlobRef, DotDict)): + if isinstance(model, DotDict): return model.to_dict() - return model.model_dump() + return model.model_dump(exclude_none=True) if not dataclasses.is_dataclass(model): raise ModelError('Invalid model') @@ -186,6 +183,7 @@ def get_model_as_dict(model: t.Union[BlobRef, ModelBase]) -> dict: def get_model_as_json(model: t.Union[BlobRef, ModelBase]) -> str: + return model.model_dump_json(exclude_none=True, by_alias=True) return json.dumps(get_model_as_dict(model)) @@ -227,7 +225,7 @@ def is_record_type(model: ModelBase, expected_type: t.Union[str, types.ModuleTyp if not hasattr(expected_type, 'Main'): return False - expected_type = expected_type.Main._type + expected_type = expected_type.Main.model_fields['py_type'].default if isinstance(model, DotDict): # custom (extended) record try: @@ -235,4 +233,4 @@ def is_record_type(model: ModelBase, expected_type: t.Union[str, types.ModuleTyp except ModelFieldNotFoundError: return False - return expected_type == model._type + return expected_type == model.py_type diff --git a/atproto/xrpc_client/namespaces/async_ns.py b/atproto/xrpc_client/namespaces/async_ns.py index be43debd..1aea73ff 100644 --- a/atproto/xrpc_client/namespaces/async_ns.py +++ b/atproto/xrpc_client/namespaces/async_ns.py @@ -56,7 +56,7 @@ async def get_preferences( async def get_profile( self, params: t.Union[dict, 'models.AppBskyActorGetProfile.Params'], **kwargs - ) -> 'models.AppBskyActorGetProfile.ResponseRef': + ) -> 'models.AppBskyActorDefs.ProfileViewDetailed': """Get profile. Args: @@ -64,7 +64,7 @@ async def get_profile( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.AppBskyActorGetProfile.ResponseRef`: Output model. + :obj:`models.AppBskyActorDefs.ProfileViewDetailed`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -74,7 +74,7 @@ async def get_profile( response = await self._client.invoke_query( 'app.bsky.actor.getProfile', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.AppBskyActorGetProfile.ResponseRef) + return get_response_model(response, models.AppBskyActorDefs.ProfileViewDetailed) async def get_profiles( self, params: t.Union[dict, 'models.AppBskyActorGetProfiles.Params'], **kwargs @@ -1191,7 +1191,7 @@ async def get_invite_codes( async def get_moderation_action( self, params: t.Union[dict, 'models.ComAtprotoAdminGetModerationAction.Params'], **kwargs - ) -> 'models.ComAtprotoAdminGetModerationAction.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ActionViewDetail': """View details about a moderation action. Args: @@ -1199,7 +1199,7 @@ async def get_moderation_action( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminGetModerationAction.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ActionViewDetail`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1209,7 +1209,7 @@ async def get_moderation_action( response = await self._client.invoke_query( 'com.atproto.admin.getModerationAction', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.ComAtprotoAdminGetModerationAction.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ActionViewDetail) async def get_moderation_actions( self, params: t.Optional[t.Union[dict, 'models.ComAtprotoAdminGetModerationActions.Params']] = None, **kwargs @@ -1235,7 +1235,7 @@ async def get_moderation_actions( async def get_moderation_report( self, params: t.Union[dict, 'models.ComAtprotoAdminGetModerationReport.Params'], **kwargs - ) -> 'models.ComAtprotoAdminGetModerationReport.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ReportViewDetail': """View details about a moderation report. Args: @@ -1243,7 +1243,7 @@ async def get_moderation_report( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminGetModerationReport.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ReportViewDetail`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1253,7 +1253,7 @@ async def get_moderation_report( response = await self._client.invoke_query( 'com.atproto.admin.getModerationReport', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.ComAtprotoAdminGetModerationReport.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ReportViewDetail) async def get_moderation_reports( self, params: t.Optional[t.Union[dict, 'models.ComAtprotoAdminGetModerationReports.Params']] = None, **kwargs @@ -1279,7 +1279,7 @@ async def get_moderation_reports( async def get_record( self, params: t.Union[dict, 'models.ComAtprotoAdminGetRecord.Params'], **kwargs - ) -> 'models.ComAtprotoAdminGetRecord.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.RecordViewDetail': """View details about a record. Args: @@ -1287,7 +1287,7 @@ async def get_record( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminGetRecord.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.RecordViewDetail`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1297,11 +1297,11 @@ async def get_record( response = await self._client.invoke_query( 'com.atproto.admin.getRecord', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.ComAtprotoAdminGetRecord.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.RecordViewDetail) async def get_repo( self, params: t.Union[dict, 'models.ComAtprotoAdminGetRepo.Params'], **kwargs - ) -> 'models.ComAtprotoAdminGetRepo.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.RepoViewDetail': """View details about a repository. Args: @@ -1309,7 +1309,7 @@ async def get_repo( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminGetRepo.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.RepoViewDetail`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1319,7 +1319,7 @@ async def get_repo( response = await self._client.invoke_query( 'com.atproto.admin.getRepo', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.ComAtprotoAdminGetRepo.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.RepoViewDetail) async def rebase_repo(self, data: t.Union[dict, 'models.ComAtprotoAdminRebaseRepo.Data'], **kwargs) -> bool: """Administrative action to rebase an account's repo. @@ -1343,7 +1343,7 @@ async def rebase_repo(self, data: t.Union[dict, 'models.ComAtprotoAdminRebaseRep async def resolve_moderation_reports( self, data: t.Union[dict, 'models.ComAtprotoAdminResolveModerationReports.Data'], **kwargs - ) -> 'models.ComAtprotoAdminResolveModerationReports.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ActionView': """Resolve moderation reports by an action. Args: @@ -1351,7 +1351,7 @@ async def resolve_moderation_reports( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminResolveModerationReports.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ActionView`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1365,11 +1365,11 @@ async def resolve_moderation_reports( output_encoding='application/json', **kwargs, ) - return get_response_model(response, models.ComAtprotoAdminResolveModerationReports.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ActionView) async def reverse_moderation_action( self, data: t.Union[dict, 'models.ComAtprotoAdminReverseModerationAction.Data'], **kwargs - ) -> 'models.ComAtprotoAdminReverseModerationAction.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ActionView': """Reverse a moderation action. Args: @@ -1377,7 +1377,7 @@ async def reverse_moderation_action( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminReverseModerationAction.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ActionView`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1391,7 +1391,7 @@ async def reverse_moderation_action( output_encoding='application/json', **kwargs, ) - return get_response_model(response, models.ComAtprotoAdminReverseModerationAction.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ActionView) async def search_repos( self, params: t.Optional[t.Union[dict, 'models.ComAtprotoAdminSearchRepos.Params']] = None, **kwargs @@ -1443,7 +1443,7 @@ async def send_email( async def take_moderation_action( self, data: t.Union[dict, 'models.ComAtprotoAdminTakeModerationAction.Data'], **kwargs - ) -> 'models.ComAtprotoAdminTakeModerationAction.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ActionView': """Take a moderation action on a repo. Args: @@ -1451,7 +1451,7 @@ async def take_moderation_action( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminTakeModerationAction.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ActionView`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1465,7 +1465,7 @@ async def take_moderation_action( output_encoding='application/json', **kwargs, ) - return get_response_model(response, models.ComAtprotoAdminTakeModerationAction.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ActionView) async def update_account_email( self, data: t.Union[dict, 'models.ComAtprotoAdminUpdateAccountEmail.Data'], **kwargs @@ -1541,7 +1541,7 @@ async def create_account( async def create_app_password( self, data: t.Union[dict, 'models.ComAtprotoServerCreateAppPassword.Data'], **kwargs - ) -> 'models.ComAtprotoServerCreateAppPassword.ResponseRef': + ) -> 'models.ComAtprotoServerCreateAppPassword.AppPassword': """Create an app-specific password. Args: @@ -1549,7 +1549,7 @@ async def create_app_password( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoServerCreateAppPassword.ResponseRef`: Output model. + :obj:`models.ComAtprotoServerCreateAppPassword.AppPassword`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1563,7 +1563,7 @@ async def create_app_password( output_encoding='application/json', **kwargs, ) - return get_response_model(response, models.ComAtprotoServerCreateAppPassword.ResponseRef) + return get_response_model(response, models.ComAtprotoServerCreateAppPassword.AppPassword) async def create_invite_code( self, data: t.Union[dict, 'models.ComAtprotoServerCreateInviteCode.Data'], **kwargs diff --git a/atproto/xrpc_client/namespaces/sync_ns.py b/atproto/xrpc_client/namespaces/sync_ns.py index 62eac531..57ef4b73 100644 --- a/atproto/xrpc_client/namespaces/sync_ns.py +++ b/atproto/xrpc_client/namespaces/sync_ns.py @@ -56,7 +56,7 @@ def get_preferences( def get_profile( self, params: t.Union[dict, 'models.AppBskyActorGetProfile.Params'], **kwargs - ) -> 'models.AppBskyActorGetProfile.ResponseRef': + ) -> 'models.AppBskyActorDefs.ProfileViewDetailed': """Get profile. Args: @@ -64,7 +64,7 @@ def get_profile( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.AppBskyActorGetProfile.ResponseRef`: Output model. + :obj:`models.AppBskyActorDefs.ProfileViewDetailed`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -74,7 +74,7 @@ def get_profile( response = self._client.invoke_query( 'app.bsky.actor.getProfile', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.AppBskyActorGetProfile.ResponseRef) + return get_response_model(response, models.AppBskyActorDefs.ProfileViewDetailed) def get_profiles( self, params: t.Union[dict, 'models.AppBskyActorGetProfiles.Params'], **kwargs @@ -1191,7 +1191,7 @@ def get_invite_codes( def get_moderation_action( self, params: t.Union[dict, 'models.ComAtprotoAdminGetModerationAction.Params'], **kwargs - ) -> 'models.ComAtprotoAdminGetModerationAction.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ActionViewDetail': """View details about a moderation action. Args: @@ -1199,7 +1199,7 @@ def get_moderation_action( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminGetModerationAction.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ActionViewDetail`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1209,7 +1209,7 @@ def get_moderation_action( response = self._client.invoke_query( 'com.atproto.admin.getModerationAction', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.ComAtprotoAdminGetModerationAction.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ActionViewDetail) def get_moderation_actions( self, params: t.Optional[t.Union[dict, 'models.ComAtprotoAdminGetModerationActions.Params']] = None, **kwargs @@ -1235,7 +1235,7 @@ def get_moderation_actions( def get_moderation_report( self, params: t.Union[dict, 'models.ComAtprotoAdminGetModerationReport.Params'], **kwargs - ) -> 'models.ComAtprotoAdminGetModerationReport.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ReportViewDetail': """View details about a moderation report. Args: @@ -1243,7 +1243,7 @@ def get_moderation_report( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminGetModerationReport.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ReportViewDetail`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1253,7 +1253,7 @@ def get_moderation_report( response = self._client.invoke_query( 'com.atproto.admin.getModerationReport', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.ComAtprotoAdminGetModerationReport.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ReportViewDetail) def get_moderation_reports( self, params: t.Optional[t.Union[dict, 'models.ComAtprotoAdminGetModerationReports.Params']] = None, **kwargs @@ -1279,7 +1279,7 @@ def get_moderation_reports( def get_record( self, params: t.Union[dict, 'models.ComAtprotoAdminGetRecord.Params'], **kwargs - ) -> 'models.ComAtprotoAdminGetRecord.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.RecordViewDetail': """View details about a record. Args: @@ -1287,7 +1287,7 @@ def get_record( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminGetRecord.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.RecordViewDetail`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1297,11 +1297,11 @@ def get_record( response = self._client.invoke_query( 'com.atproto.admin.getRecord', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.ComAtprotoAdminGetRecord.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.RecordViewDetail) def get_repo( self, params: t.Union[dict, 'models.ComAtprotoAdminGetRepo.Params'], **kwargs - ) -> 'models.ComAtprotoAdminGetRepo.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.RepoViewDetail': """View details about a repository. Args: @@ -1309,7 +1309,7 @@ def get_repo( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminGetRepo.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.RepoViewDetail`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1319,7 +1319,7 @@ def get_repo( response = self._client.invoke_query( 'com.atproto.admin.getRepo', params=params_model, output_encoding='application/json', **kwargs ) - return get_response_model(response, models.ComAtprotoAdminGetRepo.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.RepoViewDetail) def rebase_repo(self, data: t.Union[dict, 'models.ComAtprotoAdminRebaseRepo.Data'], **kwargs) -> bool: """Administrative action to rebase an account's repo. @@ -1343,7 +1343,7 @@ def rebase_repo(self, data: t.Union[dict, 'models.ComAtprotoAdminRebaseRepo.Data def resolve_moderation_reports( self, data: t.Union[dict, 'models.ComAtprotoAdminResolveModerationReports.Data'], **kwargs - ) -> 'models.ComAtprotoAdminResolveModerationReports.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ActionView': """Resolve moderation reports by an action. Args: @@ -1351,7 +1351,7 @@ def resolve_moderation_reports( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminResolveModerationReports.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ActionView`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1365,11 +1365,11 @@ def resolve_moderation_reports( output_encoding='application/json', **kwargs, ) - return get_response_model(response, models.ComAtprotoAdminResolveModerationReports.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ActionView) def reverse_moderation_action( self, data: t.Union[dict, 'models.ComAtprotoAdminReverseModerationAction.Data'], **kwargs - ) -> 'models.ComAtprotoAdminReverseModerationAction.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ActionView': """Reverse a moderation action. Args: @@ -1377,7 +1377,7 @@ def reverse_moderation_action( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminReverseModerationAction.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ActionView`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1391,7 +1391,7 @@ def reverse_moderation_action( output_encoding='application/json', **kwargs, ) - return get_response_model(response, models.ComAtprotoAdminReverseModerationAction.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ActionView) def search_repos( self, params: t.Optional[t.Union[dict, 'models.ComAtprotoAdminSearchRepos.Params']] = None, **kwargs @@ -1443,7 +1443,7 @@ def send_email( def take_moderation_action( self, data: t.Union[dict, 'models.ComAtprotoAdminTakeModerationAction.Data'], **kwargs - ) -> 'models.ComAtprotoAdminTakeModerationAction.ResponseRef': + ) -> 'models.ComAtprotoAdminDefs.ActionView': """Take a moderation action on a repo. Args: @@ -1451,7 +1451,7 @@ def take_moderation_action( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoAdminTakeModerationAction.ResponseRef`: Output model. + :obj:`models.ComAtprotoAdminDefs.ActionView`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1465,7 +1465,7 @@ def take_moderation_action( output_encoding='application/json', **kwargs, ) - return get_response_model(response, models.ComAtprotoAdminTakeModerationAction.ResponseRef) + return get_response_model(response, models.ComAtprotoAdminDefs.ActionView) def update_account_email( self, data: t.Union[dict, 'models.ComAtprotoAdminUpdateAccountEmail.Data'], **kwargs @@ -1541,7 +1541,7 @@ def create_account( def create_app_password( self, data: t.Union[dict, 'models.ComAtprotoServerCreateAppPassword.Data'], **kwargs - ) -> 'models.ComAtprotoServerCreateAppPassword.ResponseRef': + ) -> 'models.ComAtprotoServerCreateAppPassword.AppPassword': """Create an app-specific password. Args: @@ -1549,7 +1549,7 @@ def create_app_password( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`models.ComAtprotoServerCreateAppPassword.ResponseRef`: Output model. + :obj:`models.ComAtprotoServerCreateAppPassword.AppPassword`: Output model. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1563,7 +1563,7 @@ def create_app_password( output_encoding='application/json', **kwargs, ) - return get_response_model(response, models.ComAtprotoServerCreateAppPassword.ResponseRef) + return get_response_model(response, models.ComAtprotoServerCreateAppPassword.AppPassword) def create_invite_code( self, data: t.Union[dict, 'models.ComAtprotoServerCreateInviteCode.Data'], **kwargs diff --git a/test.py b/test.py index 770d4491..a77c3ef0 100644 --- a/test.py +++ b/test.py @@ -10,7 +10,7 @@ FirehoseSubscribeReposClient, parse_subscribe_repos_message, ) -from atproto.xrpc_client.models import get_model_as_dict, ids, is_record_type +from atproto.xrpc_client.models import get_model_as_dict, ids, is_record_type, get_model_as_json if t.TYPE_CHECKING: from atproto.firehose import MessageFrame @@ -39,6 +39,39 @@ def convert_uri_to_url(): def sync_main(): client = Client() client.login(os.environ['USERNAME'], os.environ['PASSWORD']) + # h = client.com.atproto.identity.resolve_handle({'handle': 'bsky.app'}) + # s = client.bsky.actor.search_actors_typeahead({'term': 'bsky'}) + + # post_ref = client.send_post(text='Hello World from Python!') + + # We can put likes only with reference to the post. You need to create/get post first to be able to like it + # cid='bafyreidaszwnbzl65oqryswowxzrexlqfeoh47zhtvo65yv5wblosgdrkq' uri='at://did:plc:kvwvcn5iqfooopmyzvb4qzba/app.bsky.feed.like/3k5u5ammyg72r' + # r = client.like(models.ComAtprotoRepoStrongRef.Main(cid=post_ref.cid, uri=post_ref.uri)) + # print(r) + + feed = client.com.atproto.repo.get_record( + {'collection': 'app.bsky.feed.generator', 'repo': 'did:plc:2wqb5jjkxli4rcswpyb624xj', 'rkey': 'Filecoin'} + ) + post = client.com.atproto.repo.get_record( + {'collection': 'app.bsky.feed.post', 'repo': 'test.marshal.dev', 'rkey': '3k2yihcrp6f2c'} + ) + custom_post = client.com.atproto.repo.get_record( + {'collection': 'app.bsky.feed.post', 'repo': 'test.marshal.dev', 'rkey': '3k2yinh52ne2x'} + ) + custom_like = client.com.atproto.repo.get_record( + {'collection': 'app.bsky.feed.like', 'repo': 'test.marshal.dev', 'rkey': '3k5u5ammyg72r'} + ) + like = client.com.atproto.repo.get_record( + {'collection': 'app.bsky.feed.like', 'repo': 'test.marshal.dev', 'rkey': '3k5u7c7j7a52v'} + ) + print(type(feed.value)) + print(get_model_as_json(feed.value)) + print(get_model_as_json(feed.value.avatar)) + + print(type(like.value)) + print(type(post.value)) + print(type(custom_like.value)) + print(type(custom_post.value)) lexicon_correct_record = client.com.atproto.repo.get_record( {'collection': 'app.bsky.feed.post', 'repo': 'test.marshal.dev', 'rkey': '3k2yihcrp6f2c'} @@ -49,15 +82,17 @@ def sync_main(): {'collection': 'app.bsky.feed.post', 'repo': 'test.marshal.dev', 'rkey': '3k2yinh52ne2x'} ) print(extended_record.value.text) - print(extended_record.value.lol) # custom (out of lexicon) attribute + # FIXME + # print(extended_record.value.lol) # custom (out of lexicon) attribute print(type(extended_record.value)) - did_doc = client.com.atproto.repo.describe_repo({'repo': 'did:plc:ze3uieyyns7prike7itbdjiy'}).didDoc - print(did_doc) - print(did_doc.service) - print(did_doc['service']) - print(did_doc['@context']) - print(type(did_doc)) + # FIXME + # did_doc = client.com.atproto.repo.describe_repo({'repo': 'did:plc:ze3uieyyns7prike7itbdjiy'}).didDoc + # print(did_doc) + # print(did_doc.service) + # print(did_doc['service']) + # print(did_doc['@context']) + # print(type(did_doc)) atproto_feed = client.com.atproto.repo.get_record( {'collection': ids.AppBskyFeedGenerator, 'repo': 'marshal.dev', 'rkey': 'atproto'}