1
|
|
|
# Licensed to the StackStorm, Inc ('StackStorm') under one or more |
2
|
|
|
# contributor license agreements. See the NOTICE file distributed with |
3
|
|
|
# this work for additional information regarding copyright ownership. |
4
|
|
|
# The ASF licenses this file to You under the Apache License, Version 2.0 |
5
|
|
|
# (the "License"); you may not use this file except in compliance with |
6
|
|
|
# the License. You may obtain a copy of the License at |
7
|
|
|
# |
8
|
|
|
# http://www.apache.org/licenses/LICENSE-2.0 |
9
|
|
|
# |
10
|
|
|
# Unless required by applicable law or agreed to in writing, software |
11
|
|
|
# distributed under the License is distributed on an "AS IS" BASIS, |
12
|
|
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13
|
|
|
# See the License for the specific language governing permissions and |
14
|
|
|
# limitations under the License. |
15
|
|
|
|
16
|
|
|
from lib.actions import OrionBaseAction |
17
|
|
|
|
18
|
|
|
|
19
|
|
|
class ListSdkVerbArgs(OrionBaseAction): |
20
|
|
|
def run(self, platform, entity_name, verb_name): |
21
|
|
|
""" |
22
|
|
|
List the Orion SDK Verbs |
23
|
|
|
|
24
|
|
|
Args: |
25
|
|
|
platform: The orion platform to act on. |
26
|
|
|
entity_name: The EntityName to query. |
27
|
|
|
verb_name: The VerbName to query. |
28
|
|
|
|
29
|
|
|
Returns: |
30
|
|
|
dict: Of a verb's args taken from the Orion DB. |
31
|
|
|
|
32
|
|
|
Raises: |
33
|
|
|
None: Does not raise any exceptions. |
34
|
|
|
""" |
35
|
|
|
|
36
|
|
|
results = {'verb_arguments': []} |
37
|
|
|
self.connect(platform) |
38
|
|
|
|
39
|
|
|
swql = """SELECT EntityName, VerbName, Position, Name, Type, |
40
|
|
|
XmlTemplate, XmlSchemas, IsOptional |
41
|
|
|
FROM Metadata.VerbArgument WHERE EntityName=@EntityName |
42
|
|
|
and VerbName=@VerbName |
43
|
|
|
ORDER BY Position""" |
44
|
|
|
kargs = {'EntityName': entity_name, |
45
|
|
|
'VerbName': verb_name} |
46
|
|
|
orion_data = self.query(swql, **kargs) |
47
|
|
|
|
48
|
|
|
for item in orion_data['results']: |
49
|
|
|
results['verb_arguments'].append( |
50
|
|
|
{'position': item['Position'], |
51
|
|
|
'name': item['Name'], |
52
|
|
|
'type': item['Type'], |
53
|
|
|
'optional': item['IsOptional']}) |
54
|
|
|
return results |
55
|
|
|
|