<commit_before>Datastore
===============================

The goal of the datastore service is to allow users to store common
parameters and their values within Stanley for reuse in the definition
of sensors, actions, and rules. The datastore service store the data as
a key value pair and they can be get/set using the st2 CLI or the st2
python client. From the sensor and action plugins, since they are
implemented in python, the key value pairs are accessed from the st2
python client. For rule definitions in JSON, the key value pairs are
referenced with a specific string substitution syntax and the references
are resolved on rule evaluation.

Storing and Retrieving Key Value Pairs from CLI
-----------------------------------------------

Create new key value pairs.

::

    st2 key create os_keystone_endpoint http://localhost:5000/v2.0
    st2 key create aws_cfn_endpoint https://cloudformation.us-west-1.amazonaws.com

Load a list of key value pairs from a JSON file. The following is the
JSON example using the same keys from the create examples above.

::

    {
        "os_keystone_endpoint": "http://localhost:5000/v2.0",
        "aws_cfn_endpoint": "https://cloudformation.us-west-1.amazonaws.com"
    }

    st2 key load mydata.json

Get individual key value pair or list all.

::

    st2 key list
    st2 key get os_keystone_endpoint
    st2 key get os_keystone_endpoint -j

Update an existing key value pair.

::

    st2 key update os_keystone_endpoint http://localhost:5000/v3

Delete an existing key value pair.

::

    st2 key delete os_keystone_endpoint

Storing and Retrieving from Python Client
-----------------------------------------

Create new key value pairs. The Stanley API endpoint is set either via
the Client init (base\_url) or from environment variable
(ST2\_BASE\_URL). The default ports for the API servers are assumed.

::

    >>> from st2client.client import Client
    >>> from st2client.models import KeyValuePair
    >>> client = Client(base_url='http://localhost')
    >>> client.keys.create(models.KeyValuePair(name='os_keystone_endpoint', value='http://localhost:5000/v2.0'))

Get individual key value pair or list all.

::

    >>> keys = client.keys.get_all()
    >>> os_keystone_endpoint = client.keys.get_by_name(name='os_keystone_endpoint')<commit_msg>Update stanley/Stanley/STANLEY references in datastore.rst.<commit_after>Datastore
===============================

The goal of the datastore service is to allow users to store common
parameters and their values within st2 for reuse in the definition
of sensors, actions, and rules. The datastore service store the data as
a key value pair and they can be get/set using the st2 CLI or the st2
python client. From the sensor and action plugins, since they are
implemented in python, the key value pairs are accessed from the st2
python client. For rule definitions in JSON, the key value pairs are
referenced with a specific string substitution syntax and the references
are resolved on rule evaluation.

Storing and Retrieving Key Value Pairs from CLI
-----------------------------------------------

Create new key value pairs.

::

    st2 key create os_keystone_endpoint http://localhost:5000/v2.0
    st2 key create aws_cfn_endpoint https://cloudformation.us-west-1.amazonaws.com

Load a list of key value pairs from a JSON file. The following is the
JSON example using the same keys from the create examples above.

::

    {
        "os_keystone_endpoint": "http://localhost:5000/v2.0",
        "aws_cfn_endpoint": "https://cloudformation.us-west-1.amazonaws.com"
    }

    st2 key load mydata.json

Get individual key value pair or list all.

::

    st2 key list
    st2 key get os_keystone_endpoint
    st2 key get os_keystone_endpoint -j

Update an existing key value pair.

::

    st2 key update os_keystone_endpoint http://localhost:5000/v3

Delete an existing key value pair.

::

    st2 key delete os_keystone_endpoint

Storing and Retrieving from Python Client
-----------------------------------------

Create new key value pairs. The st2 API endpoint is set either via
the Client init (base\_url) or from environment variable
(ST2\_BASE\_URL). The default ports for the API servers are assumed.

::

    >>> from st2client.client import Client
    >>> from st2client.models import KeyValuePair
    >>> client = Client(base_url='http://localhost')
    >>> client.keys.create(models.KeyValuePair(name='os_keystone_endpoint', value='http://localhost:5000/v2.0'))

Get individual key value pair or list all.

::

    >>> keys = client.keys.get_all()
    >>> os_keystone_endpoint = client.keys.get_by_name(name='os_keystone_endpoint')
{'fraction_non_alphanumeric': 0.11802575107296137, 'fraction_numerical': 0.017167381974248927, 'mean_word_length': 3.319740500463392, 'pattern_counts': {'":': 4, '<': 3, '<?xml version=': 0, '>': 39, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6686250', 'n_tokens_mistral': 1324, 'n_tokens_neox': 1259, 'n_words': 527}