Skip to content

Commit

Permalink
Add support for EU region
Browse files Browse the repository at this point in the history
  • Loading branch information
arvdias committed Jun 7, 2019
1 parent a7faa93 commit 2505eca
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions newrelic-cloud
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,17 @@ import collections
OperationResult = collections.namedtuple(
'OperationResult', ['function', 'region', 'failed', 'error'])

_GRAPHQL_API_URL = 'https://api.newrelic.com/graphql'
_GRAPHQL_EU_API_URL = 'https://api.eu.newrelic.com/graphql'


class NewRelicGraphQLClient:
_GRAPHQL_API_URL = 'https://api.newrelic.com/graphql'

def __init__(self, nr_account_id, api_key, url=None):
def __init__(self, nr_account_id, api_key, endpoint):
self.api_key = api_key
self.nr_account_id = int(nr_account_id)
self.debug = False
self.url = url if url else self._GRAPHQL_API_URL
self.url = endpoint

def _extract_errors(self, errors):
"""
Expand Down Expand Up @@ -477,6 +479,13 @@ def setup_log_ingestion(nr_license_key, regions):
return results


def get_endpoint(nr_license_key):
if nr_license_key.startswith("eu"):
return _GRAPHQL_EU_API_URL
else:
return _GRAPHQL_API_URL


def enable_lambda_monitoring(args):
"""
Execute the full workflow to enable AWS lambda monitoring.
Expand All @@ -494,7 +503,8 @@ def enable_lambda_monitoring(args):
regions = args['regions']

results = []
api_client = NewRelicGraphQLClient(nr_account_id, api_key)
api_endpoint = get_endpoint(nr_license_key)
api_client = NewRelicGraphQLClient(nr_account_id, api_key, api_endpoint)
try:

validate_linked_account(linked_account_name, api_client)
Expand Down

0 comments on commit 2505eca

Please sign in to comment.