squarecloud-api 3.6.0__tar.gz → 3.6.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,20 +1,20 @@
1
- The MIT License (MIT)
2
-
3
- Copyright (c) 2022 Robert Nogueira
4
-
5
- Permission is hereby granted, free of charge, to any person obtaining a copy of
6
- this software and associated documentation files (the "Software"), to deal in
7
- the Software without restriction, including without limitation the rights to
8
- use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
- the Software, and to permit persons to whom the Software is furnished to do so,
10
- subject to the following conditions:
11
-
12
- The above copyright notice and this permission notice shall be included in all
13
- copies or substantial portions of the Software.
14
-
15
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
- FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
- IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2022 Robert Nogueira
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of
6
+ this software and associated documentation files (the "Software"), to deal in
7
+ the Software without restriction, including without limitation the rights to
8
+ use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9
+ the Software, and to permit persons to whom the Software is furnished to do so,
10
+ subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17
+ FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18
+ COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19
+ IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20
20
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: squarecloud-api
3
- Version: 3.6.0
3
+ Version: 3.6.1
4
4
  Summary: SquareCloud API wrapper
5
5
  Home-page: https://github.com/squarecloudofc/wrapper-api-py
6
6
  License: MIT
@@ -14,10 +14,8 @@ Classifier: Programming Language :: Python :: 3.10
14
14
  Classifier: Programming Language :: Python :: 3.11
15
15
  Classifier: Programming Language :: Python :: 3.12
16
16
  Requires-Dist: aiohttp (==3.9.5)
17
- Requires-Dist: click (>=8.1.6,<9.0.0)
18
17
  Requires-Dist: pydantic (>=2.5.2,<3.0.0)
19
- Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
20
- Requires-Dist: rich (>=13.5.2,<14.0.0)
18
+ Requires-Dist: taskipy (>=1.13.0,<2.0.0)
21
19
  Project-URL: Documentation, https://docs.squarecloud.app/sdks/py
22
20
  Project-URL: Repository, https://github.com/squarecloudofc/wrapper-api-py
23
21
  Description-Content-Type: text/markdown
@@ -1,6 +1,6 @@
1
1
  [tool.poetry]
2
2
  name = 'squarecloud-api'
3
- version = '3.6.0'
3
+ version = '3.6.1'
4
4
  description = 'SquareCloud API wrapper'
5
5
  authors = ['Robert Nogueira <robertlucasnogueira@gmail.com>']
6
6
  repository = 'https://github.com/squarecloudofc/wrapper-api-py'
@@ -12,10 +12,8 @@ packages = [{ include = 'squarecloud' }]
12
12
  [tool.poetry.dependencies]
13
13
  python = '^3.9'
14
14
  aiohttp = "3.9.5"
15
- click = '^8.1.6'
16
- rich = '^13.5.2'
17
15
  pydantic = '^2.5.2'
18
- python-dotenv = '^1.0.0'
16
+ taskipy = "^1.13.0"
19
17
 
20
18
  [tool.poetry.group.dev.dependencies]
21
19
  pytest = '^7.4.3'
@@ -28,7 +26,6 @@ ruff = '^0.0.289'
28
26
  memory-profiler = '^0.61.0'
29
27
  requests = '^2.31.0'
30
28
  pytest-rerunfailures = "^13.0"
31
- taskipy = "^1.13.0"
32
29
 
33
30
  [build-system]
34
31
  requires = ['poetry-core']
@@ -8,17 +8,17 @@ from .data import (
8
8
  Backup,
9
9
  BackupInfo,
10
10
  DeployData,
11
+ DNSRecord,
11
12
  DomainAnalytics,
12
13
  FileInfo,
13
14
  LogsData,
14
15
  PlanData,
16
+ ResumedStatus,
15
17
  StatusData,
16
18
  UploadData,
17
19
  UserData,
18
- ResumedStatus,
19
- DNSRecord,
20
20
  )
21
21
  from .file import File
22
22
  from .http.endpoints import Endpoint
23
23
 
24
- __version__ = '3.6.0'
24
+ __version__ = '3.6.1'
@@ -657,6 +657,9 @@ class Application(CaptureListenerManager):
657
657
  async def move_file(self, origin: str, dest: str):
658
658
  return await self.client.move_app_file(self.id, origin, dest)
659
659
 
660
+ async def current_integration(self):
661
+ return await self.client.current_app_integration(self.id)
662
+
660
663
  @_notify_listener(Endpoint.dns_records())
661
664
  async def dns_records(self) -> list[DNSRecord]:
662
665
  return await self.client.dns_records(self.id)
