def ConfigConsumer(username): consumer = ConsumerReference(username=username) consumer.save() KeyAuth = KeyAuthReference(consumer=consumer) KeyAuth.save() client = factory.get_kong_client() obj = ConsumerReference.objects.get(id=consumer.id) logic.synchronize_consumer(client, obj, toggle=False) client.close()
def apiDetail(request, param1): #http://10.103.240.194:8080/accontroller/apiAccessControl?apiName=weather&userId=15 api = APIReference.objects.get(name = param1) username = get_username(request) person = ConsumerReference.objects.get(username = username) status = 0 if request.method == "POST": p = Userinfo.objects.get(username=username) payload = {'apiName': param1, 'userId': p.userid} try: req_content = get("http://10.103.240.194:8080/accontroller/apiAccessControl", params=payload, timeout=2) json_content = json.loads(req_content.content) if not(json_content['result']): return HttpResponse('3') except: return HttpResponse("2") try: new_buy = BuyReference(api=api,consumer=person) new_buy.save() Acl = AclReference(consumer=person, group=param1) Acl.save() #print(person.id) client = factory.get_kong_client() obj = ConsumerReference.objects.get(id=person.id) logic.synchronize_consumer(client, obj, toggle=False) client.close() return HttpResponse("1") except: return HttpResponse("2") api_key = person.keyauthreference_related.all()[:1] api_key = api_key[0] gateway_url = 'http://10.33.6.199:8000' url_Parameters = ParameterReference.objects.filter(api__name__exact = param1) Headers = HeaderReference.objects.filter(api__name__exact = param1) Errors = ErrorReference.objects.filter(api__name__exact = param1) url_example = "?" for para in url_Parameters: url_example += para.name + '=' + para.defaultValue + '&' context = { 'api' : api, 'gateway_url' : gateway_url, 'url_Parameters' : url_Parameters, 'url_example' : url_example, 'Headers' : Headers, 'Errors' : Errors, 'api_key': api_key, 'status' : status, } return render_to_response('apiDetail.html', context)
def setUp(self): self.client = get_kong_client() self._cleanup_api = []
def setUp(self): self.client = get_kong_client() self._cleanup_consumers = []