
This depends on ansible-monasca-schema changes here: https://github.com/hpcloud-mon/ansible-monasca-schema/pull/17 Here are sample curl commands for POST, GET, and DELETE: curl -i -X POST -H 'X-Auth-User: mini-mon' -H 'X-Auth-Token: 8c959d0296344c27a47b8e78dbf912ac' -H 'X-Auth-Key: password' -H 'Accept: application/json' -H 'User-Agent: python-monascaclient' -H 'Content-Tye: application/json' -d '{"fire_criteria": [{"event_type": "compute.instance.create.start"}, {"event_type": "compute.instance.create.end"}], "description": "provisioning duration", "name": "panda", "group_by": ["instance_id"], "expiration": 3, "select": [{"traits": {"tenant_id": "406904"}, "event_type": "compute.instance.create.*"}], "fire_actions": ["ed469bb9-2b4a-457a-9926-9da9f6ac75da"], "expire_actions":["ed469bb9-2b4a-457a-9926-9da9f6ac75da"]}' http://127.0.0.1:8080/v2.0/events/stream-definitions curl -i -X GET -H 'X-Auth-User: mini-mon' -H 'X-Auth-Token: 8c959d0296344c27a47b8e78dbf912ac' -H 'X-Auth-Key: password' -H 'Accept: application/json' -H 'User-Agent: python-monascaclient' -H 'Content-Type: application/json' http://127.0.0.1:8080/v2.0/events/stream-definitions/ curl -i -X DELETE -H 'X-Auth-User: mini-mon' -H 'X-Auth-Token: 8c959d0296344c27a47b8e78dbf912ac' -H 'X-Auth-Key: password' -H 'Accept: application/json' -H 'User-Agent: python-monascaclient' -H 'Content-Type: application/json' http://127.0.0.1:8080/v2.0/events/stream-definitions/86177f0e-f811-4c42-a91a-1813251bf93f Note: the limit parameter is passed into the streams_repository method for listing streams, but not yet used. We will open a separate Jira to to handle pagination with a user input limit parameter. Note: fixed a few events problems. stevedore wasn't loading the driver, and missing some abstact function defs. I tested stream-defintions and events, they both work now. Had to change the URI for stream-definitions because it conflicted with events, and now is more RESTful. Change-Id: I0b6dc385e1d095c1bd33867a038fe170ca277bfe
49 lines
1.5 KiB
Python
49 lines
1.5 KiB
Python
# Copyright 2015 Hewlett-Packard
|
|
#
|
|
# Licensed under the Apache License, Version 2.0 (the "License"); you may
|
|
# not use this file except in compliance with the License. You may obtain
|
|
# a copy of the License at
|
|
#
|
|
# 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.
|
|
import abc
|
|
|
|
import six
|
|
|
|
|
|
@six.add_metaclass(abc.ABCMeta)
|
|
class StreamsRepository(object):
|
|
|
|
def __init__(self):
|
|
super(StreamsRepository, self).__init__()
|
|
|
|
@abc.abstractmethod
|
|
def create_stream_definition(self,
|
|
tenant_id,
|
|
name,
|
|
description,
|
|
select,
|
|
group_by,
|
|
fire_criteria,
|
|
expiration,
|
|
fire_actions,
|
|
expire_actions):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def delete_stream_definition(self, tenant_id, stream_definition_id):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get_stream_definition(self, tenant_id, stream_definition_id):
|
|
pass
|
|
|
|
@abc.abstractmethod
|
|
def get_stream_definitions(self, tenant_id, name, offset, limit):
|
|
pass
|