cc-ampapi 1.3.0__tar.gz → 4.6.0__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.
- {cc_ampapi-1.3.0/cc_ampapi.egg-info → cc_ampapi-4.6.0}/PKG-INFO +109 -47
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/README.md +107 -45
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/__init__.py +10 -10
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/adsmodule.py +315 -77
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/analytics.py +2 -2
- cc_ampapi-4.6.0/ampapi/backoff.py +101 -0
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/base.py +238 -155
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/bridge.py +6 -3
- cc_ampapi-4.6.0/ampapi/controller.py +292 -0
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/core.py +196 -97
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/emailsender.py +2 -2
- cc_ampapi-1.3.0/ampapi/enums.py → cc_ampapi-4.6.0/ampapi/enums_.py +2 -0
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/filebackup.py +27 -8
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/filemanager.py +36 -18
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/instance.py +214 -18
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/minecraft.py +38 -15
- cc_ampapi-1.3.0/ampapi/dataclass.py → cc_ampapi-4.6.0/ampapi/modules.py +352 -46
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/util.py +50 -15
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0/cc_ampapi.egg-info}/PKG-INFO +109 -47
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/cc_ampapi.egg-info/SOURCES.txt +2 -3
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/cc_ampapi.egg-info/requires.txt +1 -1
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/pyproject.toml +36 -35
- cc_ampapi-1.3.0/ampapi/controller.py +0 -159
- cc_ampapi-1.3.0/ampapi/modules.py +0 -216
- cc_ampapi-1.3.0/requirements.txt +0 -3
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/LICENSE +0 -0
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/LICENSE-dpy +0 -0
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/MANIFEST.in +0 -0
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/ampapi/types_.py +0 -0
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/cc_ampapi.egg-info/dependency_links.txt +0 -0
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/cc_ampapi.egg-info/top_level.txt +0 -0
- {cc_ampapi-1.3.0 → cc_ampapi-4.6.0}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cc-ampapi
|
|
3
|
-
Version:
|
|
3
|
+
Version: 4.6.0
|
|
4
4
|
Summary: A Python wrapper for the AMP API by CubeCoders
|
|
5
5
|
Author-email: k8thekat <Cadwalladerkatelynn+AMPAPI@gmail.com>
|
|
6
6
|
License: GNU GENERAL PUBLIC LICENSE
|
|
@@ -704,41 +704,50 @@ Description-Content-Type: text/markdown
|
|
|
704
704
|
License-File: LICENSE
|
|
705
705
|
License-File: LICENSE-dpy
|
|
706
706
|
Requires-Dist: aiohttp>=3.7.4.post0
|
|
707
|
-
Requires-Dist:
|
|
707
|
+
Requires-Dist: dataclass-wizard>=0.22.2
|
|
708
708
|
Requires-Dist: pyotp>=2.6.0
|
|
709
709
|
Dynamic: license-file
|
|
710
710
|
|
|
711
711
|
# AMP API Python
|
|
712
|
-
___
|
|
713
|
-
CubeCoders AMP API wrapper in Python.
|
|
714
712
|
|
|
713
|
+
---
|
|
714
|
+
|
|
715
|
+
CubeCoders AMP API wrapper in Python.
|
|
715
716
|
|
|
716
717
|
<div align="left">
|
|
717
718
|
<a href="https://discord.gg/BtNyU8DFtt"><img src='https://img.shields.io/discord/705500489248145459?color=blue&label=Discord&logo=Discord%20Server&logoColor=green' alt='Discord Server'></a>
|
|
718
719
|
</div>
|
|
719
720
|
|
|
720
721
|
<!--  -->
|
|
721
|
-

|
|
722
722
|
|
|
723
|
+

