def __init__(self, api_home_url='', relations={}): self.__log = logging.getLogger(__name__) self.__log.debug("__init__(api_home_url=%s, relations=%s)" % (api_home_url, str(relations))) if "users" not in relations: relations["users"] = default_link_rel_users self.__log.warning("Using default link relation for users: %s" % default_link_rel_users) if "projects" not in relations: relations["projects"] = default_link_rel_projects self.__log.warning("Using default link relation for projects: %s" % default_link_rel_projects) self._rc = RestClient(relations) @self._rc.handle_content_type('application/json-home', 0.75) def handle_json_home0(client, resp): # parse JSON home document or other JSON directly json_home_data = resp.json() self.__log.debug("have JSON home data: %s" % (str(json_home_data))) if 'resources' in json_home_data: for rel, d in json_home_data['resources'].iteritems(): if 'href' in d: client.remember_link(resp.url, rel, d['href']) return True else: return False # Fetch and handle the API Home URL self._rc.get(api_home_url)
import logging from rest_framework import status from rest_framework.response import Response from rest_framework.views import APIView import requests from restclient import RestClient from requests.packages.urllib3.exceptions import InsecureRequestWarning requests.packages.urllib3.disable_warnings(InsecureRequestWarning) import json import re logger = logging.getLogger(__name__) rest_client = RestClient("10.154.9.156", "*****@*****.**", "VMware1!") class Omsnode(APIView): def post(self, request, cluster, ng): api_url_template = "cluster/{}/nodegroup/{}/scaleout" url = api_url_template.format(cluster, ng) try: resp = rest_client.do_put(url, request.body) except Exception as e: return Response(data={'error': str(e)}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response(data={'oms': resp}, status=status.HTTP_202_ACCEPTED) def delete(self, request, cluster, ng, nd):
def __init__(self, oms, sso_user, sso_pwd): self.rest_client = RestClient(oms, sso_user, sso_pwd) self.logger = logging.getLogger(__name__) self._made_remote_dirs = []
import sys def getInput(string, l, ex=False): while True: val = int(input(string + "\n")) if (ex == True and val == 5): sys.exit() if val not in l: print('Invalid Input') else: break return val a = RestClient("http://127.0.0.1:5000") tables = {1: 'employees', 2: 'student', 3: 'cricket'} employeeDict = { "LastName": "", "FirstName": "", "Title": "", "ReportsTo": "", "BirthDate": "", "HireDate": "", "Address": "", "City": "", "State": "", "Country": "", "PostalCode": "", "Phone": "", "Fax": "",