diff --git a/README.md b/README.md index 072944dd..15ed3ed8 100644 --- a/README.md +++ b/README.md @@ -23,6 +23,7 @@ > ⚠️ Under construction. Until the 1.0.0 release compatibility between versions is not guaranteed. Code snippet: + ```python from atproto import Client, client_utils @@ -85,7 +86,7 @@ This SDK attempts to implement everything that provides ATProto. There is suppor ### Installing ``` bash -pip install -U atproto +pip install atproto ``` ### Quick start @@ -93,6 +94,7 @@ pip install -U atproto First of all, you need to create the instance of the XRPC Client. To do so, you have two major options: asynchronous, and synchronous. The difference only in import and how you call the methods. If you are not familiar with async, use sync instead. For sync: + ```python from atproto import Client @@ -102,6 +104,7 @@ client = Client() ``` For async: + ```python from atproto import AsyncClient @@ -124,6 +127,7 @@ client.login('my-username', 'my-password') You are awesome! Now you feel to pick any high-level method that you want and perform it! Code to send post: + ```python from atproto import Client @@ -133,6 +137,7 @@ client.send_post(text='Hello World!') ``` Useful links to continue: + - [List of all methods with documentation](https://atproto.readthedocs.io/en/latest/atproto_client/index.html). - [Examples of using the methods](https://github.com/MarshalX/atproto/tree/main/examples). @@ -173,18 +178,24 @@ I'll be honest. The high-level Client that was shown in the "Quick Start" sectio The basics: - Namespaces – classes that group sub-namespaces and the XRPC queries and procedures. Built upon NSID ATProto semantic. -- Model – dataclasses for input, output, and params of the methods from namespaces. Models describe Record and all other types in the Lexicon Schemes. +- Model – dataclasses for input, output, and params of the methods from namespaces. Models describe Record and all other types in the Lexicon Schemes. + +#### Namespaces The client contains references to the root of all namespaces. It's `com` and `app` for now. + ```python from atproto import Client + Client().com Client().app ``` To dive deeper, you can navigate using hints from your IDE. Thanks to well-type hinted SDK, it's much easier. + ```python from atproto import Client + Client().com.atproto.server.create_session(...) Client().com.atproto.sync.get_blob(...) Client().app.bsky.feed.get_likes(...) @@ -193,9 +204,55 @@ Client().app.bsky.graph.get_follows(...) The endpoint of the path is always the method that you want to call. The method presents a query or procedure in XRPC. You should not care about it much. The only thing you need to know is that the procedures required data objects. Queries could be called with or without params. +#### Records + +In some sub-namespaces, you can find records. Such record classes provide a syntax sugar not defined in the lexicon scheme. This sugar provides a more convenient way to work with repository operations. Such as creating a record, deleting a record, and so on. + +Here are some available records of Bluesky records: + +```python +from atproto import Client + +Client().app.bsky.feed.post +Client().app.bsky.feed.like +Client().app.bsky.graph.follow +Client().app.bsky.graph.block +Client().app.bsky.actor.profile +# ... more +``` + +Usage example with the `post` record: + +```python +from atproto import AtUri, Client, models + +client = Client() +client.login('my-username', 'my-password') + +posts = client.app.bsky.feed.post.list(client.me.did, limit=10) +for uri, post in posts.records.items(): + print(uri, post.text) + +post = client.app.bsky.feed.post.get(client.me.did, AtUri.from_str(uri).rkey) +print(post.value.text) + +post_record = models.AppBskyFeedPost.Main(text='test record namespaces', created_at=client.get_current_time_iso()) +new_post = client.app.bsky.feed.post.create(client.me.did, post_record) +print(new_post) + +deleted_post = client.app.bsky.feed.post.delete(client.me.did, AtUri.from_str(new_post.uri).rkey) +print(deleted_post) +``` + +Please note that not all repository operations are covered by these syntax sugars. You can always use the low-level methods to perform any desired action. One such action is updating a record. + +#### Models + To deal with methods, we need to deal with models! Models are available in the `models` module and have NSID-based aliases. Let's take a look at it. + ```python from atproto import models + models.ComAtprotoIdentityResolveHandle models.AppBskyFeedPost models.AppBskyActorGetProfile @@ -203,25 +260,28 @@ models.AppBskyActorGetProfile ``` The model classes in the "models" aliases could be: + - Data model - Params model - Response model +- Sugar response model - Record model - Type model The only thing you need to know is how to create instances of models. Not with all models, you will work as model-creator. For example, SDK will create Response models for you. There are a few ways how to create the instance of a model: + - Dict-based - Class-based The instances of data and params models should be passed as arguments to the methods that were described above. Dict-based: + ```python from atproto import Client - client = Client() client.login('my-username', 'my-password') # The params model will be created automatically internally for you! @@ -229,10 +289,10 @@ print(client.com.atproto.identity.resolve_handle({'handle': 'marshal.dev'})) ``` Class-based: + ```python from atproto import Client, models - client = Client() client.login('my-username', 'my-password') params = models.ComAtprotoIdentityResolveHandle.Params(handle='marshal.dev') @@ -246,10 +306,10 @@ Pro Tip: use IDE autocompletion to find necessary models! Just start typing the Models could be nested as hell. Be ready for it! This is how we can send a post with the image using low-level XRPC Client: + ```python from atproto import Client, models - client = Client() client.login('my-username', 'my-password') @@ -269,6 +329,13 @@ with open('cat.jpg', 'rb') as f: ), ) ) + + # of course, you can use the syntax sugar here instead + post = models.AppBskyFeedPost.Record(text='Text of the post', embed=embed, created_at=client.get_current_time_iso()) + client.app.bsky.feed.post.create(client.me.did, post) + # or even high-level client + client.send_image(text='Text of the post', image=img_data, image_alt='Img alt') + # these three methods are equivalent ``` I hope you are not scared. May the Force be with you. Good luck! diff --git a/docs/source/atproto/atproto_codegen.namespaces.record_templates.rst b/docs/source/atproto/atproto_codegen.namespaces.record_templates.rst deleted file mode 100644 index e6663a80..00000000 --- a/docs/source/atproto/atproto_codegen.namespaces.record_templates.rst +++ /dev/null @@ -1,7 +0,0 @@ -atproto\_codegen.namespaces.record\_templates -============================================= - -.. automodule:: atproto_codegen.namespaces.record_templates - :members: - :undoc-members: - :show-inheritance: \ No newline at end of file diff --git a/docs/source/atproto/atproto_codegen.namespaces.rst b/docs/source/atproto/atproto_codegen.namespaces.rst index 3c9532ca..fcb9db4b 100644 --- a/docs/source/atproto/atproto_codegen.namespaces.rst +++ b/docs/source/atproto/atproto_codegen.namespaces.rst @@ -14,4 +14,3 @@ Submodules atproto_codegen.namespaces.builder atproto_codegen.namespaces.generator - atproto_codegen.namespaces.record_templates diff --git a/docs/source/atproto/atproto_codegen.record_templates.rst b/docs/source/atproto/atproto_codegen.record_templates.rst new file mode 100644 index 00000000..dd31641a --- /dev/null +++ b/docs/source/atproto/atproto_codegen.record_templates.rst @@ -0,0 +1,7 @@ +atproto\_codegen.record\_templates +================================== + +.. automodule:: atproto_codegen.record_templates + :members: + :undoc-members: + :show-inheritance: \ No newline at end of file diff --git a/docs/source/atproto/atproto_codegen.rst b/docs/source/atproto/atproto_codegen.rst index 5ad29e98..128ef54d 100644 --- a/docs/source/atproto/atproto_codegen.rst +++ b/docs/source/atproto/atproto_codegen.rst @@ -23,4 +23,5 @@ Submodules :maxdepth: 4 atproto_codegen.consts + atproto_codegen.record_templates atproto_codegen.utils diff --git a/docs/source/readme.content.md b/docs/source/readme.content.md index 040a213a..73359438 100644 --- a/docs/source/readme.content.md +++ b/docs/source/readme.content.md @@ -9,7 +9,7 @@ This SDK attempts to implement everything that provides ATProto. There is suppor ### Installing ``` bash -pip install -U atproto +pip install atproto ``` ### Quick start @@ -17,6 +17,7 @@ pip install -U atproto First of all, you need to create the instance of the XRPC Client. To do so, you have two major options: asynchronous, and synchronous. The difference only in import and how you call the methods. If you are not familiar with async, use sync instead. For sync: + ```python from atproto import Client @@ -26,6 +27,7 @@ client = Client() ``` For async: + ```python from atproto import AsyncClient @@ -48,6 +50,7 @@ client.login('my-username', 'my-password') You are awesome! Now you feel to pick any high-level method that you want and perform it! Code to send post: + ```python from atproto import Client @@ -57,6 +60,7 @@ client.send_post(text='Hello World!') ``` Useful links to continue: + - [List of all methods with documentation](https://atproto.readthedocs.io/en/latest/atproto_client/index.html). - [Examples of using the methods](https://github.com/MarshalX/atproto/tree/main/examples). @@ -80,7 +84,6 @@ The SDK is built upon the following components: I highly recommend you to use the `atproto` package to import everything that you need. It contains shortcuts to all other packages. - ### Documentation The documentation is live at [atproto.blue](https://atproto.blue/). @@ -100,16 +103,22 @@ The basics: - Namespaces – classes that group sub-namespaces and the XRPC queries and procedures. Built upon NSID ATProto semantic. - Model – dataclasses for input, output, and params of the methods from namespaces. Models describe Record and all other types in the Lexicon Schemes. +#### Namespaces + The client contains references to the root of all namespaces. It's `com` and `app` for now. + ```python from atproto import Client + Client().com Client().app ``` To dive deeper, you can navigate using hints from your IDE. Thanks to well-type hinted SDK, it's much easier. + ```python from atproto import Client + Client().com.atproto.server.create_session(...) Client().com.atproto.sync.get_blob(...) Client().app.bsky.feed.get_likes(...) @@ -118,9 +127,55 @@ Client().app.bsky.graph.get_follows(...) The endpoint of the path is always the method that you want to call. The method presents a query or procedure in XRPC. You should not care about it much. The only thing you need to know is that the procedures required data objects. Queries could be called with or without params. +#### Records + +In some sub-namespaces, you can find records. Such record classes provide a syntax sugar not defined in the lexicon scheme. This sugar provides a more convenient way to work with repository operations. Such as creating a record, deleting a record, and so on. + +Here are some available records of Bluesky records: + +```python +from atproto import Client + +Client().app.bsky.feed.post +Client().app.bsky.feed.like +Client().app.bsky.graph.follow +Client().app.bsky.graph.block +Client().app.bsky.actor.profile +# ... more +``` + +Usage example with the `post` record: + +```python +from atproto import AtUri, Client, models + +client = Client() +client.login('my-username', 'my-password') + +posts = client.app.bsky.feed.post.list(client.me.did, limit=10) +for uri, post in posts.records.items(): + print(uri, post.text) + +post = client.app.bsky.feed.post.get(client.me.did, AtUri.from_str(uri).rkey) +print(post.value.text) + +post_record = models.AppBskyFeedPost.Main(text='test record namespaces', created_at=client.get_current_time_iso()) +new_post = client.app.bsky.feed.post.create(client.me.did, post_record) +print(new_post) + +deleted_post = client.app.bsky.feed.post.delete(client.me.did, AtUri.from_str(new_post.uri).rkey) +print(deleted_post) +``` + +Please note that not all repository operations are covered by these syntax sugars. You can always use the low-level methods to perform any desired action. One such action is updating a record. + +#### Models + To deal with methods, we need to deal with models! Models are available in the `models` module and have NSID-based aliases. Let's take a look at it. + ```python from atproto import models + models.ComAtprotoIdentityResolveHandle models.AppBskyFeedPost models.AppBskyActorGetProfile @@ -128,25 +183,28 @@ models.AppBskyActorGetProfile ``` The model classes in the "models" aliases could be: + - Data model - Params model - Response model +- Sugar response model - Record model - Type model The only thing you need to know is how to create instances of models. Not with all models, you will work as model-creator. For example, SDK will create Response models for you. There are a few ways how to create the instance of a model: + - Dict-based - Class-based The instances of data and params models should be passed as arguments to the methods that were described above. Dict-based: + ```python from atproto import Client - client = Client() client.login('my-username', 'my-password') # The params model will be created automatically internally for you! @@ -154,10 +212,10 @@ print(client.com.atproto.identity.resolve_handle({'handle': 'marshal.dev'})) ``` Class-based: + ```python from atproto import Client, models - client = Client() client.login('my-username', 'my-password') params = models.ComAtprotoIdentityResolveHandle.Params(handle='marshal.dev') @@ -171,10 +229,10 @@ Pro Tip: use IDE autocompletion to find necessary models! Just start typing the Models could be nested as hell. Be ready for it! This is how we can send a post with the image using low-level XRPC Client: + ```python from atproto import Client, models - client = Client() client.login('my-username', 'my-password') @@ -194,6 +252,13 @@ with open('cat.jpg', 'rb') as f: ), ) ) + + # of course, you can use the syntax sugar here instead + post = models.AppBskyFeedPost.Record(text='Text of the post', embed=embed, created_at=client.get_current_time_iso()) + client.app.bsky.feed.post.create(client.me.did, post) + # or even high-level client + client.send_image(text='Text of the post', image=img_data, image_alt='Img alt') + # these three methods are equivalent ``` I hope you are not scared. May the Force be with you. Good luck! diff --git a/examples/advanced_usage/handle_cursor_pagination.py b/examples/advanced_usage/handle_cursor_pagination.py index 01a24e0e..7a36d5e5 100644 --- a/examples/advanced_usage/handle_cursor_pagination.py +++ b/examples/advanced_usage/handle_cursor_pagination.py @@ -1,6 +1,4 @@ -import typing as t - -from atproto import Client, models +from atproto import Client def main() -> None: @@ -9,22 +7,16 @@ def main() -> None: client.login('my-handle', 'my-password') handle = 'target-handle' - def _fetch(actor: str, cursor: t.Union[str, None]) -> models.AppBskyGraphGetFollows.Response: - params = models.AppBskyGraphGetFollows.Params(actor=actor, limit=100) - if cursor: - params.cursor = cursor - - return client.app.bsky.graph.get_follows(params) - cursor = None follows = [] while True: - fetched = _fetch(handle, cursor) + fetched = client.get_follows(actor=handle, cursor=cursor) + follows = follows + fetched.follows + if not fetched.cursor: break - follows = follows + fetched.follows cursor = fetched.cursor print(follows) diff --git a/examples/advanced_usage/home_timeline.py b/examples/advanced_usage/home_timeline.py deleted file mode 100644 index eeaf748a..00000000 --- a/examples/advanced_usage/home_timeline.py +++ /dev/null @@ -1,31 +0,0 @@ -from atproto import Client - - -def main() -> None: - client = Client() - client.login('my-handle', 'my-password') - - print('Home (Following):\n\n') - - # Get "Home" page. Use pagination (cursor + limit) to fetch all posts - timeline = client.app.bsky.feed.get_timeline({'algorithm': 'reverse-chronological'}) - for feed_view in timeline.feed: - author = feed_view.post.author - - action = 'New Post' - action_by = author.display_name - if feed_view.reason: - action = type(feed_view.reason).__name__.replace('Reason', '') - action_by = feed_view.reason.by.display_name - - post = feed_view.post.record - author = feed_view.post.author - - print( - f'[{action} by {action_by}] Post author: {author.display_name}. ' - f'Posted at {post.created_at}. Post text: {post.text}' - ) - - -if __name__ == '__main__': - main() diff --git a/examples/advanced_usage/send_rich_text.py b/examples/advanced_usage/send_rich_text.py index 960e9889..70de8eb6 100644 --- a/examples/advanced_usage/send_rich_text.py +++ b/examples/advanced_usage/send_rich_text.py @@ -21,13 +21,7 @@ def main() -> None: ) ] - client.com.atproto.repo.create_record( - models.ComAtprotoRepoCreateRecord.Data( - repo=client.me.did, # or any another DID - collection=models.ids.AppBskyFeedPost, - record=models.AppBskyFeedPost.Record(created_at=client.get_current_time_iso(), text=text, facets=facets), - ) - ) + client.send_post(text=text, facets=facets) if __name__ == '__main__': diff --git a/examples/advanced_usage/update_profile.py b/examples/advanced_usage/update_profile.py index c5c56449..9bfd28df 100644 --- a/examples/advanced_usage/update_profile.py +++ b/examples/advanced_usage/update_profile.py @@ -9,13 +9,7 @@ def main() -> None: client.login(os.environ['USERNAME'], os.environ['PASSWORD']) try: - current_profile_record = client.com.atproto.repo.get_record( - models.ComAtprotoRepoGetRecord.Params( - collection=models.ids.AppBskyActorProfile, - repo=client.me.did, - rkey='self', - ) - ) + current_profile_record = client.app.bsky.actor.profile.get(client.me.did, 'self') current_profile = current_profile_record.value swap_record_cid = current_profile_record.cid except BadRequestError: diff --git a/examples/home_timeline.py b/examples/home_timeline.py new file mode 100644 index 00000000..d850e090 --- /dev/null +++ b/examples/home_timeline.py @@ -0,0 +1,25 @@ +from atproto import Client + + +def main() -> None: + client = Client() + client.login('my-handle', 'my-password') + + print('Home (Following):\n') + + # Get "Home" page. Use pagination (cursor + limit) to fetch all posts + timeline = client.get_timeline(algorithm='reverse-chronological') + for feed_view in timeline.feed: + action = 'New Post' + if feed_view.reason: + action_by = feed_view.reason.by.handle + action = f'Reposted by @{action_by}' + + post = feed_view.post.record + author = feed_view.post.author + + print(f'[{action}] {author.display_name}: {post.text}') + + +if __name__ == '__main__': + main() diff --git a/examples/profile_posts.py b/examples/profile_posts.py index 8fdf509c..1c5c6c11 100644 --- a/examples/profile_posts.py +++ b/examples/profile_posts.py @@ -5,7 +5,7 @@ def main(client: Client, handle: str) -> None: print(f'\nProfile Posts of {handle}:\n\n') # Get profile's posts. Use pagination (cursor + limit) to fetch all - profile_feed = client.app.bsky.feed.get_author_feed({'actor': handle}) + profile_feed = client.get_author_feed(actor=handle) for feed_view in profile_feed.feed: print('-', feed_view.post.record.text) diff --git a/examples/send_image.py b/examples/send_image.py index 671d0ada..e85f2b10 100644 --- a/examples/send_image.py +++ b/examples/send_image.py @@ -9,9 +9,7 @@ def main() -> None: with open('cat.jpg', 'rb') as f: img_data = f.read() - client.send_image( - text='Post with image from Python', image=img_data, image_alt='Text version of the image (ALT)' - ) + client.send_image(text='Post with image from Python', image=img_data, image_alt='Text version of the image (ALT)') if __name__ == '__main__': diff --git a/packages/atproto_client/client/async_client.py b/packages/atproto_client/client/async_client.py index b8478a33..f92be2e5 100644 --- a/packages/atproto_client/client/async_client.py +++ b/packages/atproto_client/client/async_client.py @@ -13,7 +13,6 @@ from atproto_client.client.async_raw import AsyncClientRaw from atproto_client.client.methods_mixin import SessionMethodsMixin, TimeMethodsMixin from atproto_client.client.methods_mixin.strong_ref_arg_backward_compatibility import _StrongRefArgBackwardCompatibility -from atproto_client.models import ids from atproto_client.models.languages import DEFAULT_LANGUAGE_CODE1 from atproto_client.utils import TextBuilder @@ -30,7 +29,7 @@ def __init__(self, base_url: t.Optional[str] = None, *args, **kwargs: t.Any) -> self._refresh_lock = Lock() - self.me: t.Optional[models.AppBskyActorDefs.ProfileViewDetailed] = None + self.me: t.Optional['models.AppBskyActorDefs.ProfileViewDetailed'] = None async def _invoke(self, invoke_type: 'InvokeType', **kwargs: t.Any) -> 'Response': session_refreshing = kwargs.pop('session_refreshing', False) @@ -43,7 +42,7 @@ async def _invoke(self, invoke_type: 'InvokeType', **kwargs: t.Any) -> 'Response return await super()._invoke(invoke_type, **kwargs) - async def _get_and_set_session(self, login: str, password: str) -> models.ComAtprotoServerCreateSession.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(identifier=login, password=password) ) @@ -51,7 +50,7 @@ async def _get_and_set_session(self, login: str, password: str) -> models.ComAtp return session - async def _refresh_and_set_session(self) -> models.ComAtprotoServerRefreshSession.Response: + async def _refresh_and_set_session(self) -> 'models.ComAtprotoServerRefreshSession.Response': refresh_session = await self.com.atproto.server.refresh_session( headers=self._get_auth_headers(self._refresh_jwt), session_refreshing=True ) @@ -61,7 +60,7 @@ async def _refresh_and_set_session(self) -> models.ComAtprotoServerRefreshSessio async def login( self, login: t.Optional[str] = None, password: t.Optional[str] = None, session_string: t.Optional[str] = None - ) -> models.AppBskyActorDefs.ProfileViewDetailed: + ) -> 'models.AppBskyActorDefs.ProfileViewDetailed': """Authorize a client and get profile info. Args: @@ -92,7 +91,7 @@ async def send_post( self, text: t.Union[str, TextBuilder], profile_identify: t.Optional[str] = None, - reply_to: t.Optional[t.Union[models.AppBskyFeedPost.ReplyRef, models.AppBskyFeedDefs.ReplyRef]] = None, + reply_to: t.Optional[t.Union['models.AppBskyFeedPost.ReplyRef', 'models.AppBskyFeedDefs.ReplyRef']] = None, embed: t.Optional[ t.Union[ 'models.AppBskyEmbedImages.Main', @@ -103,7 +102,7 @@ async def send_post( ] = None, langs: t.Optional[t.List[str]] = None, facets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None, - ) -> models.ComAtprotoRepoCreateRecord.Response: + ) -> 'models.AppBskyFeedPost.CreateRecordResponse': """Send post. Note: @@ -121,7 +120,7 @@ async def send_post( facets: List of facets (rich text items). Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the created post record. + :obj:`models.AppBskyFeedPost.CreateRecordResponse`: Reference to the created record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -137,20 +136,15 @@ async def send_post( if not langs: langs = [DEFAULT_LANGUAGE_CODE1] - return await self.com.atproto.repo.create_record( - models.ComAtprotoRepoCreateRecord.Data( - repo=repo, - collection=ids.AppBskyFeedPost, - record=models.AppBskyFeedPost.Record( - created_at=self.get_current_time_iso(), - text=text, - reply=reply_to, - embed=embed, - langs=langs, - facets=facets, - ), - ) + record = models.AppBskyFeedPost.Record( + created_at=self.get_current_time_iso(), + text=text, + reply=reply_to, + embed=embed, + langs=langs, + facets=facets, ) + return await self.app.bsky.feed.post.create(repo, record) async def delete_post(self, post_uri: str) -> bool: """Delete post. @@ -165,13 +159,7 @@ async def delete_post(self, post_uri: str) -> bool: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ uri = AtUri.from_str(post_uri) - return await self.com.atproto.repo.delete_record( - models.ComAtprotoRepoDeleteRecord.Data( - collection=ids.AppBskyFeedPost, - repo=uri.hostname, - rkey=uri.rkey, - ) - ) + return await self.app.bsky.feed.post.delete(uri.hostname, uri.rkey) async def send_image( self, @@ -179,10 +167,10 @@ async def send_image( image: bytes, image_alt: str, profile_identify: t.Optional[str] = None, - reply_to: t.Optional[t.Union[models.AppBskyFeedPost.ReplyRef, models.AppBskyFeedDefs.ReplyRef]] = None, + reply_to: t.Optional[t.Union['models.AppBskyFeedPost.ReplyRef', 'models.AppBskyFeedDefs.ReplyRef']] = None, langs: t.Optional[t.List[str]] = None, facets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None, - ) -> models.ComAtprotoRepoCreateRecord.Response: + ) -> 'models.AppBskyFeedPost.CreateRecordResponse': """Send post with attached image. Note: @@ -198,7 +186,7 @@ async def send_image( facets: List of facets (rich text items). Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the created post record. + :obj:`models.AppBskyFeedPost.CreateRecordResponse`: Reference to the created record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -216,7 +204,7 @@ async def send_image( async def get_post( self, post_rkey: str, profile_identify: t.Optional[str] = None, cid: t.Optional[str] = None - ) -> models.ComAtprotoRepoGetRecord.Response: + ) -> 'models.AppBskyFeedPost.GetRecordResponse': """Get post. Args: @@ -225,7 +213,7 @@ async def get_post( cid: The CID of the version of the post. Returns: - :obj:`models.ComAtprotoRepoGetRecord.Response`: Post. + :obj:`models.AppBskyFeedPost.GetRecordResponse`: Post. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -234,16 +222,9 @@ async def get_post( if profile_identify: repo = profile_identify - return await self.com.atproto.repo.get_record( - models.ComAtprotoRepoGetRecord.Params( - collection=ids.AppBskyFeedPost, - repo=repo, - rkey=post_rkey, - cid=cid, - ) - ) + return await self.app.bsky.feed.post.get(repo, post_rkey, cid) - async def get_posts(self, uris: t.List[str]) -> models.AppBskyFeedGetPosts.Response: + async def get_posts(self, uris: t.List[str]) -> 'models.AppBskyFeedGetPosts.Response': """Get posts. Args: @@ -268,7 +249,7 @@ async def get_posts(self, uris: t.List[str]) -> models.AppBskyFeedGetPosts.Respo async def get_post_thread( self, uri: str, depth: t.Optional[int] = None, parent_height: t.Optional[int] = None - ) -> models.AppBskyFeedGetPostThread.Response: + ) -> 'models.AppBskyFeedGetPostThread.Response': """Get post thread. Args: @@ -292,7 +273,7 @@ async def get_post_thread( async def get_likes( self, uri: str, cid: t.Optional[str] = None, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyFeedGetLikes.Response: + ) -> 'models.AppBskyFeedGetLikes.Response': """Get likes. Args: @@ -313,7 +294,7 @@ async def get_likes( async def get_reposted_by( self, uri: str, cid: t.Optional[str] = None, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyFeedGetRepostedBy.Response: + ) -> 'models.AppBskyFeedGetRepostedBy.Response': """Get reposted by (reposts). Args: @@ -334,7 +315,7 @@ async def get_reposted_by( async def get_timeline( self, algorithm: t.Optional[str] = None, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyFeedGetTimeline.Response: + ) -> 'models.AppBskyFeedGetTimeline.Response': """Get home timeline. Args: @@ -354,7 +335,7 @@ async def get_timeline( async def get_author_feed( self, actor: str, cursor: t.Optional[str] = None, filter: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyFeedGetAuthorFeed.Response: + ) -> 'models.AppBskyFeedGetAuthorFeed.Response': """Get author (profile) feed. Args: @@ -377,8 +358,8 @@ async def like( self, uri: t.Optional[str] = None, cid: t.Optional[str] = None, - subject: t.Optional[models.ComAtprotoRepoStrongRef.Main] = None, - ) -> models.ComAtprotoRepoCreateRecord.Response: + subject: t.Optional['models.ComAtprotoRepoStrongRef.Main'] = None, + ) -> 'models.AppBskyFeedLike.CreateRecordResponse': """Like the post. Args: @@ -387,20 +368,15 @@ async def like( subject: DEPRECATED. Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the created like record. + :obj:`models.AppBskyFeedLike.CreateRecordResponse`: Reference to the created record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ subject_obj = self._strong_ref_arg_backward_compatibility(uri, cid, subject) - return await self.com.atproto.repo.create_record( - models.ComAtprotoRepoCreateRecord.Data( - repo=self.me.did, - collection=ids.AppBskyFeedLike, - record=models.AppBskyFeedLike.Record(created_at=self.get_current_time_iso(), subject=subject_obj), - ) - ) + record = models.AppBskyFeedLike.Record(created_at=self.get_current_time_iso(), subject=subject_obj) + return await self.app.bsky.feed.like.create(self.me.did, record) async def unlike(self, like_uri: str) -> bool: """Unlike the post. @@ -415,20 +391,14 @@ async def unlike(self, like_uri: str) -> bool: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ uri = AtUri.from_str(like_uri) - return await self.com.atproto.repo.delete_record( - models.ComAtprotoRepoDeleteRecord.Data( - collection=ids.AppBskyFeedLike, - repo=uri.hostname, - rkey=uri.rkey, - ) - ) + return await self.app.bsky.feed.like.delete(uri.hostname, uri.rkey) async def repost( self, uri: t.Optional[str] = None, cid: t.Optional[str] = None, - subject: t.Optional[models.ComAtprotoRepoStrongRef.Main] = None, - ) -> models.ComAtprotoRepoCreateRecord.Response: + subject: t.Optional['models.ComAtprotoRepoStrongRef.Main'] = None, + ) -> 'models.AppBskyFeedRepost.CreateRecordResponse': """Repost post. Args: @@ -437,23 +407,15 @@ async def repost( subject: DEPRECATED. Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the reposted record. + :obj:`models.AppBskyFeedRepost.CreateRecordResponse`: Reference to the reposted record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ subject_obj = self._strong_ref_arg_backward_compatibility(uri, cid, subject) - return await self.com.atproto.repo.create_record( - models.ComAtprotoRepoCreateRecord.Data( - repo=self.me.did, - collection=ids.AppBskyFeedRepost, - record=models.AppBskyFeedRepost.Record( - created_at=self.get_current_time_iso(), - subject=subject_obj, - ), - ) - ) + record = models.AppBskyFeedRepost.Record(created_at=self.get_current_time_iso(), subject=subject_obj) + return await self.app.bsky.feed.repost.create(self.me.did, record) async def unrepost(self, repost_uri: str) -> bool: """Unrepost the post (delete repost). @@ -468,33 +430,22 @@ async def unrepost(self, repost_uri: str) -> bool: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ uri = AtUri.from_str(repost_uri) - return await self.com.atproto.repo.delete_record( - models.ComAtprotoRepoDeleteRecord.Data( - collection=ids.AppBskyFeedRepost, - repo=uri.hostname, - rkey=uri.rkey, - ) - ) + return await self.app.bsky.feed.repost.delete(uri.hostname, uri.rkey) - async def follow(self, subject: str) -> models.ComAtprotoRepoCreateRecord.Response: + async def follow(self, subject: str) -> 'models.AppBskyGraphFollow.CreateRecordResponse': """Follow the profile. Args: subject: DID of the profile. Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the created follow record. + :obj:`models.AppBskyGraphFollow.CreateRecordResponse`: Reference to the created record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ - return await self.com.atproto.repo.create_record( - models.ComAtprotoRepoCreateRecord.Data( - repo=self.me.did, - collection=ids.AppBskyGraphFollow, - record=models.AppBskyGraphFollow.Record(created_at=self.get_current_time_iso(), subject=subject), - ) - ) + record = models.AppBskyGraphFollow.Record(created_at=self.get_current_time_iso(), subject=subject) + return await self.app.bsky.graph.follow.create(self.me.did, record) async def unfollow(self, follow_uri: str) -> bool: """Unfollow the profile. @@ -509,23 +460,17 @@ async def unfollow(self, follow_uri: str) -> bool: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ uri = AtUri.from_str(follow_uri) - return await self.com.atproto.repo.delete_record( - models.ComAtprotoRepoDeleteRecord.Data( - collection=ids.AppBskyGraphFollow, - repo=uri.hostname, - rkey=uri.rkey, - ) - ) + return await self.app.bsky.graph.follow.delete(uri.hostname, uri.rkey) async def get_follows( self, actor: str, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyGraphGetFollows.Response: + ) -> 'models.AppBskyGraphGetFollows.Response': """Get follows of the profile. Args: actor: Actor (handle or DID). - cursor: Cursor of the last like in the previous page. - limit: Limit count of likes to return. + cursor: Cursor of the next page. + limit: Limit count of follows to return. Returns: :obj:`models.AppBskyGraphGetFollows.Response`: Follows. @@ -539,13 +484,13 @@ async def get_follows( async def get_followers( self, actor: str, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyGraphGetFollowers.Response: + ) -> 'models.AppBskyGraphGetFollowers.Response': """Get followers of the profile. Args: actor: Actor (handle or DID). - cursor: Cursor of the last like in the previous page. - limit: Limit count of likes to return. + cursor: Cursor of the next page. + limit: Limit count of followers to return. Returns: :obj:`models.AppBskyGraphGetFollowers.Response`: Followers. @@ -557,7 +502,7 @@ async def get_followers( models.AppBskyGraphGetFollowers.Params(actor=actor, cursor=cursor, limit=limit) ) - async def get_profile(self, actor: str) -> models.AppBskyActorDefs.ProfileViewDetailed: + async def get_profile(self, actor: str) -> 'models.AppBskyActorDefs.ProfileViewDetailed': """Get profile. Args: @@ -571,7 +516,7 @@ async def get_profile(self, actor: str) -> models.AppBskyActorDefs.ProfileViewDe """ return await self.app.bsky.actor.get_profile(models.AppBskyActorGetProfile.Params(actor=actor)) - async def get_profiles(self, actors: t.List[str]) -> models.AppBskyActorGetProfiles.Response: + async def get_profiles(self, actors: t.List[str]) -> 'models.AppBskyActorGetProfiles.Response': """Get profiles. Args: @@ -613,7 +558,7 @@ async def unmute(self, actor: str) -> bool: """ return await self.app.bsky.graph.unmute_actor(models.AppBskyGraphUnmuteActor.Data(actor=actor)) - async def resolve_handle(self, handle: str) -> models.ComAtprotoIdentityResolveHandle.Response: + async def resolve_handle(self, handle: str) -> 'models.ComAtprotoIdentityResolveHandle.Response': """Resolve the handle. Args: @@ -643,7 +588,7 @@ async def update_handle(self, handle: str) -> bool: """ return await self.com.atproto.identity.update_handle(models.ComAtprotoIdentityUpdateHandle.Data(handle=handle)) - async def upload_blob(self, data: bytes) -> models.ComAtprotoRepoUploadBlob.Response: + async def upload_blob(self, data: bytes) -> 'models.ComAtprotoRepoUploadBlob.Response': """Upload blob. Args: diff --git a/packages/atproto_client/client/client.py b/packages/atproto_client/client/client.py index 7da6d47a..4ff74022 100644 --- a/packages/atproto_client/client/client.py +++ b/packages/atproto_client/client/client.py @@ -7,7 +7,6 @@ from atproto_client.client.methods_mixin import SessionMethodsMixin, TimeMethodsMixin from atproto_client.client.methods_mixin.strong_ref_arg_backward_compatibility import _StrongRefArgBackwardCompatibility from atproto_client.client.raw import ClientRaw -from atproto_client.models import ids from atproto_client.models.languages import DEFAULT_LANGUAGE_CODE1 from atproto_client.utils import TextBuilder @@ -24,7 +23,7 @@ def __init__(self, base_url: t.Optional[str] = None, *args, **kwargs: t.Any) -> self._refresh_lock = Lock() - self.me: t.Optional[models.AppBskyActorDefs.ProfileViewDetailed] = None + self.me: t.Optional['models.AppBskyActorDefs.ProfileViewDetailed'] = None def _invoke(self, invoke_type: 'InvokeType', **kwargs: t.Any) -> 'Response': session_refreshing = kwargs.pop('session_refreshing', False) @@ -37,7 +36,7 @@ def _invoke(self, invoke_type: 'InvokeType', **kwargs: t.Any) -> 'Response': return super()._invoke(invoke_type, **kwargs) - def _get_and_set_session(self, login: str, password: str) -> models.ComAtprotoServerCreateSession.Response: + 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) ) @@ -45,7 +44,7 @@ def _get_and_set_session(self, login: str, password: str) -> models.ComAtprotoSe return session - def _refresh_and_set_session(self) -> models.ComAtprotoServerRefreshSession.Response: + def _refresh_and_set_session(self) -> 'models.ComAtprotoServerRefreshSession.Response': refresh_session = self.com.atproto.server.refresh_session( headers=self._get_auth_headers(self._refresh_jwt), session_refreshing=True ) @@ -55,7 +54,7 @@ def _refresh_and_set_session(self) -> models.ComAtprotoServerRefreshSession.Resp def login( self, login: t.Optional[str] = None, password: t.Optional[str] = None, session_string: t.Optional[str] = None - ) -> models.AppBskyActorDefs.ProfileViewDetailed: + ) -> 'models.AppBskyActorDefs.ProfileViewDetailed': """Authorize a client and get profile info. Args: @@ -86,7 +85,7 @@ def send_post( self, text: t.Union[str, TextBuilder], profile_identify: t.Optional[str] = None, - reply_to: t.Optional[t.Union[models.AppBskyFeedPost.ReplyRef, models.AppBskyFeedDefs.ReplyRef]] = None, + reply_to: t.Optional[t.Union['models.AppBskyFeedPost.ReplyRef', 'models.AppBskyFeedDefs.ReplyRef']] = None, embed: t.Optional[ t.Union[ 'models.AppBskyEmbedImages.Main', @@ -97,7 +96,7 @@ def send_post( ] = None, langs: t.Optional[t.List[str]] = None, facets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None, - ) -> models.ComAtprotoRepoCreateRecord.Response: + ) -> 'models.AppBskyFeedPost.CreateRecordResponse': """Send post. Note: @@ -115,7 +114,7 @@ def send_post( facets: List of facets (rich text items). Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the created post record. + :obj:`models.AppBskyFeedPost.CreateRecordResponse`: Reference to the created record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -131,20 +130,15 @@ def send_post( if not langs: langs = [DEFAULT_LANGUAGE_CODE1] - return self.com.atproto.repo.create_record( - models.ComAtprotoRepoCreateRecord.Data( - repo=repo, - collection=ids.AppBskyFeedPost, - record=models.AppBskyFeedPost.Record( - created_at=self.get_current_time_iso(), - text=text, - reply=reply_to, - embed=embed, - langs=langs, - facets=facets, - ), - ) + record = models.AppBskyFeedPost.Record( + created_at=self.get_current_time_iso(), + text=text, + reply=reply_to, + embed=embed, + langs=langs, + facets=facets, ) + return self.app.bsky.feed.post.create(repo, record) def delete_post(self, post_uri: str) -> bool: """Delete post. @@ -159,13 +153,7 @@ def delete_post(self, post_uri: str) -> bool: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ uri = AtUri.from_str(post_uri) - return self.com.atproto.repo.delete_record( - models.ComAtprotoRepoDeleteRecord.Data( - collection=ids.AppBskyFeedPost, - repo=uri.hostname, - rkey=uri.rkey, - ) - ) + return self.app.bsky.feed.post.delete(uri.hostname, uri.rkey) def send_image( self, @@ -173,10 +161,10 @@ def send_image( image: bytes, image_alt: str, profile_identify: t.Optional[str] = None, - reply_to: t.Optional[t.Union[models.AppBskyFeedPost.ReplyRef, models.AppBskyFeedDefs.ReplyRef]] = None, + reply_to: t.Optional[t.Union['models.AppBskyFeedPost.ReplyRef', 'models.AppBskyFeedDefs.ReplyRef']] = None, langs: t.Optional[t.List[str]] = None, facets: t.Optional[t.List['models.AppBskyRichtextFacet.Main']] = None, - ) -> models.ComAtprotoRepoCreateRecord.Response: + ) -> 'models.AppBskyFeedPost.CreateRecordResponse': """Send post with attached image. Note: @@ -192,7 +180,7 @@ def send_image( facets: List of facets (rich text items). Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the created post record. + :obj:`models.AppBskyFeedPost.CreateRecordResponse`: Reference to the created record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -210,7 +198,7 @@ def send_image( def get_post( self, post_rkey: str, profile_identify: t.Optional[str] = None, cid: t.Optional[str] = None - ) -> models.ComAtprotoRepoGetRecord.Response: + ) -> 'models.AppBskyFeedPost.GetRecordResponse': """Get post. Args: @@ -219,7 +207,7 @@ def get_post( cid: The CID of the version of the post. Returns: - :obj:`models.ComAtprotoRepoGetRecord.Response`: Post. + :obj:`models.AppBskyFeedPost.GetRecordResponse`: Post. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -228,16 +216,9 @@ def get_post( if profile_identify: repo = profile_identify - return self.com.atproto.repo.get_record( - models.ComAtprotoRepoGetRecord.Params( - collection=ids.AppBskyFeedPost, - repo=repo, - rkey=post_rkey, - cid=cid, - ) - ) + return self.app.bsky.feed.post.get(repo, post_rkey, cid) - def get_posts(self, uris: t.List[str]) -> models.AppBskyFeedGetPosts.Response: + def get_posts(self, uris: t.List[str]) -> 'models.AppBskyFeedGetPosts.Response': """Get posts. Args: @@ -262,7 +243,7 @@ def get_posts(self, uris: t.List[str]) -> models.AppBskyFeedGetPosts.Response: def get_post_thread( self, uri: str, depth: t.Optional[int] = None, parent_height: t.Optional[int] = None - ) -> models.AppBskyFeedGetPostThread.Response: + ) -> 'models.AppBskyFeedGetPostThread.Response': """Get post thread. Args: @@ -286,7 +267,7 @@ def get_post_thread( def get_likes( self, uri: str, cid: t.Optional[str] = None, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyFeedGetLikes.Response: + ) -> 'models.AppBskyFeedGetLikes.Response': """Get likes. Args: @@ -307,7 +288,7 @@ def get_likes( def get_reposted_by( self, uri: str, cid: t.Optional[str] = None, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyFeedGetRepostedBy.Response: + ) -> 'models.AppBskyFeedGetRepostedBy.Response': """Get reposted by (reposts). Args: @@ -328,7 +309,7 @@ def get_reposted_by( def get_timeline( self, algorithm: t.Optional[str] = None, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyFeedGetTimeline.Response: + ) -> 'models.AppBskyFeedGetTimeline.Response': """Get home timeline. Args: @@ -348,7 +329,7 @@ def get_timeline( def get_author_feed( self, actor: str, cursor: t.Optional[str] = None, filter: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyFeedGetAuthorFeed.Response: + ) -> 'models.AppBskyFeedGetAuthorFeed.Response': """Get author (profile) feed. Args: @@ -371,8 +352,8 @@ def like( self, uri: t.Optional[str] = None, cid: t.Optional[str] = None, - subject: t.Optional[models.ComAtprotoRepoStrongRef.Main] = None, - ) -> models.ComAtprotoRepoCreateRecord.Response: + subject: t.Optional['models.ComAtprotoRepoStrongRef.Main'] = None, + ) -> 'models.AppBskyFeedLike.CreateRecordResponse': """Like the post. Args: @@ -381,20 +362,15 @@ def like( subject: DEPRECATED. Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the created like record. + :obj:`models.AppBskyFeedLike.CreateRecordResponse`: Reference to the created record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ subject_obj = self._strong_ref_arg_backward_compatibility(uri, cid, subject) - return self.com.atproto.repo.create_record( - models.ComAtprotoRepoCreateRecord.Data( - repo=self.me.did, - collection=ids.AppBskyFeedLike, - record=models.AppBskyFeedLike.Record(created_at=self.get_current_time_iso(), subject=subject_obj), - ) - ) + record = models.AppBskyFeedLike.Record(created_at=self.get_current_time_iso(), subject=subject_obj) + return self.app.bsky.feed.like.create(self.me.did, record) def unlike(self, like_uri: str) -> bool: """Unlike the post. @@ -409,20 +385,14 @@ def unlike(self, like_uri: str) -> bool: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ uri = AtUri.from_str(like_uri) - return self.com.atproto.repo.delete_record( - models.ComAtprotoRepoDeleteRecord.Data( - collection=ids.AppBskyFeedLike, - repo=uri.hostname, - rkey=uri.rkey, - ) - ) + return self.app.bsky.feed.like.delete(uri.hostname, uri.rkey) def repost( self, uri: t.Optional[str] = None, cid: t.Optional[str] = None, - subject: t.Optional[models.ComAtprotoRepoStrongRef.Main] = None, - ) -> models.ComAtprotoRepoCreateRecord.Response: + subject: t.Optional['models.ComAtprotoRepoStrongRef.Main'] = None, + ) -> 'models.AppBskyFeedRepost.CreateRecordResponse': """Repost post. Args: @@ -431,23 +401,15 @@ def repost( subject: DEPRECATED. Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the reposted record. + :obj:`models.AppBskyFeedRepost.CreateRecordResponse`: Reference to the reposted record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ subject_obj = self._strong_ref_arg_backward_compatibility(uri, cid, subject) - return self.com.atproto.repo.create_record( - models.ComAtprotoRepoCreateRecord.Data( - repo=self.me.did, - collection=ids.AppBskyFeedRepost, - record=models.AppBskyFeedRepost.Record( - created_at=self.get_current_time_iso(), - subject=subject_obj, - ), - ) - ) + record = models.AppBskyFeedRepost.Record(created_at=self.get_current_time_iso(), subject=subject_obj) + return self.app.bsky.feed.repost.create(self.me.did, record) def unrepost(self, repost_uri: str) -> bool: """Unrepost the post (delete repost). @@ -462,33 +424,22 @@ def unrepost(self, repost_uri: str) -> bool: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ uri = AtUri.from_str(repost_uri) - return self.com.atproto.repo.delete_record( - models.ComAtprotoRepoDeleteRecord.Data( - collection=ids.AppBskyFeedRepost, - repo=uri.hostname, - rkey=uri.rkey, - ) - ) + return self.app.bsky.feed.repost.delete(uri.hostname, uri.rkey) - def follow(self, subject: str) -> models.ComAtprotoRepoCreateRecord.Response: + def follow(self, subject: str) -> 'models.AppBskyGraphFollow.CreateRecordResponse': """Follow the profile. Args: subject: DID of the profile. Returns: - :obj:`models.ComAtprotoRepoCreateRecord.Response`: Reference to the created follow record. + :obj:`models.AppBskyGraphFollow.CreateRecordResponse`: Reference to the created record. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ - return self.com.atproto.repo.create_record( - models.ComAtprotoRepoCreateRecord.Data( - repo=self.me.did, - collection=ids.AppBskyGraphFollow, - record=models.AppBskyGraphFollow.Record(created_at=self.get_current_time_iso(), subject=subject), - ) - ) + record = models.AppBskyGraphFollow.Record(created_at=self.get_current_time_iso(), subject=subject) + return self.app.bsky.graph.follow.create(self.me.did, record) def unfollow(self, follow_uri: str) -> bool: """Unfollow the profile. @@ -503,23 +454,17 @@ def unfollow(self, follow_uri: str) -> bool: :class:`atproto.exceptions.AtProtocolError`: Base exception. """ uri = AtUri.from_str(follow_uri) - return self.com.atproto.repo.delete_record( - models.ComAtprotoRepoDeleteRecord.Data( - collection=ids.AppBskyGraphFollow, - repo=uri.hostname, - rkey=uri.rkey, - ) - ) + return self.app.bsky.graph.follow.delete(uri.hostname, uri.rkey) def get_follows( self, actor: str, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyGraphGetFollows.Response: + ) -> 'models.AppBskyGraphGetFollows.Response': """Get follows of the profile. Args: actor: Actor (handle or DID). - cursor: Cursor of the last like in the previous page. - limit: Limit count of likes to return. + cursor: Cursor of the next page. + limit: Limit count of follows to return. Returns: :obj:`models.AppBskyGraphGetFollows.Response`: Follows. @@ -533,13 +478,13 @@ def get_follows( def get_followers( self, actor: str, cursor: t.Optional[str] = None, limit: t.Optional[int] = None - ) -> models.AppBskyGraphGetFollowers.Response: + ) -> 'models.AppBskyGraphGetFollowers.Response': """Get followers of the profile. Args: actor: Actor (handle or DID). - cursor: Cursor of the last like in the previous page. - limit: Limit count of likes to return. + cursor: Cursor of the next page. + limit: Limit count of followers to return. Returns: :obj:`models.AppBskyGraphGetFollowers.Response`: Followers. @@ -551,7 +496,7 @@ def get_followers( models.AppBskyGraphGetFollowers.Params(actor=actor, cursor=cursor, limit=limit) ) - def get_profile(self, actor: str) -> models.AppBskyActorDefs.ProfileViewDetailed: + def get_profile(self, actor: str) -> 'models.AppBskyActorDefs.ProfileViewDetailed': """Get profile. Args: @@ -565,7 +510,7 @@ def get_profile(self, actor: str) -> models.AppBskyActorDefs.ProfileViewDetailed """ return self.app.bsky.actor.get_profile(models.AppBskyActorGetProfile.Params(actor=actor)) - def get_profiles(self, actors: t.List[str]) -> models.AppBskyActorGetProfiles.Response: + def get_profiles(self, actors: t.List[str]) -> 'models.AppBskyActorGetProfiles.Response': """Get profiles. Args: @@ -607,7 +552,7 @@ def unmute(self, actor: str) -> bool: """ return self.app.bsky.graph.unmute_actor(models.AppBskyGraphUnmuteActor.Data(actor=actor)) - def resolve_handle(self, handle: str) -> models.ComAtprotoIdentityResolveHandle.Response: + def resolve_handle(self, handle: str) -> 'models.ComAtprotoIdentityResolveHandle.Response': """Resolve the handle. Args: @@ -635,7 +580,7 @@ def update_handle(self, handle: str) -> bool: """ return self.com.atproto.identity.update_handle(models.ComAtprotoIdentityUpdateHandle.Data(handle=handle)) - def upload_blob(self, data: bytes) -> models.ComAtprotoRepoUploadBlob.Response: + def upload_blob(self, data: bytes) -> 'models.ComAtprotoRepoUploadBlob.Response': """Upload blob. Args: diff --git a/packages/atproto_client/models/app/bsky/actor/profile.py b/packages/atproto_client/models/app/bsky/actor/profile.py index 4f400796..434c6b97 100644 --- a/packages/atproto_client/models/app/bsky/actor/profile.py +++ b/packages/atproto_client/models/app/bsky/actor/profile.py @@ -42,3 +42,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyActorProfile.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyActorProfile.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyActorProfile.Record`.""" + + records: t.Dict[str, 'models.AppBskyActorProfile.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyActorProfile.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/feed/generator.py b/packages/atproto_client/models/app/bsky/feed/generator.py index 34546ae3..994343e3 100644 --- a/packages/atproto_client/models/app/bsky/feed/generator.py +++ b/packages/atproto_client/models/app/bsky/feed/generator.py @@ -48,3 +48,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyFeedGenerator.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyFeedGenerator.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyFeedGenerator.Record`.""" + + records: t.Dict[str, 'models.AppBskyFeedGenerator.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyFeedGenerator.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/feed/like.py b/packages/atproto_client/models/app/bsky/feed/like.py index a56793ec..8123d851 100644 --- a/packages/atproto_client/models/app/bsky/feed/like.py +++ b/packages/atproto_client/models/app/bsky/feed/like.py @@ -36,3 +36,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyFeedLike.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyFeedLike.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyFeedLike.Record`.""" + + records: t.Dict[str, 'models.AppBskyFeedLike.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyFeedLike.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/feed/post.py b/packages/atproto_client/models/app/bsky/feed/post.py index 44adc050..877e1201 100644 --- a/packages/atproto_client/models/app/bsky/feed/post.py +++ b/packages/atproto_client/models/app/bsky/feed/post.py @@ -93,3 +93,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyFeedPost.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyFeedPost.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyFeedPost.Record`.""" + + records: t.Dict[str, 'models.AppBskyFeedPost.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyFeedPost.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/feed/repost.py b/packages/atproto_client/models/app/bsky/feed/repost.py index fbfe5c45..85851d12 100644 --- a/packages/atproto_client/models/app/bsky/feed/repost.py +++ b/packages/atproto_client/models/app/bsky/feed/repost.py @@ -36,3 +36,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyFeedRepost.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyFeedRepost.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyFeedRepost.Record`.""" + + records: t.Dict[str, 'models.AppBskyFeedRepost.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyFeedRepost.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/feed/threadgate.py b/packages/atproto_client/models/app/bsky/feed/threadgate.py index 98c89257..c7d6ed3a 100644 --- a/packages/atproto_client/models/app/bsky/feed/threadgate.py +++ b/packages/atproto_client/models/app/bsky/feed/threadgate.py @@ -76,3 +76,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyFeedThreadgate.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyFeedThreadgate.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyFeedThreadgate.Record`.""" + + records: t.Dict[str, 'models.AppBskyFeedThreadgate.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyFeedThreadgate.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/graph/block.py b/packages/atproto_client/models/app/bsky/graph/block.py index 7c9c2656..ac87780f 100644 --- a/packages/atproto_client/models/app/bsky/graph/block.py +++ b/packages/atproto_client/models/app/bsky/graph/block.py @@ -10,6 +10,8 @@ import typing_extensions as te from pydantic import Field +if t.TYPE_CHECKING: + from atproto_client import models from atproto_client.models import base @@ -34,3 +36,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyGraphBlock.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyGraphBlock.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyGraphBlock.Record`.""" + + records: t.Dict[str, 'models.AppBskyGraphBlock.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyGraphBlock.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/graph/follow.py b/packages/atproto_client/models/app/bsky/graph/follow.py index 749a4a72..526b5e22 100644 --- a/packages/atproto_client/models/app/bsky/graph/follow.py +++ b/packages/atproto_client/models/app/bsky/graph/follow.py @@ -10,6 +10,8 @@ import typing_extensions as te from pydantic import Field +if t.TYPE_CHECKING: + from atproto_client import models from atproto_client.models import base @@ -34,3 +36,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyGraphFollow.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyGraphFollow.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyGraphFollow.Record`.""" + + records: t.Dict[str, 'models.AppBskyGraphFollow.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyGraphFollow.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/graph/list.py b/packages/atproto_client/models/app/bsky/graph/list.py index 03ec5f43..6805eca5 100644 --- a/packages/atproto_client/models/app/bsky/graph/list.py +++ b/packages/atproto_client/models/app/bsky/graph/list.py @@ -46,3 +46,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyGraphList.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyGraphList.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyGraphList.Record`.""" + + records: t.Dict[str, 'models.AppBskyGraphList.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyGraphList.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/graph/listblock.py b/packages/atproto_client/models/app/bsky/graph/listblock.py index 344549d7..ec30be0f 100644 --- a/packages/atproto_client/models/app/bsky/graph/listblock.py +++ b/packages/atproto_client/models/app/bsky/graph/listblock.py @@ -10,6 +10,8 @@ import typing_extensions as te from pydantic import Field +if t.TYPE_CHECKING: + from atproto_client import models from atproto_client.models import base @@ -36,3 +38,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyGraphListblock.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyGraphListblock.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyGraphListblock.Record`.""" + + records: t.Dict[str, 'models.AppBskyGraphListblock.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyGraphListblock.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/app/bsky/graph/listitem.py b/packages/atproto_client/models/app/bsky/graph/listitem.py index 942552cb..aee204f9 100644 --- a/packages/atproto_client/models/app/bsky/graph/listitem.py +++ b/packages/atproto_client/models/app/bsky/graph/listitem.py @@ -10,6 +10,8 @@ import typing_extensions as te from pydantic import Field +if t.TYPE_CHECKING: + from atproto_client import models from atproto_client.models import base @@ -37,3 +39,25 @@ def __init__(self, **data: t.Any) -> None: warnings.warn('Main class is deprecated. Use Record class instead.', DeprecationWarning, stacklevel=2) super().__init__(**data) + + +class GetRecordResponse(base.SugarResponseModelBase): + """Get record response for :obj:`models.AppBskyGraphListitem.Record`.""" + + uri: str #: The URI of the record. + value: 'models.AppBskyGraphListitem.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. + + +class ListRecordsResponse(base.SugarResponseModelBase): + """List records response for :obj:`models.AppBskyGraphListitem.Record`.""" + + records: t.Dict[str, 'models.AppBskyGraphListitem.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. + + +class CreateRecordResponse(base.SugarResponseModelBase): + """Create record response for :obj:`models.AppBskyGraphListitem.Record`.""" + + uri: str #: The URI of the record. + cid: str #: The CID of the record. diff --git a/packages/atproto_client/models/base.py b/packages/atproto_client/models/base.py index b39cea6b..cc75bb3d 100644 --- a/packages/atproto_client/models/base.py +++ b/packages/atproto_client/models/base.py @@ -55,6 +55,10 @@ class ResponseModelBase(ModelBase): pass +class SugarResponseModelBase(ResponseModelBase): + pass + + class UnknownDict(AtProtocolBase): pass diff --git a/packages/atproto_client/namespaces/async_ns.py b/packages/atproto_client/namespaces/async_ns.py index cc8d1022..57db64d5 100644 --- a/packages/atproto_client/namespaces/async_ns.py +++ b/packages/atproto_client/namespaces/async_ns.py @@ -6,7 +6,6 @@ import typing as t -from dataclasses import dataclass from atproto_client import models from atproto_client.models.utils import get_or_create, get_response_model @@ -33,15 +32,9 @@ def __init__(self, client: 'AsyncClientRaw') -> None: class ProfileRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyActorProfile.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyActorProfile.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyActorProfile.GetRecordResponse': """Get a record. Args: @@ -51,7 +44,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyActorProfile.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -63,19 +56,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyActorProfile.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyActorProfile.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyActorProfile.Record`.""" - - records: t.Dict[str, 'models.AppBskyActorProfile.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -83,7 +69,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyActorProfile.ListRecordsResponse': """List a range of records in a collection. Args: @@ -94,7 +80,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyActorProfile.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -110,7 +96,7 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyActorProfile.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyActorProfile.Record', record.value) for record in response_model.records @@ -118,13 +104,6 @@ async def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyActorProfile.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -133,7 +112,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyActorProfile.CreateRecordResponse': """Create a new record. Args: @@ -145,7 +124,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyActorProfile.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -166,7 +145,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyActorProfile.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -397,15 +376,9 @@ async def search_actors_typeahead( class GeneratorRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedGenerator.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedGenerator.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedGenerator.GetRecordResponse': """Get a record. Args: @@ -415,7 +388,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedGenerator.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -427,19 +400,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedGenerator.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedGenerator.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedGenerator.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedGenerator.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -447,7 +413,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedGenerator.ListRecordsResponse': """List a range of records in a collection. Args: @@ -458,7 +424,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedGenerator.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -474,7 +440,7 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedGenerator.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedGenerator.Record', record.value) for record in response_model.records @@ -482,13 +448,6 @@ async def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedGenerator.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -497,7 +456,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedGenerator.CreateRecordResponse': """Create a new record. Args: @@ -509,7 +468,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedGenerator.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -530,7 +489,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedGenerator.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -569,15 +528,9 @@ async def delete( class LikeRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedLike.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedLike.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedLike.GetRecordResponse': """Get a record. Args: @@ -587,7 +540,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedLike.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -599,19 +552,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedLike.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedLike.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedLike.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedLike.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -619,7 +565,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedLike.ListRecordsResponse': """List a range of records in a collection. Args: @@ -630,7 +576,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedLike.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -646,20 +592,13 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedLike.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedLike.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedLike.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -668,7 +607,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedLike.CreateRecordResponse': """Create a new record. Args: @@ -680,7 +619,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedLike.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -701,7 +640,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedLike.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -740,15 +679,9 @@ async def delete( class PostRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedPost.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedPost.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedPost.GetRecordResponse': """Get a record. Args: @@ -758,7 +691,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedPost.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -770,19 +703,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedPost.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedPost.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedPost.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedPost.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -790,7 +716,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedPost.ListRecordsResponse': """List a range of records in a collection. Args: @@ -801,7 +727,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedPost.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -817,20 +743,13 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedPost.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedPost.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedPost.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -839,7 +758,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedPost.CreateRecordResponse': """Create a new record. Args: @@ -851,7 +770,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedPost.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -872,7 +791,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedPost.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -911,15 +830,9 @@ async def delete( class RepostRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedRepost.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedRepost.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedRepost.GetRecordResponse': """Get a record. Args: @@ -929,7 +842,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedRepost.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -941,19 +854,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedRepost.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedRepost.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedRepost.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedRepost.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -961,7 +867,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedRepost.ListRecordsResponse': """List a range of records in a collection. Args: @@ -972,7 +878,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedRepost.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -988,20 +894,13 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedRepost.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedRepost.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedRepost.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -1010,7 +909,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedRepost.CreateRecordResponse': """Create a new record. Args: @@ -1022,7 +921,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedRepost.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1043,7 +942,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedRepost.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -1082,15 +981,9 @@ async def delete( class ThreadgateRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedThreadgate.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedThreadgate.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedThreadgate.GetRecordResponse': """Get a record. Args: @@ -1100,7 +993,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedThreadgate.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1112,19 +1005,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedThreadgate.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedThreadgate.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedThreadgate.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedThreadgate.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -1132,7 +1018,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedThreadgate.ListRecordsResponse': """List a range of records in a collection. Args: @@ -1143,7 +1029,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedThreadgate.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1159,7 +1045,7 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedThreadgate.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedThreadgate.Record', record.value) for record in response_model.records @@ -1167,13 +1053,6 @@ async def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedThreadgate.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -1182,7 +1061,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedThreadgate.CreateRecordResponse': """Create a new record. Args: @@ -1194,7 +1073,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedThreadgate.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1215,7 +1094,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedThreadgate.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -1657,15 +1536,9 @@ async def search_posts( class BlockRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphBlock.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphBlock.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphBlock.GetRecordResponse': """Get a record. Args: @@ -1675,7 +1548,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphBlock.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1687,19 +1560,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphBlock.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphBlock.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphBlock.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphBlock.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -1707,7 +1573,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphBlock.ListRecordsResponse': """List a range of records in a collection. Args: @@ -1718,7 +1584,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphBlock.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1734,20 +1600,13 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphBlock.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphBlock.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphBlock.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -1756,7 +1615,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphBlock.CreateRecordResponse': """Create a new record. Args: @@ -1768,7 +1627,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphBlock.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1789,7 +1648,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphBlock.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -1828,15 +1687,9 @@ async def delete( class FollowRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphFollow.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphFollow.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphFollow.GetRecordResponse': """Get a record. Args: @@ -1846,7 +1699,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphFollow.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1858,19 +1711,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphFollow.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphFollow.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphFollow.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphFollow.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -1878,7 +1724,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphFollow.ListRecordsResponse': """List a range of records in a collection. Args: @@ -1889,7 +1735,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphFollow.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1905,7 +1751,7 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphFollow.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphFollow.Record', record.value) for record in response_model.records @@ -1913,13 +1759,6 @@ async def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphFollow.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -1928,7 +1767,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphFollow.CreateRecordResponse': """Create a new record. Args: @@ -1940,7 +1779,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphFollow.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1961,7 +1800,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphFollow.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -2000,15 +1839,9 @@ async def delete( class ListRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphList.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphList.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphList.GetRecordResponse': """Get a record. Args: @@ -2018,7 +1851,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphList.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2030,19 +1863,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphList.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphList.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphList.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphList.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -2050,7 +1876,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphList.ListRecordsResponse': """List a range of records in a collection. Args: @@ -2061,7 +1887,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphList.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2077,20 +1903,13 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphList.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphList.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphList.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -2099,7 +1918,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphList.CreateRecordResponse': """Create a new record. Args: @@ -2111,7 +1930,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphList.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2132,7 +1951,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphList.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -2171,15 +1990,9 @@ async def delete( class ListblockRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphListblock.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphListblock.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphListblock.GetRecordResponse': """Get a record. Args: @@ -2189,7 +2002,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphListblock.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2201,19 +2014,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphListblock.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphListblock.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphListblock.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphListblock.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -2221,7 +2027,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphListblock.ListRecordsResponse': """List a range of records in a collection. Args: @@ -2232,7 +2038,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphListblock.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2248,7 +2054,7 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphListblock.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphListblock.Record', record.value) for record in response_model.records @@ -2256,13 +2062,6 @@ async def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphListblock.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -2271,7 +2070,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphListblock.CreateRecordResponse': """Create a new record. Args: @@ -2283,7 +2082,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphListblock.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2304,7 +2103,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphListblock.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, @@ -2343,15 +2142,9 @@ async def delete( class ListitemRecord(AsyncRecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphListitem.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphListitem.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + async def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphListitem.GetRecordResponse': """Get a record. Args: @@ -2361,7 +2154,7 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphListitem.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2373,19 +2166,12 @@ async def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphListitem.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphListitem.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphListitem.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphListitem.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - async def list( self, repo: str, @@ -2393,7 +2179,7 @@ async def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphListitem.ListRecordsResponse': """List a range of records in a collection. Args: @@ -2404,7 +2190,7 @@ async def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphListitem.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2420,7 +2206,7 @@ async def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphListitem.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphListitem.Record', record.value) for record in response_model.records @@ -2428,13 +2214,6 @@ async def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphListitem.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - async def create( self, repo: str, @@ -2443,7 +2222,7 @@ async def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphListitem.CreateRecordResponse': """Create a new record. Args: @@ -2455,7 +2234,7 @@ async def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphListitem.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2476,7 +2255,7 @@ async def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphListitem.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) async def delete( self, diff --git a/packages/atproto_client/namespaces/sync_ns.py b/packages/atproto_client/namespaces/sync_ns.py index cef44061..e964f3b6 100644 --- a/packages/atproto_client/namespaces/sync_ns.py +++ b/packages/atproto_client/namespaces/sync_ns.py @@ -6,7 +6,6 @@ import typing as t -from dataclasses import dataclass from atproto_client import models from atproto_client.models.utils import get_or_create, get_response_model @@ -33,15 +32,9 @@ def __init__(self, client: 'ClientRaw') -> None: class ProfileRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyActorProfile.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyActorProfile.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyActorProfile.GetRecordResponse': """Get a record. Args: @@ -51,7 +44,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyActorProfile.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -63,19 +56,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyActorProfile.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyActorProfile.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyActorProfile.Record`.""" - - records: t.Dict[str, 'models.AppBskyActorProfile.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -83,7 +69,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyActorProfile.ListRecordsResponse': """List a range of records in a collection. Args: @@ -94,7 +80,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyActorProfile.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -110,7 +96,7 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyActorProfile.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyActorProfile.Record', record.value) for record in response_model.records @@ -118,13 +104,6 @@ def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyActorProfile.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -133,7 +112,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyActorProfile.CreateRecordResponse': """Create a new record. Args: @@ -145,7 +124,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyActorProfile.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -166,7 +145,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyActorProfile.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -397,15 +376,9 @@ def search_actors_typeahead( class GeneratorRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedGenerator.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedGenerator.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedGenerator.GetRecordResponse': """Get a record. Args: @@ -415,7 +388,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedGenerator.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -427,19 +400,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedGenerator.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedGenerator.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedGenerator.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedGenerator.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -447,7 +413,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedGenerator.ListRecordsResponse': """List a range of records in a collection. Args: @@ -458,7 +424,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedGenerator.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -474,7 +440,7 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedGenerator.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedGenerator.Record', record.value) for record in response_model.records @@ -482,13 +448,6 @@ def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedGenerator.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -497,7 +456,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedGenerator.CreateRecordResponse': """Create a new record. Args: @@ -509,7 +468,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedGenerator.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -530,7 +489,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedGenerator.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -569,15 +528,9 @@ def delete( class LikeRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedLike.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedLike.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedLike.GetRecordResponse': """Get a record. Args: @@ -587,7 +540,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedLike.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -599,19 +552,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedLike.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedLike.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedLike.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedLike.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -619,7 +565,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedLike.ListRecordsResponse': """List a range of records in a collection. Args: @@ -630,7 +576,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedLike.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -646,20 +592,13 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedLike.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedLike.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedLike.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -668,7 +607,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedLike.CreateRecordResponse': """Create a new record. Args: @@ -680,7 +619,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedLike.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -701,7 +640,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedLike.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -740,15 +679,9 @@ def delete( class PostRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedPost.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedPost.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedPost.GetRecordResponse': """Get a record. Args: @@ -758,7 +691,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedPost.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -770,19 +703,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedPost.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedPost.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedPost.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedPost.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -790,7 +716,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedPost.ListRecordsResponse': """List a range of records in a collection. Args: @@ -801,7 +727,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedPost.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -817,20 +743,13 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedPost.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedPost.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedPost.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -839,7 +758,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedPost.CreateRecordResponse': """Create a new record. Args: @@ -851,7 +770,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedPost.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -872,7 +791,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedPost.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -911,15 +830,9 @@ def delete( class RepostRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedRepost.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedRepost.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedRepost.GetRecordResponse': """Get a record. Args: @@ -929,7 +842,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedRepost.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -941,19 +854,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedRepost.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedRepost.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedRepost.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedRepost.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -961,7 +867,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedRepost.ListRecordsResponse': """List a range of records in a collection. Args: @@ -972,7 +878,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedRepost.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -988,20 +894,13 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedRepost.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedRepost.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedRepost.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -1010,7 +909,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedRepost.CreateRecordResponse': """Create a new record. Args: @@ -1022,7 +921,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedRepost.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1043,7 +942,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedRepost.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -1082,15 +981,9 @@ def delete( class ThreadgateRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyFeedThreadgate.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyFeedThreadgate.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyFeedThreadgate.GetRecordResponse': """Get a record. Args: @@ -1100,7 +993,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyFeedThreadgate.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1112,19 +1005,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyFeedThreadgate.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyFeedThreadgate.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyFeedThreadgate.Record`.""" - - records: t.Dict[str, 'models.AppBskyFeedThreadgate.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -1132,7 +1018,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyFeedThreadgate.ListRecordsResponse': """List a range of records in a collection. Args: @@ -1143,7 +1029,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyFeedThreadgate.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1159,7 +1045,7 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyFeedThreadgate.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyFeedThreadgate.Record', record.value) for record in response_model.records @@ -1167,13 +1053,6 @@ def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyFeedThreadgate.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -1182,7 +1061,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyFeedThreadgate.CreateRecordResponse': """Create a new record. Args: @@ -1194,7 +1073,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyFeedThreadgate.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1215,7 +1094,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyFeedThreadgate.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -1657,15 +1536,9 @@ def search_posts( class BlockRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphBlock.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphBlock.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphBlock.GetRecordResponse': """Get a record. Args: @@ -1675,7 +1548,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphBlock.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1687,19 +1560,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphBlock.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphBlock.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphBlock.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphBlock.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -1707,7 +1573,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphBlock.ListRecordsResponse': """List a range of records in a collection. Args: @@ -1718,7 +1584,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphBlock.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1734,20 +1600,13 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphBlock.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphBlock.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphBlock.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -1756,7 +1615,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphBlock.CreateRecordResponse': """Create a new record. Args: @@ -1768,7 +1627,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphBlock.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1789,7 +1648,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphBlock.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -1828,15 +1687,9 @@ def delete( class FollowRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphFollow.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphFollow.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphFollow.GetRecordResponse': """Get a record. Args: @@ -1846,7 +1699,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphFollow.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1858,19 +1711,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphFollow.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphFollow.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphFollow.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphFollow.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -1878,7 +1724,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphFollow.ListRecordsResponse': """List a range of records in a collection. Args: @@ -1889,7 +1735,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphFollow.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1905,7 +1751,7 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphFollow.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphFollow.Record', record.value) for record in response_model.records @@ -1913,13 +1759,6 @@ def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphFollow.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -1928,7 +1767,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphFollow.CreateRecordResponse': """Create a new record. Args: @@ -1940,7 +1779,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphFollow.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -1961,7 +1800,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphFollow.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -2000,15 +1839,9 @@ def delete( class ListRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphList.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphList.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphList.GetRecordResponse': """Get a record. Args: @@ -2018,7 +1851,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphList.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2030,19 +1863,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphList.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphList.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphList.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphList.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -2050,7 +1876,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphList.ListRecordsResponse': """List a range of records in a collection. Args: @@ -2061,7 +1887,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphList.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2077,20 +1903,13 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphList.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphList.Record', record.value) for record in response_model.records }, cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphList.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -2099,7 +1918,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphList.CreateRecordResponse': """Create a new record. Args: @@ -2111,7 +1930,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphList.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2132,7 +1951,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphList.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -2171,15 +1990,9 @@ def delete( class ListblockRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphListblock.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphListblock.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphListblock.GetRecordResponse': """Get a record. Args: @@ -2189,7 +2002,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphListblock.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2201,19 +2014,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphListblock.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphListblock.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphListblock.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphListblock.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -2221,7 +2027,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphListblock.ListRecordsResponse': """List a range of records in a collection. Args: @@ -2232,7 +2038,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphListblock.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2248,7 +2054,7 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphListblock.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphListblock.Record', record.value) for record in response_model.records @@ -2256,13 +2062,6 @@ def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphListblock.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -2271,7 +2070,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphListblock.CreateRecordResponse': """Create a new record. Args: @@ -2283,7 +2082,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphListblock.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2304,7 +2103,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphListblock.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, @@ -2343,15 +2142,9 @@ def delete( class ListitemRecord(RecordBase): - @dataclass - class GetRecordResponse: - """Get record response for :obj:`models.AppBskyGraphListitem.Record`.""" - - uri: str #: The URI of the record. - value: 'models.AppBskyGraphListitem.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. - - def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any) -> GetRecordResponse: + def get( + self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any + ) -> 'models.AppBskyGraphListitem.GetRecordResponse': """Get a record. Args: @@ -2361,7 +2154,7 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.AppBskyGraphListitem.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2373,19 +2166,12 @@ def get(self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.AppBskyGraphListitem.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.AppBskyGraphListitem.Record', response_model.value), ) - @dataclass - class ListRecordsResponse: - """List records response for :obj:`models.AppBskyGraphListitem.Record`.""" - - records: t.Dict[str, 'models.AppBskyGraphListitem.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. - def list( self, repo: str, @@ -2393,7 +2179,7 @@ def list( limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.AppBskyGraphListitem.ListRecordsResponse': """List a range of records in a collection. Args: @@ -2404,7 +2190,7 @@ def list( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.AppBskyGraphListitem.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2420,7 +2206,7 @@ def list( 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.AppBskyGraphListitem.ListRecordsResponse( records={ record.uri: t.cast('models.AppBskyGraphListitem.Record', record.value) for record in response_model.records @@ -2428,13 +2214,6 @@ def list( cursor=response_model.cursor, ) - @dataclass - class CreateRecordResponse: - """Create record response for :obj:`models.AppBskyGraphListitem.Record`.""" - - uri: str #: The URI of the record. - cid: str #: The CID of the record. - def create( self, repo: str, @@ -2443,7 +2222,7 @@ def create( swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.AppBskyGraphListitem.CreateRecordResponse': """Create a new record. Args: @@ -2455,7 +2234,7 @@ def create( **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.AppBskyGraphListitem.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -2476,7 +2255,7 @@ def create( **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.AppBskyGraphListitem.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) def delete( self, diff --git a/packages/atproto_codegen/models/generator.py b/packages/atproto_codegen/models/generator.py index da5c47aa..fe2e22dc 100644 --- a/packages/atproto_codegen/models/generator.py +++ b/packages/atproto_codegen/models/generator.py @@ -16,6 +16,11 @@ PARAMS_MODEL, ) from atproto_codegen.models import builder +from atproto_codegen.record_templates import ( + RECORD_CREATE_RESPONSE_MODEL_TEMPLATE, + RECORD_GET_RESPONSE_MODEL_TEMPLATE, + RECORD_LIST_RESPONSE_MODEL_TEMPLATE, +) from atproto_codegen.utils import ( _resolve_nsid_ref, append_code, @@ -631,6 +636,18 @@ def _generate_def_models(lex_db: builder.BuiltDefModels) -> None: raise ValueError(f'Unhandled type {type(def_model)}') +def _generate_record_sugar_models(nsid: NSID) -> str: + lines = [] + for model in [ + RECORD_GET_RESPONSE_MODEL_TEMPLATE, + RECORD_LIST_RESPONSE_MODEL_TEMPLATE, + RECORD_CREATE_RESPONSE_MODEL_TEMPLATE, + ]: + lines.append(model.format(record_import=get_import_path(nsid))) + + return join_code(lines) + + def _generate_record_models(lex_db: builder.BuiltRecordModels) -> None: for nsid, defs in lex_db.items(): _save_code_import_if_not_exist(nsid) @@ -639,6 +656,7 @@ def _generate_record_models(lex_db: builder.BuiltRecordModels) -> None: if isinstance(def_record, models.LexRecord): # TODO(MarshalX): Process somehow def_record.key? save_code_part(nsid, _generate_def_model(nsid, def_name, def_record.record, ModelType.RECORD)) + save_code_part(nsid, _generate_record_sugar_models(nsid)) def _generate_record_type_database(lex_db: builder.BuiltRecordModels) -> None: diff --git a/packages/atproto_codegen/namespaces/generator.py b/packages/atproto_codegen/namespaces/generator.py index f19409ac..ff3161ce 100644 --- a/packages/atproto_codegen/namespaces/generator.py +++ b/packages/atproto_codegen/namespaces/generator.py @@ -19,7 +19,7 @@ PARAMS_MODEL, ) from atproto_codegen.namespaces.builder import MethodInfo, ProcedureInfo, QueryInfo, RecordInfo, build_namespaces -from atproto_codegen.namespaces.record_templates import ( +from atproto_codegen.record_templates import ( RECORD_CREATE_METHOD_TEMPLATE, RECORD_DELETE_METHOD_TEMPLATE, RECORD_GET_METHOD_TEMPLATE, @@ -59,7 +59,6 @@ def _get_namespace_imports() -> str: lines = [ DISCLAIMER, 'import typing as t', - 'from dataclasses import dataclass', '', 'from atproto_client import models', 'from atproto_client.models.utils import get_or_create, get_response_model', diff --git a/packages/atproto_codegen/namespaces/record_templates.py b/packages/atproto_codegen/record_templates.py similarity index 77% rename from packages/atproto_codegen/namespaces/record_templates.py rename to packages/atproto_codegen/record_templates.py index 1b6362ee..37cf3126 100644 --- a/packages/atproto_codegen/namespaces/record_templates.py +++ b/packages/atproto_codegen/record_templates.py @@ -4,14 +4,15 @@ # in original code, TypeScript Omit<> is used for args instead of coping # this approach provides more clean usage on the user side with type hints -RECORD_CREATE_METHOD_TEMPLATE = """ - @dataclass - class CreateRecordResponse: - \"""Create record response for :obj:`models.{record_import}.Record`.\""" +RECORD_CREATE_RESPONSE_MODEL_TEMPLATE = """ +class CreateRecordResponse(base.SugarResponseModelBase): + \"""Create record response for :obj:`models.{record_import}.Record`.\""" - uri: str #: The URI of the record. - cid: str #: The CID of the record. + uri: str #: The URI of the record. + cid: str #: The CID of the record. +""" +RECORD_CREATE_METHOD_TEMPLATE = """ {d}def create( self, repo: str, @@ -20,7 +21,7 @@ class CreateRecordResponse: swap_commit: t.Optional[str] = None, validate: t.Optional[bool] = True, **kwargs: t.Any, - ) -> CreateRecordResponse: + ) -> 'models.{record_import}.CreateRecordResponse': \"""Create a new record. Args: @@ -32,7 +33,7 @@ class CreateRecordResponse: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`CreateRecordResponse`: Create record response. + :obj:`models.{record_import}.CreateRecordResponse`: Create record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -53,21 +54,22 @@ class CreateRecordResponse: **kwargs, ) response_model = get_response_model(response, models.ComAtprotoRepoCreateRecord.Response) - return self.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) + return models.{record_import}.CreateRecordResponse(uri=response_model.uri, cid=response_model.cid) """ -RECORD_GET_METHOD_TEMPLATE = """ - @dataclass - class GetRecordResponse: - \"""Get record response for :obj:`models.{record_import}.Record`.\""" +RECORD_GET_RESPONSE_MODEL_TEMPLATE = """ +class GetRecordResponse(base.SugarResponseModelBase): + \"""Get record response for :obj:`models.{record_import}.Record`.\""" - uri: str #: The URI of the record. - value: 'models.{record_import}.Record' #: The record. - cid: t.Optional[str] = None #: The CID of the record. + uri: str #: The URI of the record. + value: 'models.{record_import}.Record' #: The record. + cid: t.Optional[str] = None #: The CID of the record. +""" +RECORD_GET_METHOD_TEMPLATE = """ {d}def get( self, repo: str, rkey: str, cid: t.Optional[str] = None, **kwargs: t.Any - ) -> GetRecordResponse: + ) -> 'models.{record_import}.GetRecordResponse': \"""Get a record. Args: @@ -77,7 +79,7 @@ class GetRecordResponse: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`GetRecordResponse`: Get record response. + :obj:`models.{record_import}.GetRecordResponse`: Get record response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -92,21 +94,22 @@ class GetRecordResponse: 'com.atproto.repo.getRecord', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoGetRecord.Response) - return self.GetRecordResponse( + return models.{record_import}.GetRecordResponse( uri=response_model.uri, cid=response_model.cid, value=t.cast('models.{record_import}.Record', response_model.value), ) """ -RECORD_LIST_METHOD_TEMPLATE = """ - @dataclass - class ListRecordsResponse: - \"""List records response for :obj:`models.{record_import}.Record`.\""" +RECORD_LIST_RESPONSE_MODEL_TEMPLATE = """ +class ListRecordsResponse(base.SugarResponseModelBase): + \"""List records response for :obj:`models.{record_import}.Record`.\""" - records: t.Dict[str, 'models.{record_import}.Record'] #: Map of URIs to records. - cursor: t.Optional[str] = None #: Next page cursor. + records: t.Dict[str, 'models.{record_import}.Record'] #: Map of URIs to records. + cursor: t.Optional[str] = None #: Next page cursor. +""" +RECORD_LIST_METHOD_TEMPLATE = """ {d}def list( self, repo: str, @@ -114,7 +117,7 @@ class ListRecordsResponse: limit: t.Optional[int] = None, reverse: t.Optional[bool] = None, **kwargs: t.Any, - ) -> ListRecordsResponse: + ) -> 'models.{record_import}.ListRecordsResponse': \"""List a range of records in a collection. Args: @@ -125,7 +128,7 @@ class ListRecordsResponse: **kwargs: Arbitrary arguments to HTTP request. Returns: - :obj:`ListRecordsResponse`: List records response. + :obj:`models.{record_import}.ListRecordsResponse`: List records response. Raises: :class:`atproto.exceptions.AtProtocolError`: Base exception. @@ -141,7 +144,7 @@ class ListRecordsResponse: 'com.atproto.repo.listRecords', params=params_model, output_encoding='application/json', **kwargs ) response_model = get_response_model(response, models.ComAtprotoRepoListRecords.Response) - return self.ListRecordsResponse( + return models.{record_import}.ListRecordsResponse( records={{ record.uri: t.cast('models.{record_import}.Record', record.value) for record in response_model.records