|
|
723
724
|
|
|
724
725
|
### Key Features
|
|
725
|
-
|
|
726
|
+
|
|
727
|
+
---
|
|
726
728
|
|
|
727
729
|
- Pythonic API wrapper using `async` and `await`.
|
|
728
730
|
- Data is in dataclasses for easier management and interaction.
|
|
729
|
-
|
|
731
|
+
- Optional parameter per function or global to disable formatting of data.
|
|
730
732
|
- Parent classes `ADSInstance` and `AMPInstance` to group endpoints together and make handling of multiple Instances easier.
|
|
731
|
-
|
|
733
|
+
- This will also limit Instance specific API endpoints (eg. Minecraft) to that Instance type only.
|
|
734
|
+
|
|
735
|
+
### Docs
|
|
736
|
+
|
|
737
|
+
- https://ampapi-python.readthedocs.io/en/latest/
|
|
732
738
|
|
|
733
739
|
### Installing
|
|
734
|
-
___
|
|
735
740
|
|
|
736
|
-
|
|
741
|
+
---
|
|
742
|
+
|
|
743
|
+
_Python 3.10 or higher is required_
|
|
737
744
|
|
|
738
745
|
To install run the below command to install the required pip packages from [Requirements](./requirements.txt)
|
|
739
746
|
|
|
740
|
-
### PyPi
|
|
741
|
-
|
|
747
|
+
### PyPi
|
|
748
|
+
|
|
749
|
+
---
|
|
750
|
+
|
|
742
751
|
-> Visit the package on [Pypi](https://pypi.org/project/cc-ampapi/)
|
|
743
752
|
|
|
744
753
|
```bash
|
|
@@ -748,66 +757,117 @@ pip install cc-ampapi
|
|
|
748
757
|
```
|
|
749
758
|
|
|
750
759
|
### Basic Usage
|
|
751
|
-
|
|
760
|
+
|
|
761
|
+
---
|
|
762
|
+
|
|
763
|
+
In your IDE Python file. -> `import ampapi`.
|
|
764
|
+
|
|
752
765
|
1. First you need to fill out the APIParams class with the required fields (url, user and password).
|
|
753
766
|
2. Pass the APIParams class into the Bridge class parameter api_params.
|
|
754
|
-
|
|
767
|
+
- You only need to make ONE bridge class; the rest of the API classes will get the same object and handle logging in for you.
|
|
755
768
|
3. You can then use the Parent class `ADSInstance()` or the smaller class `AMPInstance()` or any of the API classes as a stand alone.
|
|
756
|
-
|
|
769
|
+
- See [Quick Example](https://github.com/k8thekat/AMPAPI_Python/blob/main/docs/samples/sample.py) for a visual example.
|
|
757
770
|
|
|
758
771
|
### Quick Example -
|
|
759
772
|
|
|
760
773
|
```py
|
|
774
|
+
from ampapi import *
|
|
775
|
+
from ampapi.dataclass import AnalyticsFilter, AnalyticsSummary, APIParams, Players
|
|
776
|
+
from ampapi.enums import *
|
|
777
|
+
from ampapi.instance import AMPControllerInstance, AMPInstance, AMPMinecraftInstance
|
|
778
|
+
|
|
761
779
|
# You can pull these values from an `.ini` or a `.env` file,
|
|
762
780
|
# then populate the NamedTuple APIparams from `types -> APIParams`
|
|
763
781
|
_params = APIParams(url="http://192.168.13.130:8080",
|
|
764
782
|
user="amp_username",
|
|
765
783
|
password="amp_password")
|
|
766
784
|
|
|
767
|
-
_bridge = Bridge(api_params=_params)
|
|
768
785
|
|
|
769
|
-
|
|
786
|
+
|
|
787
|
+
async def Sample_API() -> None:
|
|
770
788
|
"""
|
|
771
|
-
Example
|
|
789
|
+
Example API Function to call Endpoints.
|
|
772
790
|
"""
|
|
773
|
-
|
|
774
|
-
ADS:
|
|
775
|
-
#
|
|
776
|
-
|
|
791
|
+
_bridge = Bridge(api_params=_params)
|
|
792
|
+
ADS: AMPControllerInstance = AMPControllerInstance()
|
|
793
|
+
# By default all API calls will be formatted into Dataclasses if possible.
|
|
794
|
+
# You can toggle format_data off with ANY of the API classes that inherit Base().
|
|
795
|
+
ADS.format_data = False
|
|
796
|
+
|
|
797
|
+
# This would populate the ADS class property .instances and .available_instances
|
|
798
|
+
await ADS.get_instances(format_data=True)
|
|
799
|
+
# We convert the ADS.instances attribute to a list for easier iteration.
|
|
800
|
+
# The data is a set to prevent duplicates.
|
|
801
|
+
ADSinstances = list(ADS.instances)
|
|
802
|
+
arkinstance: Union[AMPInstance, None] = None
|
|
803
|
+
mcinstance: Union[AMPInstance, AMPMinecraftInstance, None] = None
|
|
777
804
|
# We can break out all our instances into their own attributes.
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
805
|
+
for instance in ADSinstances:
|
|
806
|
+
# Pre populated from the dataclass and has the API endpoints too!
|
|
807
|
+
if isinstance(instance, (AMPADSInstance, AMPInstance, AMPMinecraftInstance)):
|
|
808
|
+
if instance.friendly_name == "ArkInstance":
|
|
809
|
+
arkinstance = instance
|
|
810
|
+
elif instance.friendly_name == "Minecraft_PVP":
|
|
811
|
+
mcinstance = instance
|
|
812
|
+
|
|
813
|
+
if arkinstance is None or mcinstance is None or not isinstance(mcinstance, AMPMinecraftInstance):
|
|
814
|
+
return
|
|
815
|
+
# This turns back on data formatting Globally.
|
|
816
|
+
arkinstance.format_data = True
|
|
781
817
|
|
|
782
|
-
# Pre populated from the dataclass and has the API methods too!
|
|
783
818
|
# You can take a backup really easily.
|
|
784
|
-
await arkinstance.take_backup(
|
|
819
|
+
await arkinstance.take_backup(name="ARK1_backup", description="This is an ARK backup", sticky=True)
|
|
785
820
|
|
|
786
|
-
# Then you can call instance type specific API
|
|
821
|
+
# Then you can call instance type specific API endpoints.
|
|
787
822
|
await mcinstance.mc_add_to_whitelist(user_or_uuid="k8_thekat")
|
|
788
823
|
|
|
789
|
-
# You can also check attributes and other fields of the instance.
|
|
790
|
-
mcinstance.
|
|
791
|
-
|
|
824
|
+
# You can also check attributes and other fields of the instance for easy logic.
|
|
825
|
+
if mcinstance.instance_name == "Test_Server":
|
|
826
|
+
# do code here
|
|
827
|
+
...
|
|
792
828
|
|
|
793
|
-
# The State of the Instance.
|
|
794
|
-
#
|
|
795
|
-
|
|
829
|
+
# The State of the Instance.
|
|
830
|
+
# Can be checked via `AMPInstance.Running`.
|
|
831
|
+
# To keep this updated simply check.
|
|
832
|
+
if mcinstance.running is True:
|
|
833
|
+
print(f"{mcinstance.friendly_name} is Running Nyao~")
|
|
834
|
+
|
|
835
|
+
elif mcinstance.running is False:
|
|
836
|
+
print(f"{mcinstance.friendly_name} is not currently Running.")
|
|
796
837
|
await mcinstance.start_instance()
|
|
797
838
|
|
|
839
|
+
# You can also restart and stop the Instance too.
|
|
840
|
+
await mcinstance.restart_instance()
|
|
841
|
+
await mcinstance.stop_instance()
|
|
842
|
+
|
|
843
|
+
# The State of the Application. eg. Running, Offline, Restarting, etc. See `types.py -> State_enum
|
|
844
|
+
# This is NOT updated constantly. See about using `get_status()` to keep it current.
|
|
845
|
+
if mcinstance.app_state == AMPInstanceState.stopped:
|
|
846
|
+
await mcinstance.start_application()
|
|
847
|
+
|
|
848
|
+
# You can also stop and update the application via
|
|
849
|
+
await mcinstance.stop_application()
|
|
850
|
+
await mcinstance.update_application()
|
|
851
|
+
|
|
852
|
+
# To get more current Instance State check out.
|
|
853
|
+
mcinstance.status.state
|
|
854
|
+
mcinstance.app_state
|
|
855
|
+
# To keep the `AMPInstance.State` property current; simply call the function below.
|
|
856
|
+
await mcinstance.get_status()
|
|
798
857
|
# You can also check Metrics of an Instance easily.
|
|
799
|
-
mcinstance.
|
|
858
|
+
mcinstance.status.metrics
|
|
800
859
|
|
|
801
860
|
# Want to kick a random person? Here ya go~
|
|
802
|
-
players:
|
|
803
|
-
await mcinstance.mc_kick_user_by_id(
|
|
861
|
+
players: Players = await mcinstance.get_user_list()
|
|
862
|
+
await mcinstance.mc_kick_user_by_id(user_id=players.sorted[0].uuid)
|
|
863
|
+
|
|
804
864
|
|
|
805
865
|
|
|
806
866
|
async def Sample_Analytics_API():
|
|
807
867
|
"""
|
|
808
868
|
Example Method to use Instance Analytics.
|
|
809
869
|
"""
|
|
810
|
-
ADS:
|
|
870
|
+
ADS: AMPControllerInstance = AMPControllerInstance()
|
|
811
871
|
await ADS.get_instances()
|
|
812
872
|
# The index value to get to an MC Instance will be different for you; this is just an example.
|
|
813
873
|
# You can check an Instances Type via the `.Module` attribute of any ADS/Instance class.
|
|
@@ -827,17 +887,19 @@ async def Sample_Analytics_API():
|
|
|
827
887
|
# These results will be filtered to only users with that match the parameter Username. (eg. k8_thekat).
|
|
828
888
|
filtered_analytics2: Analytics_Summary = await mcinstance.get_analytics_summary(filters=user_filter)
|
|
829
889
|
|
|
830
|
-
|
|
831
|
-
```
|
|
832
890
|
|
|
891
|
+
```
|
|
833
892
|
|
|
834
893
|
### Controlling data formatting -
|
|
894
|
+
|
|
835
895
|
- All JSON data returned from the API endpoints is formatted into a Dataclass/Enum/etc if possible.
|
|
836
896
|
- Data formatting can be controlled globally or locally by changing the `format_data` parameter of the method to `False`.
|
|
837
|
-
|
|
897
|
+
- When turning off the data formatting, typically you will get a `dictionary` back.
|
|
838
898
|
|
|
839
899
|
### Example -
|
|
900
|
+
|
|
840
901
|
```py
|
|
902
|
+
# You must have your Bridge object made and the Instance class created to access `format_data`.
|
|
841
903
|
# By default all API calls will be formatted into Dataclasses if possible.
|
|
842
904
|
# You can toggle format_data off with ANY of the API classes that inherit Base().
|
|
843
905
|
ADS.format_data = False
|
|
@@ -851,13 +913,12 @@ await arkinstance.get_role_data(format_data=True)
|
|
|
851
913
|
|
|
852
914
|
```
|
|
853
915
|
|
|
916
|
+
# Contributing to the Project
|
|
854
917
|
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
# Git Commit message format
|
|
918
|
+
#### Git Commit message format
|
|
858
919
|
|
|
859
920
|
```
|
|
860
|
-
# file_name.py
|
|
921
|
+
# file_name.py
|
|
861
922
|
- Change 1
|
|
862
923
|
- Change 2
|
|
863
924
|
-- Change 2 sub-change 1
|
|
@@ -866,7 +927,8 @@ await arkinstance.get_role_data(format_data=True)
|
|
|
866
927
|
- Everything below it will be ignored too as long as it has a `-`
|
|
867
928
|
```
|
|
868
929
|
|
|
869
|
-
|
|
930
|
+
#### AMP Version Bump
|
|
931
|
+
|
|
870
932
|
If the AMP version has changed, please generate new API spec sheets and upload them with any function changes.
|
|
871
|
-
- Run `await APIUtil.amp_api_update(instance=instance_here)`
|
|
872
933
|
|
|
934
|
+
- Run `await APIUtil.amp_api_update(instance=instance_here)`
|
|
@@ -1,34 +1,43 @@
|
|
|
1
1
|
# AMP API Python
|
|
2
|
-
___
|
|
3
|
-
CubeCoders AMP API wrapper in Python.
|
|
4
2
|
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
CubeCoders AMP API wrapper in Python.
|
|
5
6
|
|
|
6
7
|
<div align="left">
|
|
7
8
|
<a href="https://discord.gg/BtNyU8DFtt"><img src='https://img.shields.io/discord/705500489248145459?color=blue&label=Discord&logo=Discord%20Server&logoColor=green' alt='Discord Server'></a>
|
|
8
9
|
</div>
|
|
9
10
|
|
|
10
11
|
<!--  -->
|
|
11
|
-

|
|
12
12
|
|
|
13
|
+

|
|
13
14
|
|
|
14
15
|
### Key Features
|
|
15
|
-
|
|
16
|
+
|
|
17
|
+
---
|
|
16
18
|
|
|
17
19
|
- Pythonic API wrapper using `async` and `await`.
|
|
18
20
|
- Data is in dataclasses for easier management and interaction.
|
|
19
|
-
|
|
21
|
+
- Optional parameter per function or global to disable formatting of data.
|
|
20
22
|
- Parent classes `ADSInstance` and `AMPInstance` to group endpoints together and make handling of multiple Instances easier.
|
|
21
|
-
|
|
23
|
+
- This will also limit Instance specific API endpoints (eg. Minecraft) to that Instance type only.
|
|
24
|
+
|
|
25
|
+
### Docs
|
|
26
|
+
|
|
27
|
+
- https://ampapi-python.readthedocs.io/en/latest/
|
|
22
28
|
|
|
23
29
|
### Installing
|
|
24
|
-
___
|
|
25
30
|
|
|
26
|
-
|
|
31
|
+
---
|
|
32
|
+
|
|
33
|
+
_Python 3.10 or higher is required_
|
|
27
34
|
|
|
28
35
|
To install run the below command to install the required pip packages from [Requirements](./requirements.txt)
|
|
29
36
|
|
|
30
|
-
### PyPi
|
|
31
|
-
|
|
37
|
+
### PyPi
|
|
38
|
+
|
|
39
|
+
---
|
|
40
|
+
|
|
32
41
|
-> Visit the package on [Pypi](https://pypi.org/project/cc-ampapi/)
|
|
33
42
|
|
|
34
43
|
```bash
|
|
@@ -38,66 +47,117 @@ pip install cc-ampapi
|
|
|
38
47
|
```
|
|
39
48
|
|
|
40
49
|
### Basic Usage
|
|
41
|
-
|
|
50
|
+
|
|
51
|
+
---
|
|
52
|
+
|
|
53
|
+
In your IDE Python file. -> `import ampapi`.
|
|
54
|
+
|
|
42
55
|
1. First you need to fill out the APIParams class with the required fields (url, user and password).
|
|
43
56
|
2. Pass the APIParams class into the Bridge class parameter api_params.
|
|
44
|
-
|
|
57
|
+
- You only need to make ONE bridge class; the rest of the API classes will get the same object and handle logging in for you.
|
|
45
58
|
3. You can then use the Parent class `ADSInstance()` or the smaller class `AMPInstance()` or any of the API classes as a stand alone.
|
|
46
|
-
|
|
59
|
+
- See [Quick Example](https://github.com/k8thekat/AMPAPI_Python/blob/main/docs/samples/sample.py) for a visual example.
|
|
47
60
|
|
|
48
61
|
### Quick Example -
|
|
49
62
|
|
|
50
63
|
```py
|
|
64
|
+
from ampapi import *
|
|
65
|
+
from ampapi.dataclass import AnalyticsFilter, AnalyticsSummary, APIParams, Players
|
|
66
|
+
from ampapi.enums import *
|
|
67
|
+
from ampapi.instance import AMPControllerInstance, AMPInstance, AMPMinecraftInstance
|
|
68
|
+
|
|
51
69
|
# You can pull these values from an `.ini` or a `.env` file,
|
|
52
70
|
# then populate the NamedTuple APIparams from `types -> APIParams`
|
|
53
71
|
_params = APIParams(url="http://192.168.13.130:8080",
|
|
54
72
|
user="amp_username",
|
|
55
73
|
password="amp_password")
|
|
56
74
|
|
|
57
|
-
_bridge = Bridge(api_params=_params)
|
|
58
75
|
|
|
59
|
-
|
|
76
|
+
|
|
77
|
+
async def Sample_API() -> None:
|
|
60
78
|
"""
|
|
61
|
-
Example
|
|
79
|
+
Example API Function to call Endpoints.
|
|
62
80
|
"""
|
|
63
|
-
|
|
64
|
-
ADS:
|
|
65
|
-
#
|
|
66
|
-
|
|
81
|
+
_bridge = Bridge(api_params=_params)
|
|
82
|
+
ADS: AMPControllerInstance = AMPControllerInstance()
|
|
83
|
+
# By default all API calls will be formatted into Dataclasses if possible.
|
|
84
|
+
# You can toggle format_data off with ANY of the API classes that inherit Base().
|
|
85
|
+
ADS.format_data = False
|
|
86
|
+
|
|
87
|
+
# This would populate the ADS class property .instances and .available_instances
|
|
88
|
+
await ADS.get_instances(format_data=True)
|
|
89
|
+
# We convert the ADS.instances attribute to a list for easier iteration.
|
|
90
|
+
# The data is a set to prevent duplicates.
|
|
91
|
+
ADSinstances = list(ADS.instances)
|
|
92
|
+
arkinstance: Union[AMPInstance, None] = None
|
|
93
|
+
mcinstance: Union[AMPInstance, AMPMinecraftInstance, None] = None
|
|
67
94
|
# We can break out all our instances into their own attributes.
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
95
|
+
for instance in ADSinstances:
|
|
96
|
+
# Pre populated from the dataclass and has the API endpoints too!
|
|
97
|
+
if isinstance(instance, (AMPADSInstance, AMPInstance, AMPMinecraftInstance)):
|
|
98
|
+
if instance.friendly_name == "ArkInstance":
|
|
99
|
+
arkinstance = instance
|
|
100
|
+
elif instance.friendly_name == "Minecraft_PVP":
|
|
101
|
+
mcinstance = instance
|
|
102
|
+
|
|
103
|
+
if arkinstance is None or mcinstance is None or not isinstance(mcinstance, AMPMinecraftInstance):
|
|
104
|
+
return
|
|
105
|
+
# This turns back on data formatting Globally.
|
|
106
|
+
arkinstance.format_data = True
|
|
71
107
|
|
|
72
|
-
# Pre populated from the dataclass and has the API methods too!
|
|
73
108
|
# You can take a backup really easily.
|
|
74
|
-
await arkinstance.take_backup(
|
|
109
|
+
await arkinstance.take_backup(name="ARK1_backup", description="This is an ARK backup", sticky=True)
|
|
75
110
|
|
|
76
|
-
# Then you can call instance type specific API
|
|
111
|
+
# Then you can call instance type specific API endpoints.
|
|
77
112
|
await mcinstance.mc_add_to_whitelist(user_or_uuid="k8_thekat")
|
|
78
113
|
|
|
79
|
-
# You can also check attributes and other fields of the instance.
|
|
80
|
-
mcinstance.
|
|
81
|
-
|
|
114
|
+
# You can also check attributes and other fields of the instance for easy logic.
|
|
115
|
+
if mcinstance.instance_name == "Test_Server":
|
|
116
|
+
# do code here
|
|
117
|
+
...
|
|
82
118
|
|
|
83
|
-
# The State of the Instance.
|
|
84
|
-
#
|
|
85
|
-
|
|
119
|
+
# The State of the Instance.
|
|
120
|
+
# Can be checked via `AMPInstance.Running`.
|
|
121
|
+
# To keep this updated simply check.
|
|
122
|
+
if mcinstance.running is True:
|
|
123
|
+
print(f"{mcinstance.friendly_name} is Running Nyao~")
|
|
124
|
+
|
|
125
|
+
elif mcinstance.running is False:
|
|
126
|
+
print(f"{mcinstance.friendly_name} is not currently Running.")
|
|
86
127
|
await mcinstance.start_instance()
|
|
87
128
|
|
|
129
|
+
# You can also restart and stop the Instance too.
|
|
130
|
+
await mcinstance.restart_instance()
|
|
131
|
+
await mcinstance.stop_instance()
|
|
132
|
+
|
|
133
|
+
# The State of the Application. eg. Running, Offline, Restarting, etc. See `types.py -> State_enum
|
|
134
|
+
# This is NOT updated constantly. See about using `get_status()` to keep it current.
|
|
135
|
+
if mcinstance.app_state == AMPInstanceState.stopped:
|
|
136
|
+
await mcinstance.start_application()
|
|
137
|
+
|
|
138
|
+
# You can also stop and update the application via
|
|
139
|
+
await mcinstance.stop_application()
|
|
140
|
+
await mcinstance.update_application()
|
|
141
|
+
|
|
142
|
+
# To get more current Instance State check out.
|
|
143
|
+
mcinstance.status.state
|
|
144
|
+
mcinstance.app_state
|
|
145
|
+
# To keep the `AMPInstance.State` property current; simply call the function below.
|
|
146
|
+
await mcinstance.get_status()
|
|
88
147
|
# You can also check Metrics of an Instance easily.
|
|
89
|
-
mcinstance.
|
|
148
|
+
mcinstance.status.metrics
|
|
90
149
|
|
|
91
150
|
# Want to kick a random person? Here ya go~
|
|
92
|
-
players:
|
|
93
|
-
await mcinstance.mc_kick_user_by_id(
|
|
151
|
+
players: Players = await mcinstance.get_user_list()
|
|
152
|
+
await mcinstance.mc_kick_user_by_id(user_id=players.sorted[0].uuid)
|
|
153
|
+
|
|
94
154
|
|
|
95
155
|
|
|
96
156
|
async def Sample_Analytics_API():
|
|
97
157
|
"""
|
|
98
158
|
Example Method to use Instance Analytics.
|
|
99
159
|
"""
|
|
100
|
-
ADS:
|
|
160
|
+
ADS: AMPControllerInstance = AMPControllerInstance()
|
|
101
161
|
await ADS.get_instances()
|
|
102
162
|
# The index value to get to an MC Instance will be different for you; this is just an example.
|
|
103
163
|
# You can check an Instances Type via the `.Module` attribute of any ADS/Instance class.
|
|
@@ -117,17 +177,19 @@ async def Sample_Analytics_API():
|
|
|
117
177
|
# These results will be filtered to only users with that match the parameter Username. (eg. k8_thekat).
|
|
118
178
|
filtered_analytics2: Analytics_Summary = await mcinstance.get_analytics_summary(filters=user_filter)
|
|
119
179
|
|
|
120
|
-
|
|
121
|
-
```
|
|
122
180
|
|
|
181
|
+
```
|
|
123
182
|
|
|
124
183
|
### Controlling data formatting -
|
|
184
|
+
|
|
125
185
|
- All JSON data returned from the API endpoints is formatted into a Dataclass/Enum/etc if possible.
|
|
126
186
|
- Data formatting can be controlled globally or locally by changing the `format_data` parameter of the method to `False`.
|
|
127
|
-
|
|
187
|
+
- When turning off the data formatting, typically you will get a `dictionary` back.
|
|
128
188
|
|
|
129
189
|
### Example -
|
|
190
|
+
|
|
130
191
|
```py
|
|
192
|
+
# You must have your Bridge object made and the Instance class created to access `format_data`.
|
|
131
193
|
# By default all API calls will be formatted into Dataclasses if possible.
|
|
132
194
|
# You can toggle format_data off with ANY of the API classes that inherit Base().
|
|
133
195
|
ADS.format_data = False
|
|
@@ -141,13 +203,12 @@ await arkinstance.get_role_data(format_data=True)
|
|
|
141
203
|
|
|
142
204
|
```
|
|
143
205
|
|
|
206
|
+
# Contributing to the Project
|
|
144
207
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
# Git Commit message format
|
|
208
|
+
#### Git Commit message format
|
|
148
209
|
|
|
149
210
|
```
|
|
150
|
-
# file_name.py
|
|
211
|
+
# file_name.py
|
|
151
212
|
- Change 1
|
|
152
213
|
- Change 2
|
|
153
214
|
-- Change 2 sub-change 1
|
|
@@ -156,7 +217,8 @@ await arkinstance.get_role_data(format_data=True)
|
|
|
156
217
|
- Everything below it will be ignored too as long as it has a `-`
|
|
157
218
|
```
|
|
158
219
|
|
|
159
|
-
|
|
220
|
+
#### AMP Version Bump
|
|
221
|
+
|
|
160
222
|
If the AMP version has changed, please generate new API spec sheets and upload them with any function changes.
|
|
161
|
-
- Run `await APIUtil.amp_api_update(instance=instance_here)`
|
|
162
223
|
|
|
224
|
+
- Run `await APIUtil.amp_api_update(instance=instance_here)`
|
|
@@ -4,18 +4,18 @@ Copyright (C) 2021-2022 Katelynn Cadwallader.
|
|
|
4
4
|
|
|
5
5
|
This file is part of Gatekeeper, the AMP API.
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
AMP API is free software; you can redistribute it and/or modify
|
|
8
8
|
it under the terms of the GNU General Public License as published by
|
|
9
9
|
the Free Software Foundation; either version 3, or (at your option)
|
|
10
10
|
any later version.
|
|
11
11
|
|
|
12
|
-
|
|
12
|
+
AMP API is distributed in the hope that it will be useful, but WITHOUT
|
|
13
13
|
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
14
14
|
or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
|
|
15
15
|
License for more details.
|
|
16
16
|
|
|
17
17
|
You should have received a copy of the GNU General Public License
|
|
18
|
-
along with
|
|
18
|
+
along with AMP API; see the file COPYING. If not, write to the Free
|
|
19
19
|
Software Foundation, 51 Franklin Street - Fifth Floor, Boston, MA
|
|
20
20
|
02110-1301, USA.
|
|
21
21
|
"""
|
|
@@ -25,16 +25,13 @@ from __future__ import annotations
|
|
|
25
25
|
__title__ = "CubeCoders AMP API"
|
|
26
26
|
__author__ = "k8thekat"
|
|
27
27
|
__license__ = "GNU"
|
|
28
|
-
__version__ = "
|
|
28
|
+
__version__ = "4.6.0"
|
|
29
29
|
__credits__ = "AMP by CubeCoders and associates."
|
|
30
30
|
|
|
31
31
|
from typing import Literal, NamedTuple
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
from . import
|
|
35
|
-
from . import modules as modules
|
|
36
|
-
from . import types_ as types
|
|
37
|
-
from . import util as util
|
|
33
|
+
|
|
34
|
+
from .util import *
|
|
38
35
|
from .adsmodule import *
|
|
39
36
|
from .analytics import *
|
|
40
37
|
from .base import *
|
|
@@ -46,6 +43,9 @@ from .filebackup import *
|
|
|
46
43
|
from .filemanager import *
|
|
47
44
|
from .instance import *
|
|
48
45
|
from .minecraft import *
|
|
46
|
+
from .modules import *
|
|
47
|
+
from .enums_ import *
|
|
48
|
+
from .backoff import *
|
|
49
49
|
|
|
50
50
|
|
|
51
51
|
class VersionInfo(NamedTuple):
|
|
@@ -55,6 +55,6 @@ class VersionInfo(NamedTuple):
|
|
|
55
55
|
releaseLevel: Literal["alpha", "beta", "pre-release", "release", "development"]
|
|
56
56
|
|
|
57
57
|
|
|
58
|
-
version_info: VersionInfo = VersionInfo(Major=
|
|
58
|
+
version_info: VersionInfo = VersionInfo(Major=4, Minor=6, Revision=0, releaseLevel="development")
|
|
59
59
|
|
|
60
60
|
del NamedTuple, Literal, VersionInfo
|