Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if status == LIVEACTION_STATUS_SCHEDULED:
indicator.add_stage(status, name)
if status == LIVEACTION_STATUS_RUNNING:
indicator.update_stage(status, name)
if status in LIVEACTION_COMPLETED_STATES:
indicator.finish_stage(status, name)
if execution and execution.status == LIVEACTION_STATUS_FAILED:
args.depth = 1
self._print_execution_details(execution=execution, args=args, **kwargs)
sys.exit(1)
return self.app.client.managers['Execution'].get_by_id(parent_id, **kwargs)
class PackListCommand(resource.ResourceListCommand):
display_attributes = ['ref', 'name', 'description', 'version', 'author']
attribute_display_order = ['ref', 'name', 'description', 'version', 'author']
class PackGetCommand(resource.ResourceGetCommand):
pk_argument_name = 'ref'
display_attributes = ['name', 'version', 'author', 'email', 'keywords', 'description']
attribute_display_order = ['name', 'version', 'author', 'email', 'keywords', 'description']
help_string = 'Get information about an installed pack.'
class PackShowCommand(PackResourceCommand):
def __init__(self, resource, *args, **kwargs):
help_string = (
'Get information about an available %s from the index.'
% resource.get_display_name().lower()
commands={'list': ActionAliasListCommand, 'get': ActionAliasGetCommand},
)
self.commands['match'] = ActionAliasMatchCommand(
self.resource, self.app, self.subparsers, add_help=True
)
self.commands['execute'] = ActionAliasExecuteCommand(
self.resource, self.app, self.subparsers, add_help=True
)
class ActionAliasListCommand(resource.ContentPackResourceListCommand):
display_attributes = ['ref', 'pack', 'description', 'enabled']
class ActionAliasGetCommand(resource.ContentPackResourceGetCommand):
display_attributes = ['all']
attribute_display_order = [
'id',
'ref',
'pack',
'name',
'description',
'enabled',
'action_ref',
'formats',
]
class ActionAliasMatchCommand(resource.ResourceCommand):
display_attributes = ['name', 'description']
class RuleGetCommand(resource.ContentPackResourceGetCommand):
display_attributes = ['all']
attribute_display_order = ['id', 'uid', 'ref', 'pack', 'name', 'description', 'enabled']
class RuleUpdateCommand(resource.ContentPackResourceUpdateCommand):
pass
class RuleEnableCommand(resource.ContentPackResourceEnableCommand):
display_attributes = ['all']
attribute_display_order = ['id', 'ref', 'pack', 'name', 'enabled', 'description', 'enabled']
class RuleDisableCommand(resource.ContentPackResourceDisableCommand):
display_attributes = ['all']
attribute_display_order = ['id', 'ref', 'pack', 'name', 'enabled', 'description', 'enabled']
class RuleDeleteCommand(resource.ContentPackResourceDeleteCommand):
pass
)
if args.last and count and count > args.last:
table.SingleRowTable.note_box(self.resource_name, args.last)
class RuleGetCommand(resource.ContentPackResourceGetCommand):
display_attributes = ['all']
attribute_display_order = ['id', 'uid', 'ref', 'pack', 'name', 'description', 'enabled']
class RuleUpdateCommand(resource.ContentPackResourceUpdateCommand):
pass
class RuleEnableCommand(resource.ContentPackResourceEnableCommand):
display_attributes = ['all']
attribute_display_order = ['id', 'ref', 'pack', 'name', 'enabled', 'description', 'enabled']
class RuleDisableCommand(resource.ContentPackResourceDisableCommand):
display_attributes = ['all']
attribute_display_order = ['id', 'ref', 'pack', 'name', 'enabled', 'description', 'enabled']
class RuleDeleteCommand(resource.ContentPackResourceDeleteCommand):
pass
class ActionAliasGetCommand(resource.ContentPackResourceGetCommand):
display_attributes = ['all']
attribute_display_order = [
'id',
'ref',
'pack',
'name',
'description',
'enabled',
'action_ref',
'formats',
]
class ActionAliasMatchCommand(resource.ResourceCommand):
display_attributes = ['name', 'description']
def __init__(self, resource, *args, **kwargs):
super(ActionAliasMatchCommand, self).__init__(
resource,
'match',
'Get the %s that match the command text.' % resource.get_display_name().lower(),
*args,
**kwargs
)
self.parser.add_argument(
'match_text',
metavar='command',
help=('Get the %s that match the command text.' % resource.get_display_name().lower()),
)
class SensorGetCommand(resource.ContentPackResourceGetCommand):
display_attributes = ['all']
attribute_display_order = [
'id',
'uid',
'ref',
'pack',
'name',
'enabled',
'entry_point',
'artifact_uri',
'trigger_types',
]
class SensorEnableCommand(resource.ContentPackResourceEnableCommand):
display_attributes = ['all']
attribute_display_order = [
'id',
'ref',
'pack',
'name',
'enabled',
'poll_interval',
'entry_point',
'artifact_uri',
'trigger_types',
]
class SensorDisableCommand(resource.ContentPackResourceDisableCommand):
display_attributes = ['all']
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
from __future__ import absolute_import
from st2client import models
from st2client.commands import resource
from st2client.formatters import table
class RuleBranch(resource.ResourceBranch):
def __init__(self, description, app, subparsers, parent_parser=None):
super(RuleBranch, self).__init__(
models.Rule,
description,
app,
subparsers,
parent_parser=parent_parser,
commands={
'list': RuleListCommand,
'get': RuleGetCommand,
'update': RuleUpdateCommand,
'delete': RuleDeleteCommand,
},
)
self.commands['enable'] = RuleEnableCommand(self.resource, self.app, self.subparsers)