add default uri roles
This commit is contained in:
parent
24e5f78668
commit
1e223e7b57
|
@ -8,10 +8,10 @@ pattern: rpc
|
||||||
parameters:
|
parameters:
|
||||||
role_name:
|
role_name:
|
||||||
type: String
|
type: String
|
||||||
shortarg: n
|
shortarg: r
|
||||||
description: Nom du rôle.
|
description: Nom du rôle.
|
||||||
ref: User.RoleName
|
ref: User.RoleName
|
||||||
uri:
|
uri_name:
|
||||||
type: String
|
type: String
|
||||||
shortarg: u
|
shortarg: u
|
||||||
description: Nom du message.
|
description: Nom du message.
|
||||||
|
|
|
@ -7,9 +7,9 @@ properties:
|
||||||
type: string
|
type: string
|
||||||
description: Nom du rôle
|
description: Nom du rôle
|
||||||
ref: User.RoleName
|
ref: User.RoleName
|
||||||
uri:
|
uri_name:
|
||||||
type: string
|
type: string
|
||||||
description: Nom du message
|
description: Nom du message
|
||||||
required:
|
required:
|
||||||
- role_name
|
- role_name
|
||||||
- uri
|
- uri_name
|
||||||
|
|
|
@ -7,11 +7,67 @@ from ...utils import _
|
||||||
|
|
||||||
|
|
||||||
class Risotto(Controller):
|
class Risotto(Controller):
|
||||||
|
async def on_join(self,
|
||||||
|
risotto_context):
|
||||||
|
for uri in ['v1.applicationservice.create',
|
||||||
|
'v1.applicationservice.dataset.updated',
|
||||||
|
'v1.server.create',
|
||||||
|
'v1.servermodel.dataset.updated',
|
||||||
|
'v1.session.server.start',
|
||||||
|
'v1.source.create',
|
||||||
|
'v1.source.dataset.update',
|
||||||
|
'v1.source.release.create',
|
||||||
|
'v1.template.generate',
|
||||||
|
'v1.uri.role.join',
|
||||||
|
'v1.uri.role.list',
|
||||||
|
'v1.user.create',
|
||||||
|
'v1.user.delete',
|
||||||
|
'v1.user.list',
|
||||||
|
'v1.user.role.create',
|
||||||
|
'v1.user.role.list']:
|
||||||
|
try:
|
||||||
|
await self.call('v1.uri.role.join',
|
||||||
|
risotto_context,
|
||||||
|
role_name='administrator',
|
||||||
|
uri_name=uri)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
for uri in ['v1.applicationservice.describe',
|
||||||
|
'v1.applicationservice.get_by_id',
|
||||||
|
'v1.server.describe',
|
||||||
|
'v1.server.list',
|
||||||
|
'v1.servermodel.list',
|
||||||
|
'v1.session.server.configure',
|
||||||
|
'v1.session.server.filter',
|
||||||
|
'v1.session.server.get',
|
||||||
|
'v1.session.server.list',
|
||||||
|
'v1.session.servermodel.configure',
|
||||||
|
'v1.session.servermodel.filter',
|
||||||
|
'v1.session.servermodel.get',
|
||||||
|
'v1.session.servermodel.list',
|
||||||
|
'v1.session.servermodel.start',
|
||||||
|
'v1.session.servermodel.stop',
|
||||||
|
'v1.session.servermodel.validate',
|
||||||
|
'v1.session.server.stop',
|
||||||
|
'v1.session.server.validate',
|
||||||
|
'v1.source.describe',
|
||||||
|
'v1.source.list',
|
||||||
|
'v1.source.release.get_by_distribution',
|
||||||
|
'v1.source.release.get_by_id',
|
||||||
|
'v1.source.release.list']:
|
||||||
|
try:
|
||||||
|
await self.call('v1.uri.role.join',
|
||||||
|
risotto_context,
|
||||||
|
role_name='all',
|
||||||
|
uri_name=uri)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
@register('v1.uri.role.join', None, database=True)
|
@register('v1.uri.role.join', None, database=True)
|
||||||
async def uri_role_join(self,
|
async def uri_role_join(self,
|
||||||
risotto_context: Context,
|
risotto_context: Context,
|
||||||
role_name: str,
|
role_name: str,
|
||||||
uri: str) -> Dict:
|
uri_name: str) -> Dict:
|
||||||
# Verify if user exists and get ID
|
# Verify if user exists and get ID
|
||||||
sql = '''
|
sql = '''
|
||||||
SELECT URIId
|
SELECT URIId
|
||||||
|
@ -19,18 +75,19 @@ class Risotto(Controller):
|
||||||
WHERE URIName = $1
|
WHERE URIName = $1
|
||||||
'''
|
'''
|
||||||
uri_id = await risotto_context.connection.fetchval(sql,
|
uri_id = await risotto_context.connection.fetchval(sql,
|
||||||
uri)
|
uri_name)
|
||||||
if uri_id is None:
|
if uri_id is None:
|
||||||
raise Exception(_(f'unable to find message {uri}'))
|
raise Exception(_(f'unable to find message {uri_name}'))
|
||||||
sql = '''
|
sql = '''
|
||||||
INSERT INTO RoleURI(RoleName, URIId)
|
INSERT INTO RoleURI(RoleName, URIId)
|
||||||
VALUES ($1,$2)
|
VALUES ($1,$2)
|
||||||
|
ON CONFLICT DO NOTHING
|
||||||
'''
|
'''
|
||||||
uri_id = await risotto_context.connection.fetchrow(sql,
|
uri_id = await risotto_context.connection.fetchrow(sql,
|
||||||
role_name,
|
role_name,
|
||||||
uri_id)
|
uri_id)
|
||||||
return {'role_name': role_name,
|
return {'role_name': role_name,
|
||||||
'uri': uri}
|
'uri_name': uri_name}
|
||||||
|
|
||||||
@register('v1.uri.role.list', None, database=True)
|
@register('v1.uri.role.list', None, database=True)
|
||||||
async def uri_role_list(self,
|
async def uri_role_list(self,
|
||||||
|
|
Loading…
Reference in New Issue