<commit_before>Key list
--------

To get a list of SSH keys, run GET against */api/keys/* as authenticated user.
Note that user can see only keys that he owns.

- Keys are injected to instances during creation. The owner of the key can log in to that instance.
- Project administrators can select what key will be injected to instance during instance provisioning.

Create a new key
----------------

A new SSH key can be created by any active users. Example of a valid request:

.. code-block:: http

    POST /api/keys/ HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Authorization: Token c84d653b9ec92c6cbac41c706593e66f567a7fa4
    Host: example.com

    {
        "name": "ssh_public_key1",
        "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDURXDP5YhOQUYoDuTxJ84DuzqMJYJqJ8+SZT28
                       TtLm5yBDRLKAERqtlbH2gkrQ3US58gd2r8H9jAmQOydfvgwauxuJUE4eDpaMWupqquMYsYLB5f+vVGhdZbbzfc6DTQ2rY
                       dknWoMoArlG7MvRMA/xQ0ye1muTv+mYMipnd7Z+WH0uVArYI9QBpqC/gpZRRIouQ4VIQIVWGoT6M4Kat5ZBXEa9yP+9du
                       D2C05GX3gumoSAVyAcDHn/xgej9pYRXGha4l+LKkFdGwAoXdV1z79EG1+9ns7wXuqMJFHM2KDpxAizV0GkZcojISvDwuh
                       vEAFdOJcqjyyH4FOGYa8usP1 <EMAIL>",
    }

Manage key in instance
----------------------

Authenticated user with project administrator role or with staff privilege (is_staff=True) during instance creation
should link instance to user's SSH public key. Example of valid request:

.. code-block:: http

    POST /api/instances/ HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Authorization: Token c84d653b9ec92c6cbac41c706593e66f567a7fa4
    Host: example.com

    {
        "hostname": "test VM",
        "template": "http://example.com/api/iaas-templates/1ee385bc043249498cfeb8c7e3e079f0/",
        "flavor": "http://example.com/api/flavors/c3c546b92845431188636d8f97df223c/",
        "project": "http://example.com/api/projects/661ee58978d9487c8ac26c56836585e0/",
        "ssh_public_key": "http://example.com/api/keys/<KEY>/",
    }

Authenticated user can see public key in instance that belong to a project where a user has a role.

Example of a valid request:

.. code-block:: http

    GET /api/instances/cc37a3de4b85450cab3b2190d965c82f/ HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Authorization: Token c84d653b9ec92c6cbac41c706593e66f567a7fa4
    Host: example.com

Example of a valid response:

.. code-block:: http

    HTTP/1.0 200 OK
    Allow: GET, POST, HEAD, OPTIONS
    Content-Type: application/json
    X-Result-Count: 2

    {
        "hostname": "test VM",
        "ssh_public_key": "http://example.com/api/keys/e49f536565e646f9a4a6b2dbd57fad37/",
        "ssh_public_key_name": "ssh_public_key1",
    }<commit_msg>Replace sample response with all data<commit_after>Key list
--------

To get a list of SSH keys, run GET against */api/keys/* as authenticated user.
Note that user can see only keys that he owns.

- Keys are injected to instances during creation. The owner of the key can log in to that instance.
- Project administrators can select what key will be injected to instance during instance provisioning.

Create a new key
----------------

A new SSH key can be created by any active users. Example of a valid request:

.. code-block:: http

    POST /api/keys/ HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Authorization: Token <PASSWORD>
    Host: example.com

    {
        "name": "ssh_public_key1",
        "public_key": "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDDURXDP5YhOQUYoDuTxJ84DuzqMJYJqJ8+SZT28
                       TtLm5yBDRLKAERqtlbH2gkrQ3US58gd2r8H9jAmQOydfvgwauxuJUE4eDpaMWupqquMYsYLB5f+vVGhdZbbzfc6DTQ2rY
                       dknWoMoArlG7MvRMA/xQ0ye1muTv+mYMipnd7Z+WH0uVArYI9QBpqC/gpZRRIouQ4VIQIVWGoT6M4Kat5ZBXEa9yP+9du
                       D2C05GX3gumoSAVyAcDHn/xgej9pYRXGha4l+LKkFdGwAoXdV1z79EG1+9ns7wXuqMJFHM2KDpxAizV0GkZcojISvDwuh
                       vEAFdOJcqjyyH4FOGYa8usP1 <EMAIL>",
    }

Manage key in instance
----------------------

Authenticated user with project administrator role or with staff privilege (is_staff=True) during instance creation
should link instance to user's SSH public key. Example of valid request:

.. code-block:: http

    POST /api/instances/ HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Authorization: Token <PASSWORD>6<PASSWORD>
    Host: example.com

    {
        "hostname": "test VM",
        "template": "http://example.com/api/iaas-templates/1ee385bc043249498cfeb8c7e3e079f0/",
        "flavor": "http://example.com/api/flavors/c3c546b92845431188636d8f97df223c/",
        "project": "http://example.com/api/projects/661ee58978d9487c8ac26c56836585e0/",
        "ssh_public_key": "http://example.com/api/keys/6fbd6b24246f4fb38715c29bafa2e5e7/",
    }

Authenticated user can see public key in instance that belong to a project where a user has a role.

Example of a valid request:

.. code-block:: http

    GET /api/instances/cc37a3de4b85450cab3b2190d965c82f/ HTTP/1.1
    Content-Type: application/json
    Accept: application/json
    Authorization: Token <PASSWORD>
    Host: example.com

Example of a valid response:

.. code-block:: http

    HTTP/1.0 200 OK
    Allow: GET, POST, HEAD, OPTIONS
    Content-Type: application/json
    X-Result-Count: 2

    {
        "url": "http://127.0.0.1:8000/api/instances/2751a59a41834b079936bc2142ddb22f/",
        "uuid": "2751a59a41834b079936bc2142ddb22f",
        "hostname": "test VM",
        "description": "description1",
        "start_time": "2014-10-22T08:12:55.028Z",
        "template": "http://127.0.0.1:8000/api/iaas-templates/7826f6ab0e32490b9f408de41bab2458/",
        "template_name": "template11",
        "cloud": "http://127.0.0.1:8000/api/clouds/861d830b42fa412f93e7c3f94a29ed6b/",
        "cloud_name": "cloud1",
        "flavor": "http://127.0.0.1:8000/api/flavors/c7d3f71b3b6241c7a115b0c44c1defcb/",
        "flavor_name": "flavor1",
        "project": "http://127.0.0.1:8000/api/projects/5571948e218949bb9474fb868c366e8c/",
        "project_name": "Project1",
        "customer": "http://127.0.0.1:8000/api/customers/4648d37d23ca434bb8cb88b6defc3d20/",
        "customer_name": "Customer1",
        "ssh_public_key": "http://example.com/api/keys/e49f536565e646f9a4a6b2dbd57fad37/",
        "ssh_public_key_name": "ssh_public_key1",
        "project_groups": [],
        "security_groups": [],
        "ips": [
        "172.16.17.32",
        "172.16.58.3",
        "192.168.3.11"
        ],
        "state": "Provisioning Scheduled",
        "backups": [],
        "backup_schedules": []
    }
{'fraction_non_alphanumeric': 0.1118421052631579, 'fraction_numerical': 0.10272129186602871, 'mean_word_length': 3.0441354292623943, 'pattern_counts': {'":': 40, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 9, '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': '3343857', 'n_tokens_mistral': 2931, 'n_tokens_neox': 2549, 'n_words': 486}