@@ -739,6 +739,7 @@ class Client(RequestListenerManager):
739
739
  response: Response = await self._http.domain_analytics(
740
740
  app_id=app_id,
741
741
  )
742
+
742
743
  return DomainAnalytics(**response.response)
743
744
 
744
745
  @_notify_listener(Endpoint.all_backups())
@@ -772,3 +773,8 @@ class Client(RequestListenerManager):
772
773
  async def dns_records(self, app_id: str) -> list[DNSRecord]:
773
774
  response: Response = await self._http.dns_records(app_id)
774
775
  return [DNSRecord(**data) for data in response.response]
776
+
777
+ @_notify_listener(Endpoint.current_integration())
778
+ async def current_app_integration(self, app_id: str) -> str | None:
779
+ response: Response = await self._http.current_app_integration(app_id)
780
+ return response.response
@@ -310,17 +310,33 @@ class AnalyticsTotal:
310
310
 
311
311
  @dataclass(frozen=True)
312
312
  class DomainAnalytics:
313
- hostname: str
314
- total: list[AnalyticsTotal]
315
- countries: list[Any]
316
- methods: list[Any]
317
- referers: list[Any]
318
- browsers: list[Any]
319
- deviceTypes: list[Any]
320
- operatingSystems: list[Any]
321
- agents: list[Any]
322
- hosts: list[Any]
323
- paths: list[Any]
313
+ @dataclass(frozen=True)
314
+ class Analytics:
315
+ total: list[AnalyticsTotal]
316
+ countries: list[Any]
317
+ methods: list[Any]
318
+ referers: list[Any]
319
+ browsers: list[Any]
320
+ deviceTypes: list[Any]
321
+ operatingSystems: list[Any]
322
+ agents: list[Any]
323
+ hosts: list[Any]
324
+ paths: list[Any]
325
+
326
+ def to_dict(self):
327
+ return self.__dict__.copy()
328
+
329
+ @dataclass(frozen=True)
330
+ class Domain:
331
+ hostname: str
332
+ analytics: DomainAnalytics.Analytics | None
333
+
334
+ @dataclass(frozen=True)
335
+ class Custom:
336
+ analytics: DomainAnalytics.Analytics | None
337
+
338
+ domain: Domain
339
+ custom: Custom
324
340
 
325
341
  def to_dict(self):
326
342
  return self.__dict__.copy()
@@ -1,61 +1,61 @@
1
- from __future__ import annotations
2
-
3
- import io
4
- import os
5
- from typing import Any
6
-
7
- from squarecloud import errors
8
-
9
-
10
- class File:
11
- """
12
- File object
13
-
14
- You can use a file already opened or pass the file path.
15
- NOTE: To pass binary data, consider usage of `io.BytesIO`.
16
- """
17
-
18
- __slots__ = ('bytes', 'filename')
19
-
20
- def __init__(
21
- self,
22
- fp: str | bytes | os.PathLike[Any] | io.BufferedIOBase,
23
- filename: str | None = None,
24
- ):
25
-
26
- """
27
- The __init__ function is called when the class is instantiated.
28
- It sets up the instance of the class, and it's where you put all your
29
- initialization code.
30
- The __init__ function takes at least one argument: self, which refers
31
- to the object being created.
32
-
33
- :param self: Refer to the class instance
34
- :param fp: str | bytes | os.PathLike[Any] | io.BufferedIOBase: Define
35
- the file path,
36
- :param filename: str | None: Set the filename attribute of the class
37
- :return: None
38
- """
39
- if isinstance(fp, io.BufferedIOBase):
40
- if not (fp.seekable() and fp.readable()):
41
- raise ValueError(
42
- f'File buffer {fp!r} must be seekable and readable'
43
- )
44
- self.bytes: io.BufferedIOBase = fp
45
- else:
46
- # Verificar se fp é bytes (dados binários) e criar um io.BytesIO
47
- if isinstance(fp, bytes):
48
- self.bytes = io.BytesIO(fp)
49
- else:
50
- self.bytes = open(fp, 'rb')
51
-
52
- if filename is None:
53
- if isinstance(fp, str):
54
- _, filename = os.path.split(fp)
55
- else:
56
- filename = getattr(fp, 'name', None)
57
-
58
- if not filename:
59
- raise errors.SquareException('You need provide a filename')
60
-
61
- self.filename: str | None = filename
1
+ from __future__ import annotations
2
+
3
+ import io
4
+ import os
5
+ from typing import Any
6
+
7
+ from squarecloud import errors
8
+
9
+
10
+ class File:
11
+ """
12
+ File object
13
+
14
+ You can use a file already opened or pass the file path.
15
+ NOTE: To pass binary data, consider usage of `io.BytesIO`.
16
+ """
17
+
18
+ __slots__ = ('bytes', 'filename')
19
+
20
+ def __init__(
21
+ self,
22
+ fp: str | bytes | os.PathLike[Any] | io.BufferedIOBase,
23
+ filename: str | None = None,
24
+ ):
25
+
26
+ """
27
+ The __init__ function is called when the class is instantiated.
28
+ It sets up the instance of the class, and it's where you put all your
29
+ initialization code.
30
+ The __init__ function takes at least one argument: self, which refers
31
+ to the object being created.
32
+
33
+ :param self: Refer to the class instance
34
+ :param fp: str | bytes | os.PathLike[Any] | io.BufferedIOBase: Define
35
+ the file path,
36
+ :param filename: str | None: Set the filename attribute of the class
37
+ :return: None
38
+ """
39
+ if isinstance(fp, io.BufferedIOBase):
40
+ if not (fp.seekable() and fp.readable()):
41
+ raise ValueError(
42
+ f'File buffer {fp!r} must be seekable and readable'
43
+ )
44
+ self.bytes: io.BufferedIOBase = fp
45
+ else:
46
+ # Verificar se fp é bytes (dados binários) e criar um io.BytesIO
47
+ if isinstance(fp, bytes):
48
+ self.bytes = io.BytesIO(fp)
49
+ else:
50
+ self.bytes = open(fp, 'rb')
51
+
52
+ if filename is None:
53
+ if isinstance(fp, str):
54
+ _, filename = os.path.split(fp)
55
+ else:
56
+ filename = getattr(fp, 'name', None)
57
+
58
+ if not filename:
59
+ raise errors.SquareException('You need provide a filename')
60
+
61
+ self.filename: str | None = filename
@@ -1,2 +1,2 @@
1
- from .endpoints import Endpoint
2
- from .http_client import HTTPClient, Response
1
+ from .endpoints import Endpoint
2
+ from .http_client import HTTPClient, Response
@@ -20,11 +20,11 @@ class Endpoint:
20
20
  'UPLOAD_APP': {'METHOD': 'POST', 'PATH': '/apps'},
