add default uri roles
This commit is contained in:
parent
24e5f78668
commit
1e223e7b57
|
@ -8,10 +8,10 @@ pattern: rpc
|
|||
parameters:
|
||||
role_name:
|
||||
type: String
|
||||
shortarg: n
|
||||
shortarg: r
|
||||
description: Nom du rôle.
|
||||
ref: User.RoleName
|
||||
uri:
|
||||
uri_name:
|
||||
type: String
|
||||
shortarg: u
|
||||
description: Nom du message.
|
||||
|
|
|
@ -7,9 +7,9 @@ properties:
|
|||
type: string
|
||||
description: Nom du rôle
|
||||
ref: User.RoleName
|
||||
uri:
|
||||
uri_name:
|
||||
type: string
|
||||
description: Nom du message
|
||||
required:
|
||||
- role_name
|
||||
- uri
|
||||
- uri_name
|
||||
|
|
|
@ -7,11 +7,67 @@ from ...utils import _
|
|||
|
||||
|
||||
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)
|
||||
async def uri_role_join(self,
|
||||
risotto_context: Context,
|
||||
role_name: str,
|
||||
uri: str) -> Dict:
|
||||
uri_name: str) -> Dict:
|
||||
# Verify if user exists and get ID
|
||||
sql = '''
|
||||
SELECT URIId
|
||||
|
@ -19,18 +75,19 @@ class Risotto(Controller):
|
|||
WHERE URIName = $1
|
||||
'''
|
||||
uri_id = await risotto_context.connection.fetchval(sql,
|
||||
uri)
|
||||
uri_name)
|
||||
if uri_id is None:
|
||||
raise Exception(_(f'unable to find message {uri}'))
|
||||
raise Exception(_(f'unable to find message {uri_name}'))
|
||||
sql = '''
|
||||
INSERT INTO RoleURI(RoleName, URIId)
|
||||
VALUES ($1,$2)
|
||||
ON CONFLICT DO NOTHING
|
||||
'''
|
||||
uri_id = await risotto_context.connection.fetchrow(sql,
|
||||
role_name,
|
||||
uri_id)
|
||||
return {'role_name': role_name,
|
||||
'uri': uri}
|
||||
'uri_name': uri_name}
|
||||
|
||||
@register('v1.uri.role.list', None, database=True)
|
||||
async def uri_role_list(self,
|
||||
|
|
Loading…
Reference in New Issue