Skip to content

Commit 995e9d9

Browse files
Merge pull request #61 from aruba/v2.0a10
v2.0a10 Release PR
2 parents dd2caf1 + 9696f8e commit 995e9d9

37 files changed

Lines changed: 2861 additions & 3363 deletions

pycentral/base.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,9 @@
1414
save_access_token,
1515
)
1616
from .scopes import Scopes
17-
from .utils.url_utils import NewCentralURLs
17+
from .utils import AUTHENTICATION
1818
from .exceptions import LoginError, ResponseError
1919

20-
urls = NewCentralURLs()
2120
SUPPORTED_API_METHODS = ("POST", "PATCH", "DELETE", "GET", "PUT")
2221

2322

@@ -100,7 +99,7 @@ def create_token(self, app_name):
10099
try:
101100
self.logger.info(f"Attempting to create new token from {app_name}")
102101
token = oauth.fetch_token(
103-
token_url=urls.Authentication["OAUTH"], auth=auth
102+
token_url=AUTHENTICATION["OAUTH"], auth=auth
104103
)
105104

106105
if "access_token" in token:

pycentral/exceptions/generic_op_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
22
# MIT License
33

4-
from .pycentral_error import PycentralError
4+
from pycentral.exceptions.pycentral_error import PycentralError
55

66

77
class GenericOperationError(PycentralError):

pycentral/exceptions/login_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
22
# MIT License
33

4-
from .pycentral_error import PycentralError
4+
from pycentral.exceptions.pycentral_error import PycentralError
55

66

77
class LoginError(PycentralError):

pycentral/exceptions/parameter_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
22
# MIT License
33

4-
from .verification_error import VerificationError
4+
from pycentral.exceptions.verification_error import VerificationError
55

66

77
class ParameterError(VerificationError):

pycentral/exceptions/response_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
22
# MIT License
33

4-
from .pycentral_error import PycentralError
4+
from pycentral.exceptions.pycentral_error import PycentralError
55

66

77
class ResponseError(PycentralError):

pycentral/exceptions/unsupported_capability_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
22
# MIT License
33

4-
from .pycentral_error import PycentralError
4+
from pycentral.exceptions.pycentral_error import PycentralError
55

66

77
class UnsupportedCapabilityError(PycentralError):

pycentral/exceptions/verification_error.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
22
# MIT License
33

4-
from .pycentral_error import PycentralError
4+
from pycentral.exceptions.pycentral_error import PycentralError
55

66

77
class VerificationError(PycentralError):

pycentral/glp/devices.py

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
22
# MIT License
33

4-
from ..utils.url_utils import NewCentralURLs, urlJoin
4+
from ..utils import GLP_URLS, generate_url
55
from .subscriptions import Subscriptions
66
from ..utils.glp_utils import check_progress, rate_limit_check
77
import time
88

