def _find_new_chains(): """Get all peer chains """ other_chains = [] for url in peer_nodes: block = json.loads(request.request(f"{url}/blocks").content) other_chains.append(block) return other_chains
def listProjectStories(): url = "https://www.pivotaltracker.com/services/v5/projects/"+2186196+"/stories" token_header = request.headers['X-TrackerToken'] headers = { 'X-TrackerToken': str(token_header) } response = request.request("DELETE", url, headers=headers) return response.text
def editStory(pid, sid): story_url = "https://www.pivotaltracker.com/services/v5/projects/"+ 2186196 + "/stories/"+ 159223178 edit = request.json token_header = request.headers['X-TrackerToken'] headers = { 'X-TrackerToken': str(token_header) } response = request.request("PUT", story_url, data=edit, headers=headers) return response.text
def createStory(): storyDetails = request.json story_url = "https://www.pivotaltracker.com/services/v5/projects/"+ id +"/stories" token_header = request.headers['X-TrackerToken'] headers = { 'X-TrackerToken': str(token_header) } response = request.request("POST", story_url, data=storyDetails, headers=headers) return response.text
def getspecificEntry(): entryName = request.json token_header = request.headers['X-TrackerToken'] payload = entryName headers = { 'X-TrackerToken': str(token_header), } response = request.request("POST", url, data=payload, headers=headers) return response.text
def getAllEntry(): querystring = {"account_id": str(id)} token_header = request.headers['X-TrackerToken'] headers = { 'X-TrackerToken': str(token_header), 'Content-Type' : 'application/json' } response = request.request("GET", headers=headers, params=querystring) return response.text
def get_disruptions(line): request = urllib3.PoolManager() args = [line] url = "https://api.tfl.gov.uk/Line/{}/Disruption/" if(os.environ.get('APP_ID')): url += "?app_id={}&app_key={}" args += [os.environ.get('APP_ID'), os.environ.get('API_KEY')] url = url.format(*args) response = request.request('GET', url) data = response.data.decode('UTF-8') return json.loads(data)
def createSecurityGroup(address): url = "https://uaa.cf.stagingaws.hanavlab.ondemand.com/oauth/token" payload = "response_type=token&client_id=cf&grant_type=password&client_secret=&username=admin&password=admin" headers = { 'content-type': "application/x-www-form-urlencoded", 'cache-control': "no-cache", } response = request.request("POST", url, data=payload, headers=headers) response_json = json.loads(response.text) accesstoken = response_json["access_token"] print(accesstoken) url = "https://api.cf.stagingaws.hanavlab.ondemand.com/v2/security_groups" payload = { "name": "test_service_group", "rules": [{ "protocol": "all", "destination": address, "ports": "9200,9300,9201,9202,9301,9302", "log": "true", "description": "This rule allows access to Elastic service instance" }] } print(payload) headers = { 'authorization': "bearer " + accesstoken, 'content-type': "application/json", 'cache-control': "no-cache" } response = request.request("POST", url, data=payload, headers=headers) print(response.text)