Skip to content

Commit

Permalink
Add rules controller (#15)
Browse files Browse the repository at this point in the history
* added support for getting rules.

* bump version
  • Loading branch information
xinghengwang authored Jul 5, 2023
1 parent 1399ab7 commit 9e88422
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
43 changes: 42 additions & 1 deletion lib/moesif_api/controllers/api_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def self.instance
@@instance
end

# API Call to send data to Moesif
# API Call to send data to Moesif
# @param [EventModel] body Required [Hash] headers Required [String] url Required
# @return response and context from the API call
def send_moesif(url, headers, body)
Expand Down Expand Up @@ -202,6 +202,47 @@ def get_app_config()
return _response
end

# Get App Governance Rules
# @param void Required parameter.
# @return response from the API call
def get_rules()
# the base uri for api requests
_query_builder = Configuration.base_uri.dup

# prepare query string for API call
_query_builder << '/v1/rules'

# validate and preprocess url
_query_url = APIHelper.clean_url _query_builder

# prepare headers
_headers = {
'content-type' => 'application/json; charset=utf-8',
'X-Moesif-Application-Id' => Configuration.application_id
}

# Create the HttpRequest object for the call
_request = @http_client.get _query_url, headers: _headers

# Call the on_before_request callback
@http_call_back.on_before_request(_request) if @http_call_back

# Invoke the API call and get the response
_response = @http_client.execute_as_string(_request)

# Wrap the request and response in an HttpContext object
_context = HttpContext.new(_request, _response)

# Call the on_after_response callback
@http_call_back.on_after_response(_context) if @http_call_back

# Global error handling using HTTP status codes.
validate_response(_context)

# Return the response
return _response
end

# Update Data for a Single Company
# @param [CompanyModel] body Required parameter.
# @return void response from the API call
Expand Down
2 changes: 1 addition & 1 deletion moesif_api.gemspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Gem::Specification.new do |s|
s.name = 'moesif_api'
s.version = '1.2.14'
s.version = '1.2.15'
s.summary = 'moesif_api'
s.description = 'Collection/Data Ingestion API'
s.authors = ['Moesif, Inc', 'Derric Gilling']
Expand Down

0 comments on commit 9e88422

Please sign in to comment.