Exemple #1
0
def my_handler(event, context):
    CLUSTER_NAME = event['cluster-name']
    REGION = event['region']
    token = auth.get_bearer_token(CLUSTER_NAME, REGION)
    if not os.path.exists(KUBE_FILEPATH):
        create_kube_config(CLUSTER_NAME, REGION)
    config.load_kube_config(KUBE_FILEPATH)
    configuration = client.Configuration()
    configuration.api_key['authorization'] = token
    configuration.api_key_prefix['authorization'] = 'Bearer'
    api = client.ApiClient(configuration)
    v1 = client.AppsV1Api(api)
    body = {
        "spec": {
            "template": {
                "spec": {
                    "containers": [{
                        "name": event["deployment"],
                        "image": event["image"]
                    }]
                }
            }
        }
    }

    namespace = event["namespace"]
    name = event["deployment"]
    ret = v1.patch_namespaced_deployment(name, namespace, body)
    return {
        'statusCode': 200,
        'deployment name': ret.metadata.name,
        'namespace': ret.metadata.namespace,
        'updated_image': event["image"]
    }
Exemple #2
0
def get_league_teams(year):
	url = urlify([constants.API_BASE_URL, "league", constants.LEAGUE_LOOKUP[year], "teams"])
	querystring = {"format":"json"}

	payload = ""
	headers = {
	    'Authorization': "bearer " + auth.get_bearer_token(),
	    'cache-control': "no-cache",
	    'Postman-Token': "9ca3433a-736d-4524-9f6d-4c17e498f96c"
	    }

	response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

	return response
Exemple #3
0
def get_team_players(team_key):
	url = urlify([constants.API_BASE_URL, "team", team_key, "players"])

	querystring = {"format":"json"}

	payload = ""
	headers = {
	    'Authorization': "bearer " + auth.get_bearer_token(),
	    'cache-control': "no-cache",
	    'Postman-Token': "9ca3433a-736d-4524-9f6d-4c17e498f96c"
	    }

	response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

	# print(response.text)
	return response
Exemple #4
0
def get_league_transactions(year):
	url = urlify([constants.API_BASE_URL, "league", constants.LEAGUE_LOOKUP[year], "transactions"])

	querystring = {"format":"json"}

	payload = ""
	headers = {
	    'Authorization': "bearer " + auth.get_bearer_token(),
	    'cache-control': "no-cache",
	    'Postman-Token': "a6fec9cf-8b4e-4ca1-b788-d3f77b5b03a2"
	    }

	response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

	# print(response.text)
	return response
Exemple #5
0
def get_draft_results(year):
	url = urlify([constants.API_BASE_URL, "league", constants.LEAGUE_LOOKUP[year], "draftresults"])

	querystring = {"format":"json"}

	payload = ""
	headers = {
	    'Authorization': "bearer " + auth.get_bearer_token(),
	    'cache-control': "no-cache",
	    'Postman-Token': "175947ac-ffe1-44b3-8b63-fc451ff66601"
	    }

	response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

	# print(response.text)
	return response
Exemple #6
0
def get_player_info_by_key(player_key):
	url = urlify([constants.API_BASE_URL, "player", player_key])

	querystring = {"format":"json"}

	payload = ""
	headers = {
	    'Authorization': "bearer " + auth.get_bearer_token(),
	    'cache-control': "no-cache",
	    'Postman-Token': "acc1f544-234e-4a1b-9eef-69b10de156d2"
	    }

	response = requests.request("GET", url, data=payload, headers=headers, params=querystring)

	# print(response.text)
	return response