21
21
  'FILES_LIST': {
22
22
  'METHOD': 'GET',
23
- 'PATH': '/apps/{app_id}/files/list?path={path}',
23
+ 'PATH': '/apps/{app_id}/files?path={path}',
24
24
  },
25
25
  'FILES_READ': {
26
26
  'METHOD': 'GET',
27
- 'PATH': '/apps/{app_id}/files/read?path={path}',
27
+ 'PATH': '/apps/{app_id}/files/content?path={path}',
28
28
  },
29
29
  'FILES_CREATE': {
30
30
  'METHOD': 'PUT',
@@ -32,14 +32,14 @@ class Endpoint:
32
32
  },
33
33
  'FILES_DELETE': {
34
34
  'METHOD': 'DELETE',
35
- 'PATH': '/apps/{app_id}/files/delete?path={path}',
35
+ 'PATH': '/apps/{app_id}/files',
36
36
  },
37
37
  'MOVE_FILE': {'METHOD': 'PATCH', 'PATH': '/apps/{app_id}/files'},
38
38
  'LAST_DEPLOYS': {
39
39
  'METHOD': 'GET',
40
40
  'PATH': '/apps/{app_id}/deployments',
41
41
  },
42
- 'CURRENT_WEBHOOK': {
42
+ 'CURRENT_INTEGRATION': {
43
43
  'METHOD': 'GET',
44
44
  'PATH': '/apps/{app_id}/deployments/current',
45
45
  },
@@ -257,12 +257,12 @@ class Endpoint:
257
257
  return cls('ALL_APPS_STATUS')
258
258
 
259
259
  @classmethod
260
- def current_webhook(cls) -> Endpoint:
260
+ def current_integration(cls) -> Endpoint:
261
261
  """
262
262
  Returns an Endpoint object that represents the
263
263
  /apps/{app_id}/deployments/current endpoint.
264
264
  """
265
- return cls('CURRENT_WEBHOOK')
265
+ return cls('CURRENT_INTEGRATION')
266
266
 
267
267
  @classmethod
268
268
  def move_file(cls) -> Endpoint:
@@ -164,7 +164,7 @@ class HTTPClient:
164
164
  """
165
165
  headers = {
166
166
  'Authorization': self.api_key,
167
- 'User-Agent': 'squarecloud-api/3.6.0',
167
+ 'User-Agent': 'squarecloud-api/3.5.1',
168
168
  }
169
169
  extra_error_kwargs: dict[str, Any] = {}
170
170
 
@@ -528,9 +528,11 @@ class HTTPClient:
528
528
  code is 429
529
529
  """
530
530
  route: Router = Router(
531
- Endpoint.files_delete(), app_id=app_id, path=path
531
+ Endpoint.files_delete(),
532
+ app_id=app_id,
532
533
  )
533
- response: Response = await self.request(route)
534
+ body = {'path': path}
535
+ response: Response = await self.request(route, json=body)
534
536
  return response
535
537
 
536
538
  async def get_app_data(self, app_id: str) -> Response:
@@ -635,6 +637,7 @@ class HTTPClient:
635
637
 
636
638
  :param app_id: The application id
637
639
  :return: A Response object
640
+ :rtype: Response
638
641
 
639
642
  :raises NotFoundError: Raised when the request status code is 404
640
643
  :raises BadRequestError: Raised when the request status code is 400
@@ -650,28 +653,94 @@ class HTTPClient:
650
653
  async def get_all_app_backups(self, app_id: str) -> Response:
651
654
  """
652
655
  Returns a list of all backups of the specified application
653
- :return:
656
+
657
+ :return: A Response object
658
+ :rtype: Response
659
+
660
+ :raises NotFoundError: Raised when the request status code is 404
661
+ :raises BadRequestError: Raised when the request status code is 400
662
+ :raises AuthenticationFailure: Raised when the request status
663
+ code is 401
664
+ :raises TooManyRequestsError: Raised when the request status
665
+ code is 429
654
666
  """
655
667
  route: Router = Router(Endpoint.all_backups(), app_id=app_id)
656
668
  response: Response = await self.request(route)
657
669
  return response
658
670
 
659
671
  async def all_apps_status(self) -> Response:
672
+ """
673
+ Returns all applications status
674
+
675
+ :return: A Response object
676
+ :rtype: Response
677
+
678
+ :raises NotFoundError: Raised when the request status code is 404
679
+ :raises BadRequestError: Raised when the request status code is 400
680
+ :raises AuthenticationFailure: Raised when the request status
681
+ code is 401
682
+ :raises TooManyRequestsError: Raised when the request status
683
+ code is 429
684
+ """
660
685
  route: Router = Router(Endpoint.all_apps_status())
661
686
  response: Response = await self.request(route)
662
687
  return response
663
688
 
664
689
  async def move_app_file(self, app_id: str, origin: str, dest: str):
690
+ """
691
+ Make a http request to move an app file.
692
+
693
+ :return: A Response object
694
+ :rtype: Response
695
+
696
+ :raises NotFoundError: Raised when the request status code is 404
697
+ :raises BadRequestError: Raised when the request status code is 400
698
+ :raises AuthenticationFailure: Raised when the request status
699
+ code is 401
700
+ :raises TooManyRequestsError: Raised when the request status
701
+ code is 429
702
+ """
665
703
  route: Router = Router(Endpoint.move_file(), app_id=app_id)
666
704
  body = {'path': origin, 'to': dest}
667
705
  response: Response = await self.request(route, json=body)
668
706
  return response
669
707
 
670
708
  async def dns_records(self, app_id: str) -> Response:
709
+ """
710
+ Returns dns information of the specified application
711
+
712
+ :return: A Response object
713
+ :rtype: Response
714
+
715
+ :raises NotFoundError: Raised when the request status code is 404
716
+ :raises BadRequestError: Raised when the request status code is 400
717
+ :raises AuthenticationFailure: Raised when the request status
718
+ code is 401
719
+ :raises TooManyRequestsError: Raised when the request status
720
+ code is 429
721
+ """
671
722
  route: Router = Router(Endpoint.dns_records(), app_id=app_id)
672
723
  response: Response = await self.request(route)
673
724
  return response
674
725
 
726
+ async def get_app_current_integration(self, app_id: str) -> Response:
727
+ """
728
+ Returns the webhook url of the application current integration
729
+
730
+ :return: A Response object
731
+ :rtype: Response
732
+
733
+ :raises NotFoundError: Raised when the request status code is 404
734
+ :raises BadRequestError: Raised when the request status code is 400
735
+ :raises AuthenticationFailure: Raised when the request status
736
+ code is 401
737
+ :raises TooManyRequestsError: Raised when the request status
738
+ code is 429
739
+ """
740
+ route: Router = Router(Endpoint.current_webhook(), app_id=app_id)
741
+ response: Response = await self.request(route)
742
+ return response
743
+
675
744
  @property
676
745
  def last_response(self) -> Response | None:
677
746
  """