Skip to content

Commit f6279f1

Browse files
Removed unavalable fields from IADSInstance and made Fitness optional
1 parent 3e7d30c commit f6279f1

File tree

5 files changed

+22
-50
lines changed

5 files changed

+22
-50
lines changed

TypeSpec.json

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1482,21 +1482,11 @@
14821482
"Name": "Disabled",
14831483
"TypeName": "Boolean"
14841484
},
1485-
{
1486-
"Description": "The fitness information object",
1487-
"Name": "Fitness",
1488-
"TypeName": "ProvisionFitness"
1489-
},
14901485
{
14911486
"Description": "The friendly name",
14921487
"Name": "FriendlyName",
14931488
"TypeName": "String"
14941489
},
1495-
{
1496-
"Description": "The host",
1497-
"Name": "Host",
1498-
"TypeName": "String"
1499-
},
15001490
{
15011491
"Description": "The ID",
15021492
"Name": "Id",
@@ -1507,16 +1497,6 @@
15071497
"Name": "InstanceId",
15081498
"TypeName": "Guid"
15091499
},
1510-
{
1511-
"Description": "The instances",
1512-
"Name": "Instances",
1513-
"TypeName": "List<InstanceSummary>"
1514-
},
1515-
{
1516-
"Description": "Whether HTTPS is enabled",
1517-
"Name": "IsHTTPS",
1518-
"TypeName": "Boolean"
1519-
},
15201500
{
15211501
"Description": "Whether the instance is remote",
15221502
"Name": "IsRemote",
@@ -1532,11 +1512,6 @@
15321512
"Name": "Platform",
15331513
"TypeName": "IPlatformInfo"
15341514
},
1535-
{
1536-
"Description": "The port",
1537-
"Name": "Port",
1538-
"TypeName": "Int32"
1539-
},
15401515
{
15411516
"Description": "The state",
15421517
"Name": "State",
@@ -1561,6 +1536,12 @@
15611536
"Description": "The URL",
15621537
"Name": "URL",
15631538
"TypeName": "String"
1539+
},
1540+
{
1541+
"Description": "The fitness information object",
1542+
"Name": "Fitness",
1543+
"TypeName": "ProvisionFitness",
1544+
"Optional": true
15641545
}
15651546
]
15661547
},

libraries/python/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ def main():
5858
# API call parameters are simply in the same order as shown in the documentation.
5959
API.Core.SendConsoleMessage("say Hello Everyone, this message was sent from the Python API!")
6060

61-
currentStatus: Status = API.Core.GetStatus()
61+
currentStatus: StatusResponse = API.Core.GetStatus()
6262
cpuUsage: MetricInfo = currentStatus.Metrics.get("CPU Usage")
6363

6464
print(f"Current CPU usage is: {cpuUsage.Percent}%")
@@ -88,15 +88,15 @@ async def main():
8888
# API call parameters are simply in the same order as shown in the documentation.
8989
await API.Core.SendConsoleMessage("say Hello Everyone, this message was sent from the Python API!")
9090

91-
currentStatus: Status = await API.Core.GetStatus()
91+
currentStatus: StatusResponse = await API.Core.GetStatus()
9292
cpuUsage: MetricInfo = currentStatus.Metrics.get("CPU Usage")
9393

9494
print(f"Current CPU usage is: {cpuUsage.Percent}%")
9595

