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
|
|
|
import re |
17
|
|
|
|
18
|
|
|
from lib.actions import OrionBaseAction |
19
|
|
|
|
20
|
|
|
|
21
|
|
|
class ListSdkVerbs(OrionBaseAction): |
22
|
|
|
def run(self, platform, can_invoke=True, v_filter=None): |
23
|
|
|
""" |
24
|
|
|
List the Orion SDK Verbs |
25
|
|
|
|
26
|
|
|
Args: |
27
|
|
|
platform: The orion platform to act on. |
28
|
|
|
can_invoke: Limit to verbs what can be Invoked by the API. |
29
|
|
|
v_filter: Limit returned Verbs that match the filter. |
30
|
|
|
|
31
|
|
|
Returns: |
32
|
|
|
dict: Containing the returned data. |
33
|
|
|
|
34
|
|
|
Raises: |
35
|
|
|
None: Does not raise exceptions. |
36
|
|
|
""" |
37
|
|
|
|
38
|
|
|
results = {'Entities': []} |
39
|
|
|
self.connect(platform) |
40
|
|
|
|
41
|
|
|
swql = """SELECT Name, MethodName, EntityName |
42
|
|
|
FROM Metadata.Verb where CanInvoke=@CanInvoke""" |
43
|
|
|
kargs = {'CanInvoke': can_invoke} |
44
|
|
|
orion_data = self.query(swql, **kargs) |
45
|
|
|
|
46
|
|
|
if v_filter is not None: |
47
|
|
|
m = re.compile("{}".format(v_filter)) |
48
|
|
|
|
49
|
|
|
for item in orion_data['results']: |
50
|
|
|
if v_filter is not None: |
51
|
|
|
if m.search( |
52
|
|
|
item['EntityName']) or m.search(item['MethodName']): |
53
|
|
|
pass |
54
|
|
|
else: |
55
|
|
|
continue |
56
|
|
|
|
57
|
|
|
results['Entities'].append({'Entity': item['EntityName'], |
58
|
|
|
'Method': item['MethodName']}) |
59
|
|
|
return results |
60
|
|
|
|