9-
urls = NewCentralURLs()
10-
119
DEVICE_GET_LIMIT = 2000
1210
# Input size per request for DEVICE module APIs.
1311
INPUT_SIZE = 5
@@ -87,7 +85,7 @@ def get_device(
8785
"""
8886

8987
conn.logger.info("Getting a device in GLP workspace")
90-
path = urls.GLP_DEVICES["DEFAULT"]
88+
path = generate_url(GLP_URLS["DEVICE"], category="devices")
9189

9290
params = {"limit": limit, "offset": offset}
9391
if filter:
@@ -142,7 +140,7 @@ def get_status(self, conn, id):
142140
:rtype: dict
143141
"""
144142

145-
path = urlJoin(urls.GLP_DEVICES["GET_ASYNC"], id)
143+
path = generate_url(f"{GLP_URLS['ASYNC']}/{id}", category="devices")
146144
resp = conn.command("GET", path, "glp")
147145
return resp
148146

@@ -181,7 +179,7 @@ def add_devices(self, conn, network=[], compute=[], storage=[]):
181179
resp_list.append(self.__add_dev("storage", storage))
182180
return resp_list
183181
else:
184-
path = urls.GLP_DEVICES["DEFAULT"]
182+
path = generate_url(GLP_URLS["DEVICE"], category="devices")
185183
data = {"network": network, "compute": compute, "storage": storage}
186184
resp = conn.command("POST", path, "glp", api_data=data)
187185
resp_list.append(resp)
@@ -209,7 +207,7 @@ def __add_dev(self, conn, type, inputs):
209207
:rtype: list
210208
"""
211209

212-
path = urls.GLP_DEVICES["DEFAULT"]
210+
path = generate_url(GLP_URLS["DEVICE"], category="devices")
213211
data = {"network": [], "compute": [], "storage": []}
214212

215213
if len(inputs) > INPUT_SIZE:
@@ -300,7 +298,7 @@ def add_sub(self, conn, devices, sub, serial=False, key=False):
300298
# Setup variables for iterating commands.
301299
queue = [devices] if not split_input else split_input
302300
resp_list = []
303-
path = urls.GLP_DEVICES["DEFAULT"]
301+
path = generate_url(GLP_URLS["DEVICE"], category="devices")
304302
body = {"subscription": [{"id": sub}]}
305303

306304
for inputs in queue:
@@ -372,7 +370,7 @@ def remove_sub(self, conn, devices, serial=False):
372370
# Setup variables for iterating commands.
373371
queue = [devices] if not split_input else split_input
374372
resp_list = []
375-
path = urls.GLP_DEVICES["DEFAULT"]
373+
path = generate_url(GLP_URLS["DEVICE"], category="devices")
376374
body = {"subscription": []}
377375

378376
for inputs in queue:
@@ -421,7 +419,7 @@ def assign_devices(
421419
:rtype: dict
422420
"""
423421
conn.logger.info("Assigning device(s) to an application")
424-
path = urls.GLP_DEVICES["DEFAULT"]
422+
path = generate_url(GLP_URLS["DEVICE"], category="devices")
425423

426424
if serial:
427425
d_list = []
@@ -498,7 +496,7 @@ def unassign_devices(self, conn, devices=None, serial=False):
498496
:rtype: dict
499497
"""
500498
conn.logger.info("Unassigning device(s) from an application")
501-
path = urls.GLP_DEVICES["DEFAULT"]
499+
path = generate_url(GLP_URLS["DEVICE"], category="devices")
502500

503501
if serial:
504502
d_list = []

pycentral/glp/service_manager.py

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
22
# MIT License
33

4-
from ..utils.url_utils import NewCentralURLs
5-
6-
urls = NewCentralURLs()
4+
from ..utils import GLP_URLS, generate_url
75

86

97
class ServiceManager(object):
@@ -93,7 +91,9 @@ def get_service_manager_provisions(self, conn, limit=2000, offset=0):
9391
:rtype: dict
9492
"""
9593
conn.logger.info("Getting provisioned services in GLP workspace")
96-
path = urls.GLP_SERVICES["SERVICE_MANAGER_PROVISIONS"]
94+
path = generate_url(
95+
GLP_URLS["SERVICE_MANAGER_PROVISIONS"], category="service_catalog"
96+
)
9797

9898
params = {
9999
"limit": limit,
@@ -116,7 +116,9 @@ def get_service_manager_by_region(self, conn):
116116
:rtype: dict
117117
"""
118118
conn.logger.info("Getting services managers by region in GLP")
119-
path = urls.GLP_SERVICES["SERVICE_MANAGER_BY_REGION"]
119+
path = generate_url(
120+
GLP_URLS["SERVICE_MANAGER_BY_REGION"], category="service_catalog"
121+
)
120122

121123
resp = conn.command(api_method="GET", api_path=path, app_name="glp")
122124
return resp
@@ -161,7 +163,9 @@ def get_service_managers(self, conn, limit=2000, offset=0):
161163
:rtype: dict
162164
"""
163165
conn.logger.info("Getting service managers in GLP")
164-
path = urls.GLP_SERVICES["SERVICE_MANAGER"]
166+
path = generate_url(
167+
GLP_URLS["SERVICE_MANAGER"], category="service_catalog"
168+
)
165169

166170
params = {
167171
"limit": limit,

pycentral/glp/subscriptions.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
# (C) Copyright 2025 Hewlett Packard Enterprise Development LP.
22
# MIT License
33

4-
from ..utils.url_utils import NewCentralURLs, urlJoin
4+
from ..utils import GLP_URLS, generate_url
55
from ..utils.glp_utils import rate_limit_check, check_progress
66
import time
77

8-
urls = NewCentralURLs()
9-
108
# This is the single input size limit for using the POST request endpoint for adding subscriptions.
119
INPUT_SIZE = 5
1210
# This is the rate limit per minute of requests that can be processed by the POST request endpoint for adding subscriptions.
@@ -84,7 +82,7 @@ def get_subscription(
8482
:return: API response
8583
:rtype: dict
8684
"""
87-
path = urls.GLP_SUBSCRIPTION["DEFAULT"]
85+
path = generate_url(GLP_URLS["SUBSCRIPTION"], category="subscriptions")
8886

8987
params = {"limit": limit, "offset": offset}
9088
if filter:
@@ -134,7 +132,9 @@ def get_status(self, conn, id):
134132
:rtype: dict
135133
"""
136134

137-
path = urlJoin(urls.GLP_SUBSCRIPTION["GET_ASYNC"], id)
135+
path = generate_url(
136+
f"{GLP_URLS["ASYNC"]}/{id}", category="subscriptions"
137+
)
138138
resp = conn.command("GET", path, "glp")
139139
return resp
140140

@@ -154,7 +154,7 @@ def add_subscription(self, conn, subscriptions=None, limit=0, offset=0):
154154
:return: API response
155155
:rtype: dict
156156
"""
157-
path = urls.GLP_SUBSCRIPTION["DEFAULT"]
157+
path = generate_url(GLP_URLS["SUBSCRIPTION"], category="subscriptions")
158158

159159
if len(subscriptions) > INPUT_SIZE:
160160
resp = []

0 commit comments

Comments
 (0)