def create(self, validated_data): #Init Arango Models AwsCredentials.init() Companies.init() account_obj = AwsCredentials.objects.get( _id=str(validated_data['account_id'])) obj = Collection.get_loaded_collection(name='ScheduleIntervalSettings') SimpleQuery.update_by_example( obj, { 'account_id': str(account_obj.document), 'service': str(validated_data['service']), }, { 'service': validated_data['service'], 'repeat_delay': validated_data['repeat_delay'] }) response = SimpleQuery.get_by_example( obj, example_data={ 'account_id': str(account_obj.document), 'service': str(validated_data['service']) }) headers = {"Content-Type": "application/json"} url = FOXX_BASE_URL + "execute/" + urllib.quote_plus( str(response)) + "/" + str(self.context['user']) + "/edit" response = requests.get(url, headers=headers) return response
def test_update_document(self): SimpleQuery.update_by_example(collection=self.test_1_col, example_data={ 'bla': 'xxx' }, new_value={ 'bla': 'ttt' }) self.col1_doc2.retrieve() self.assertEqual(self.col1_doc2.bla, 'ttt')
def test_update_document(self): SimpleQuery.update_by_example(collection=self.test_1_col, example_data={'bla': 'xxx'}, new_value={'bla': 'ttt'}) self.col1_doc2.retrieve() self.assertEqual(self.col1_doc2.bla, 'ttt')
def create(self, validated_data): #Init Arango Models AwsCredentials.init() Companies.init() obj = AwsCredentials() obj.role_arn = str(validated_data['role_arn']) obj.external_id = str(validated_data['external_id']) obj.account_name = str(validated_data['account_name']) obj.company = Companies.objects.get(_id=str(self.context['company'])) obj.user = int(self.context['user']) obj.save() collection = Collection.get_loaded_collection('AwsExternalIds') SimpleQuery.update_by_example(collection, {'external_id': obj.external_id}, { 'used': True, 'company': str(obj.company.id), 'user': obj.user }) return obj.id