spacelift


Namespacelift JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://github.com/wrgeorge1983/spacelift
Summarysimple python client for the spacelift.io GraphQL API
upload_time2024-03-13 18:42:36
maintainer
docs_urlNone
authorWill George
requires_python>=3.11,<4.0
licenseApache-2.0
keywords spacelift spacelift.io api graphql
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Spacelift Client
Simple client library for working with the [spacelift.io](https://spacelift.io) API.

## Essential features:
- Read operations for Spaces, Contexts, Stacks, and Blueprints
- Create operations for Spaces, Contexts, and Stacks (from Blueprints)
- Trigger a run for a Stack

## Install
```bash
pip install spacelift
```

## Usage
```python
from spacelift import Spacelift


def main():
    sl = Spacelift(
        base_url="https://ORGNAME.app.spacelift.io/graphql",
        key_id="01HCJMP<API_KEY_ID ~26CHAR LONG>",
        key_secret="e355ae6fd5<API_KEY_SECRET ~64 CHAR LONG>"
    )
    result = sl.get_stacks()
    print(result)

    result = sl.get_stacks(query_fields=["id", "name", "branch", "namespace", "repository", "state"])
    print(result)


if __name__ == "__main__":
    main()
```
```shell
$ python main.py
[{'id': 'demo-stack', 'space': 'legacy'}]
[{'id': 'demo-stack', 'name': 'Demo stack', 'branch': 'showcase', 'namespace': 'spacelift-io', 'repository': 'onboarding', 'state': 'FINISHED'}]
$ 
```
#### Relevant Methods
```python
from spacelift import Spacelift
sl = Spacelift()
sl.get_stacks()
sl.get_stack_by_id(stack_id)
sl.get_spaces()
sl.get_space_by_id(space_id)
sl.get_contexts()
sl.get_context_by_id(context_id)
sl.get_blueprints()
sl.get_blueprint_by_id(blueprint_id)

sl.create_stack_from_blueprint(blueprint_id, inputs=[{'id': 'bp_var1', 'value': 'bp_var1_value'}])

sl.trigger_run(stack_id)
```
### Environment Variables
the `Spacelift` object can also infer its parameters from the following environment variables:

```bash
SPACELIFT_BASE_URL="https://ORGNAME.app.spacelift.io/graphql"
SPACELIFT_KEY_ID="01HCJMP<API_KEY_ID ~26CHAR LONG>"
SPACELIFT_KEY_SECRET="e355ae6fd5<API_KEY_SECRET ~64 CHAR LONG>"
```

### API Keys
Currently, this depends on the API Key workflow [here](https://docs.spacelift.io/integrations/api#spacelift-api-key-token).
The Current Spacelift.io documentation doesn't clearly specify this, but the API Key ID is the 26 character code that 
appears after the name in the web UI.  It does not appear at all in the downloaded `.config` file.  

The required Secret value is the first code (64 characters long) that appears in the downloaded `.config` file.

### Raw GraphQL
The `Spacelift` object also has a `_execute` method that accepts a raw GraphQL query object.  This can be created by 
sending a valid GraphQL query string to `gql.gql()` from the [gql package](https://pypi.org/project/gql/).  This is 
necessary for more advanced queries.

### Mocked Version
There's also a mocked version `MockedSpacelift` that can be used for testing.  It offers mocked versions of all the 
CRUD methods without any real API calls.

## Development

### Publishing
```bash
poetry build
poetry publish
```
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/wrgeorge1983/spacelift",
    "name": "spacelift",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.11,<4.0",
    "maintainer_email": "",
    "keywords": "spacelift,spacelift.io,api,graphql",
    "author": "Will George",
    "author_email": "wrgeorge1983@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/0c/6b/3bbe826e12daa4a41342db885077157e8c150a2a69def35877bc32ec57fa/spacelift-1.1.2.tar.gz",
    "platform": null,
    "description": "# Spacelift Client\nSimple client library for working with the [spacelift.io](https://spacelift.io) API.\n\n## Essential features:\n- Read operations for Spaces, Contexts, Stacks, and Blueprints\n- Create operations for Spaces, Contexts, and Stacks (from Blueprints)\n- Trigger a run for a Stack\n\n## Install\n```bash\npip install spacelift\n```\n\n## Usage\n```python\nfrom spacelift import Spacelift\n\n\ndef main():\n    sl = Spacelift(\n        base_url=\"https://ORGNAME.app.spacelift.io/graphql\",\n        key_id=\"01HCJMP<API_KEY_ID ~26CHAR LONG>\",\n        key_secret=\"e355ae6fd5<API_KEY_SECRET ~64 CHAR LONG>\"\n    )\n    result = sl.get_stacks()\n    print(result)\n\n    result = sl.get_stacks(query_fields=[\"id\", \"name\", \"branch\", \"namespace\", \"repository\", \"state\"])\n    print(result)\n\n\nif __name__ == \"__main__\":\n    main()\n```\n```shell\n$ python main.py\n[{'id': 'demo-stack', 'space': 'legacy'}]\n[{'id': 'demo-stack', 'name': 'Demo stack', 'branch': 'showcase', 'namespace': 'spacelift-io', 'repository': 'onboarding', 'state': 'FINISHED'}]\n$ \n```\n#### Relevant Methods\n```python\nfrom spacelift import Spacelift\nsl = Spacelift()\nsl.get_stacks()\nsl.get_stack_by_id(stack_id)\nsl.get_spaces()\nsl.get_space_by_id(space_id)\nsl.get_contexts()\nsl.get_context_by_id(context_id)\nsl.get_blueprints()\nsl.get_blueprint_by_id(blueprint_id)\n\nsl.create_stack_from_blueprint(blueprint_id, inputs=[{'id': 'bp_var1', 'value': 'bp_var1_value'}])\n\nsl.trigger_run(stack_id)\n```\n### Environment Variables\nthe `Spacelift` object can also infer its parameters from the following environment variables:\n\n```bash\nSPACELIFT_BASE_URL=\"https://ORGNAME.app.spacelift.io/graphql\"\nSPACELIFT_KEY_ID=\"01HCJMP<API_KEY_ID ~26CHAR LONG>\"\nSPACELIFT_KEY_SECRET=\"e355ae6fd5<API_KEY_SECRET ~64 CHAR LONG>\"\n```\n\n### API Keys\nCurrently, this depends on the API Key workflow [here](https://docs.spacelift.io/integrations/api#spacelift-api-key-token).\nThe Current Spacelift.io documentation doesn't clearly specify this, but the API Key ID is the 26 character code that \nappears after the name in the web UI.  It does not appear at all in the downloaded `.config` file.  \n\nThe required Secret value is the first code (64 characters long) that appears in the downloaded `.config` file.\n\n### Raw GraphQL\nThe `Spacelift` object also has a `_execute` method that accepts a raw GraphQL query object.  This can be created by \nsending a valid GraphQL query string to `gql.gql()` from the [gql package](https://pypi.org/project/gql/).  This is \nnecessary for more advanced queries.\n\n### Mocked Version\nThere's also a mocked version `MockedSpacelift` that can be used for testing.  It offers mocked versions of all the \nCRUD methods without any real API calls.\n\n## Development\n\n### Publishing\n```bash\npoetry build\npoetry publish\n```",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "simple python client for the spacelift.io GraphQL API",
    "version": "1.1.2",
    "project_urls": {
        "Homepage": "https://github.com/wrgeorge1983/spacelift",
        "Repository": "https://github.com/wrgeorge1983/spacelift"
    },
    "split_keywords": [
        "spacelift",
        "spacelift.io",
        "api",
        "graphql"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "eaaefe5ceb248b769eb61d572fa9ebb646f131363728efd16124f7d116e72c27",
                "md5": "8412230fb21cf8f913fcca48f6300f24",
                "sha256": "2bd1b49e2f1d101990ac0fddb788a6dd147612a33206c16ca84310f2730a8e4e"
            },
            "downloads": -1,
            "filename": "spacelift-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "8412230fb21cf8f913fcca48f6300f24",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.11,<4.0",
            "size": 11429,
            "upload_time": "2024-03-13T18:42:35",
            "upload_time_iso_8601": "2024-03-13T18:42:35.349159Z",
            "url": "https://files.pythonhosted.org/packages/ea/ae/fe5ceb248b769eb61d572fa9ebb646f131363728efd16124f7d116e72c27/spacelift-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0c6b3bbe826e12daa4a41342db885077157e8c150a2a69def35877bc32ec57fa",
                "md5": "71c8e469982de82ebb9a5db37ad28527",
                "sha256": "39b2675f2d75e82209a754b60205c4f1091f6103c16b2b56e61ed8ca41d5b5bd"
            },
            "downloads": -1,
            "filename": "spacelift-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "71c8e469982de82ebb9a5db37ad28527",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.11,<4.0",
            "size": 11177,
            "upload_time": "2024-03-13T18:42:36",
            "upload_time_iso_8601": "2024-03-13T18:42:36.357292Z",
            "url": "https://files.pythonhosted.org/packages/0c/6b/3bbe826e12daa4a41342db885077157e8c150a2a69def35877bc32ec57fa/spacelift-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-13 18:42:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "wrgeorge1983",
    "github_project": "spacelift",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "spacelift"
}
        
Elapsed time: 0.21523s