Skip to content

Commit 2900435

Browse files
authored
Merge pull request #12 from Moesif/Support-Governance
Get governance rules
2 parents c1e8b0f + f0e2fc6 commit 2900435

File tree

3 files changed

+48
-1
lines changed

3 files changed

+48
-1
lines changed

moesifapi/controllers/api_controller.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -296,6 +296,44 @@ def get_app_config(self):
296296
# Invoke the API call to fetch the response.
297297
_response = self.http_client.execute_as_string(_request)
298298

299+
# Wrap the request and the response in an HttpContext object
300+
_context = HttpContext(_request, _response)
301+
302+
# Invoke the on after response HttpCallBack if specified
303+
if self.http_call_back is not None:
304+
self.http_call_back.on_after_response(_context)
305+
306+
# Global error handling using HTTP status codes.
307+
self.validate_response(_context)
308+
309+
return _response
310+
311+
def get_governance_rules(self):
312+
# The base uri for api requests
313+
_query_builder = Configuration.BASE_URI
314+
# Prepare query string for API call
315+
_query_builder += '/v1/rules'
316+
317+
# Validate and preprocess url
318+
_query_url = APIHelper.clean_url(_query_builder)
319+
320+
# Prepare headers
321+
_headers = {
322+
'content-type': 'application/json; charset=utf-8',
323+
'X-Moesif-Application-Id': Configuration.application_id
324+
}
325+
326+
# Prepare the API call.
327+
_request = self.http_client.get(_query_url, headers=_headers)
328+
329+
# Invoke the on before request HttpCallBack if specified
330+
if self.http_call_back is not None:
331+
self.http_call_back.on_before_request(_request)
332+
333+
# Invoke the API call to fetch the response.
334+
_response = self.http_client.execute_as_string(_request)
335+
336+
299337
# Wrap the request and the response in an HttpContext object
300338
_context = HttpContext(_request, _response)
301339

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
# Versions should comply with PEP440. For a discussion on single-sourcing
2929
# the version across setup.py and the project code, see
3030
# https://packaging.python.org/en/latest/single_source_version.html
31-
version='1.3.3',
31+
version='1.4.0',
3232

3333
description='Moesif API Lib for Python',
3434
long_description=long_description,

tests/controllers/test_api_controller.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,15 @@ def test_get_app_config(self):
158158
self.assertIsNotNone(response["raw_body"])
159159
self.assertIsNotNone(response["headers"]["X-Moesif-Config-ETag"])
160160

161+
# Get Application configuration
162+
def test_get_rules(self):
163+
# Perform the API call through the SDK function
164+
response = self.controller.get_governance_rules().__dict__
165+
166+
# Test Response code
167+
self.assertEquals(self.response_catcher.response.status_code, 200)
168+
self.assertIsNotNone(response["raw_body"])
169+
161170
# Add Single company via Injestion API
162171
def test_update_company(self):
163172
# Parameter for the API call

0 commit comments

Comments
 (0)