9696
asyncio.run(main())
9797
```
9898

99-
** THE BELOW EXAMPLES ARE OUTDATED **
99+
**THE BELOW EXAMPLES ARE OUTDATED**
100100

101101
### Example using the ADS to manage an instance
102102

libraries/python/ampapi/types.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -903,28 +903,18 @@ class IADSInstance:
903903
:type Description: str
904904
:param Disabled: Whether the instance is disabled
905905
:type Disabled: bool
906-
:param Fitness: The fitness information object
907-
:type Fitness: ProvisionFitness
908906
:param FriendlyName: The friendly name
909907
:type FriendlyName: str
910-
:param Host: The host
911-
:type Host: str
912908
:param Id: The ID
913909
:type Id: int
914910
:param InstanceId: The instance ID
915911
:type InstanceId: str
916-
:param Instances: The instances
917-
:type Instances: list[InstanceSummary]
918-
:param IsHTTPS: Whether HTTPS is enabled
919-
:type IsHTTPS: bool
920912
:param IsRemote: Whether the instance is remote
921913
:type IsRemote: bool
922914
:param LastUpdated: The last updated date
923915
:type LastUpdated: str
924916
:param Platform: The platform information object
925917
:type Platform: IPlatformInfo
926-
:param Port: The port
927-
:type Port: int
928918
:param State: The state
929919
:type State: RemoteInstanceState
930920
:param StateReason: The state reason
@@ -935,6 +925,8 @@ class IADSInstance:
935925
:type TagsList: str
936926
:param URL: The URL
937927
:type URL: str
928+
:param Fitness: The fitness information object
929+
:type Fitness: Optional[ProvisionFitness]
938930
"""
939931
AvailableIPs: 'list[str]'
940932
AvailableInstances: 'list[InstanceSummary]'
@@ -943,22 +935,18 @@ class IADSInstance:
943935
Datastores: 'list[DatastoreSummary]'
944936
Description: 'str'
945937
Disabled: 'bool'
946-
Fitness: 'ProvisionFitness'
947938
FriendlyName: 'str'
948-
Host: 'str'
949939
Id: 'int'
950940
InstanceId: 'str'
951-
Instances: 'list[InstanceSummary]'
952-
IsHTTPS: 'bool'
953941
IsRemote: 'bool'
954942
LastUpdated: 'str'
955943
Platform: 'IPlatformInfo'
956-
Port: 'int'
957944
State: 'RemoteInstanceState'
958945
StateReason: 'str'
959946
Tags: 'list[str]'
960947
TagsList: 'str'
961948
URL: 'str'
949+
Fitness: 'Optional[ProvisionFitness]'
962950

963951
@dataclass
964952
class IAuditLogEntry:

libraries/python/setup.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[metadata]
22
name = ampapi
3-
version = 2604.4.2
3+
version = 2604.4.3
44
author = Dylan Sperrer - p0t4t0sandwich - thepotatoking3452
55
author_email = p0t4t0sandwich@gmail.com
66
description = An API that allows you to communicate with AMP installations from within Python.

test.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
import time
33

44
from libraries.python.ampapi.auth import BasicAuthProvider, BasicAuthProviderAsync, RefreshingAuthProvider
5-
from libraries.python.ampapi.modules import CommonAPI, CommonAPIAsync
5+
from libraries.python.ampapi.modules import CommonAPI, CommonAPIAsync, ADSAsync
66
from libraries.python.ampapi.types import MetricInfo
77

8-
PANEL_URL = "http://localhost:8080/API/ADSModule/Servers/TestServer01/"
8+
PANEL_URL = "http://localhost:8080"
99
USERNAME = "api_user"
1010
PASSWORD = "api_user123!"
1111

@@ -30,12 +30,15 @@ async def async_main():
3030
password=PASSWORD
3131
)
3232

33-
api = CommonAPIAsync(authProvider)
33+
api = ADSAsync(authProvider)
3434

35-
print(await authProvider.instanceName)
36-
print(await authProvider.instanceId)
35+
# print(await authProvider.instanceName)
36+
# print(await authProvider.instanceId)
3737

38-
print((await api.Core.GetStatus()).State)
38+
# print((await api.Core.GetStatus()).State)
39+
40+
instances = await api.ADSModule.GetInstances(ForceIncludeSelf=False)
41+
print(instances)
3942

4043
now = time.time()
4144
main()

0 commit comments

Comments
 (0)