in a pulumi script i get the following error running pulumi up
azure-native:sql:DatabaseSecurityAlertPolicy (sap_primary):
error: azure-native:sql:DatabaseSecurityAlertPolicy resource 'sap_primary' has a problem: missing required property 'resourceGroupName'
Here is the relevant part of the code:
resource_group = resources.ResourceGroup(
resource_name = <rg-name>,
tags={
<tags> # placeholder for the real tags
},
opts=pulumi.ResourceOptions(import_=<rg id>))
sql_server = sql.Server(
resource_name = str(app_stage) + '-' + str(app_key) + '-sql',
resource_group_name = resource_group.name,
location = resource_group.location,
administrator_login = sql_server_admin_user,
administrator_login_password = sql_server_admin_password,
version = sql_version,
tags = resource_group.tags,
identity = sql.ResourceIdentityArgs(type=sql.IdentityType.SYSTEM_ASSIGNED)
)
sql_database_primary = sql.Database(
resource_name = sql_database_name,
resource_group_name = resource_group.name,
location = resource_group.location,
server_name = sql_server.name,
sku = sql.SkuArgs(
name = 'GP_Gen5_2',
tier = sql_edition),
zone_redundant = sql_zone_redundancy,
tags = resource_group.tags,
)
database_security_alert_policy = sql.DatabaseSecurityAlertPolicy(
resource_name = 'sap_primary',
resource_group_name = sql_server.resource_group_name,
database_name = sql_database_name,
server_name = sql_server.name,
state = sql.SecurityAlertsPolicyState.ENABLED,
)
I don't understand why does it say resourceGroupName is missing but it is set as you can see. What am I missing?
To avoid questions like: Where is e.g. sql_server_admin_user coming from, they are set in the Pulumi.dev.yaml file and imported in the script like config.get('sql_server_admin_user')
sql_server.resource_group_name does not exist. Use resource_group.name instead.
Related
I want to handle a GET request in my Flask REST API.The request will include List parameter and I use this to be a typical GET request:
https://localhost:5000/organisation?List=1
this request, will return all of Organisation Model information. Organisation is a Model class for a table of my MySQL database(by peewee).
I want to enter PrivenceId parameter in request and will return all of Organisation Model information where Organisation.PrivencedId == PrivenceId parameter, But I encounter the following Error:
TypeError: 'Organisation' object is not iterable
my code (OrganisationController.py file) is:
from flask_restplus import Resource, reqparse
from Models.Organisation import Organisation
from flask import request
# Define parser and request args
parser = reqparse.RequestParser()
parser.add_argument('List', type=int)
parser.add_argument('ProvinceId', type=int)
class List(Resource):
def get(self):
args = parser.parse_args()
List = args['List']
ProvinceId = args['ProvinceId']
if List :
Organisations = Organisation.select()
Ls = [dict (
ID = c.ID,
Title = c.Title,
Code = c. Code,
OrgEnumId = c.OrgEnumId,
ProvinceId = c.ProvinceId,
CityId = c.CityId,
Address = c.Address,
Phone = c.Phone,
) for c in Organisations
]
return dict(Organisations = Ls)
elif (ProvinceId) :
Organisations = Organisation.select().where
(
Organisation.ProvinceId ==args['ProvinceId']
).get()
Ls = [dict (
ID = c.ID,
Title = c.Title,
Code = c. Code,
OrgEnumId = c.OrgEnumId,
ProvinceId = c.ProvinceId,
CityId = c.CityId,
Address = c.Address,
Phone = c.Phone,
) for c in Organisations
]
return dict(Organisations = Ls)
and boot.py file for run api is :
from flask import Flask
from flask_restplus import Api
from Controllers import OrganisationController
app = Flask(__name__)
api = Api(app)
api.add_resource(OrganisationController.List, '/organisation')
if __name__ == "__main__":
app.run ('127.0.0.1', 5000, True)
Could you help me?
I changed this line of my code and solved my problem:
Organisations = Organisation.select().where
(
Organisation.ProvinceId ==args['ProvinceId']
)
I'm currently trying to map automatically user groups in LDAP to user roles in a flask AppBuilder framework based application but can't come up with a solution. I have read through the entire flask AppBuilder documentation and didn't find anything related to this.
Here is the basic configuration I have come up with. I don't know how I could map different roles to different user groups.
AUTH_TYPE = AUTH_LDAP
AUTH_LDAP_SERVER = "ldap://ldapserver.local"
AUTH_LDAP_USE_TLS = False
AUTH_LDAP_SEARCH = "dc=domain,dc=local"
AUTH_LDAP_BIND_USER = "CN=Query User,OU=People,dc=domain,dc=local"
AUTH_LDAP_BIND_PASSWORD = "password"
AUTH_USER_REGISTRATION = True
AUTH_USER_REGISTRATION_ROLE = "Admin"
airflow 2.1.1
WTF_CSRF_ENABLED = True
AUTH_TYPE = AUTH_LDAP
AUTH_ROLE_ADMIN = 'Admin'
AUTH_USER_REGISTRATION = True
AUTH_USER_REGISTRATION_ROLE = "Public"
AUTH_LDAP_USE_TLS = False
AUTH_LDAP_SERVER = "ldap://ldapserver.local:389"
AUTH_LDAP_SEARCH = "OU=Users,DC=ldapserver,DC=local"
AUTH_LDAP_BIND_USER = "CN=Query User,OU=People,dc=ldapserver,dc=local"
AUTH_LDAP_BIND_PASSWORD = "password"
AUTH_LDAP_UID_FIELD = "sAMAccountName"
AUTH_ROLES_MAPPING = {
"CN=group_1_name,OU=Groups,DC=ldapserver,DC=local": ["Admin"],
"CN=group_2_name,OU=Groups,DC=ldapserver,DC=local": ["Viewer"],
}
AUTH_LDAP_GROUP_FIELD = "memberOf"
AUTH_ROLES_SYNC_AT_LOGIN = False
PERMANENT_SESSION_LIFETIME = 1800
I am trying to query a unique document using its ObjectId. However the error comes up:
DoesNotExist: Route matching query does not exist
When, upon passing this to my view as request, it prints out the corresponding ObjectId in ObjectId typeform. Therefore there shouldn't be a problem with the line route_test = Route.objects.get(id=_id).
I have the following code:
views.py
def update(request):
if request.method == "POST":
_id = request.POST.get('_id',ObjectId())
print(_id)
route_id = request.POST.get('route_id','')
geometry = request.POST.get('geometry', '')
properties = request.POST.get('properties','')
#r = Route.objects.get(route_id='LTFRB_PUJ2616') --> I cannot use this
#because it has 5 instances (Not Unique)
#print (r["id"],r["properties"])
test = Route.objects.get(id = ObjectId('587c4c3b203ada19e8e0ecf6'))
print (test["id"], test["properties"])
try:
route_test = Route.objects.get(id=_id)
print(route_test)
Route.objects.get(id=_id).update(set__geometry=geometry, set__properties=properties)
return HttpResponse("Success!")
except:
return HttpResponse("Error!")
ajax
var finishBtn = L.easyButton({
id:'finish',
states: [{
icon:"fa fa-check",
onClick: function(btn){
selectedFeature.editing.disable();
layer.closePopup();
var editedFeature = selectedFeature.toGeoJSON();
alert("Updating:" + editedFeature.route_id);
$.ajax({
url: "/update/",
data: {id:editedFeature.id,
route_id: JSON.stringify(editedFeature.route_id),
geometry: JSON.stringify(editedFeature.geometry),
properties: JSON.stringify(editedFeature.properties)
},
type: 'POST'
});
}
model.py
from __future__ import unicode_literals
from mongoengine import *
class Route(Document):
type = StringField(required=True)
route_id = StringField(required=True)
geometry = LineStringField()
properties = DictField()
meta = {'collection':'routes'}
What should be done? Even the line test = Route.objects.get(id = ObjectId('587c4c3b203ada19e8e0ecf6')) where I directly supplied the incoming _id has the same error...
I am trying to create multiple payment profiles for my customers auth net profile using the this method.
def createAuthnetPaymentProfile(profileID, tries = 3):
profile = client.factory.create("CreateCustomerPaymentProfile")
profile.merchantAuthentication = merchantAuthentication
profile.customerProfileId = profileID
profile.paymentProfile = getAuthnetProfile(profileID, tries).paymentProfiles
payment_simple_type = client.factory.create('PaymentType')
card_simple_type = client.factory.create('CreditCardSimpleType')
payment_simple_type.creditCard = card_simple_type
profile.payment = payment_simple_type
profile.payment.creditCard = card_simple_type
profile.validationMode.value = "none"
profileResult = makeAuthnetCall(client.service.CreateCustomerPaymentProfile, profile, tries)
checkForError(profileResult)
return profileResult.customerPaymentProfileId
However this returns this error AuthnetError: E00029: Payment information is required.
What might be the problem with my code.
I get a syntax error when trying to insert into a datastore, the exact same line of code worked in another project
B = db_Person(nafn='Alex')
Here is the rest of the code:
http://pastebin.com/bW37aUuT
def post(self):
q = db.Query(db_Person)
message = "Innsetning tokst"
in_kennitala = int(self.request.get('p_kennitala'))
in_nafn = self.request.get('p_nafn')
in_heimili = self.request.get('p_heimili')
in_postnumer = self.request.get('p_postnumer')
in_stadur = self.request.get('p_stadur')
in_land = self.request.get('p_land')
in_simi = int(self.request.get('p_simi'))
in_gsm = int(self.request.get('p_gsm') # <- missing right parenthesis
B = db_Person(nafn='Alex') # <- parser gets confused here
B.put()
template_values = {
'message': message
}
template = jinja_environment.get_template('breyta.html')
self.response.out.write(template.render(template_values))
This is the fixed code:
def post(self):
q = db.Query(db_Person)
message = "Innsetning tokst"
in_kennitala = int(self.request.get('p_kennitala'))
in_nafn = self.request.get('p_nafn')
in_heimili = self.request.get('p_heimili')
in_postnumer = self.request.get('p_postnumer')
in_stadur = self.request.get('p_stadur')
in_land = self.request.get('p_land')
in_simi = int(self.request.get('p_simi'))
in_gsm = int(self.request.get('p_gsm'))
B = db_Person(nafn='Alex')
B.put()
template_values = {
'message': message
}
template = jinja_environment.get_template('breyta.html')
self.response.out.write(template.render(template_values))