|
| 1 | +# Structurizr for Python |
| 2 | + |
| 3 | +A Python client package for the [Structurizr](https://structurizr.com/) cloud |
| 4 | +service and on-premises installation. |
| 5 | + |
| 6 | +## Installation |
| 7 | + |
| 8 | +For the moment, the main installation method is from PyPI, for example, using |
| 9 | +`pip`. |
| 10 | + |
| 11 | +``` |
| 12 | +pip install structurizr-python |
| 13 | +``` |
| 14 | + |
| 15 | +## Getting Started |
| 16 | + |
| 17 | +There are two starting points. Either you have no Structurizr workspace or you |
| 18 | +have an existing workspace that you want to modify locally. |
| 19 | + |
| 20 | +1. If you don't have a workspace yet, you can sign up for one at |
| 21 | + [Structurizr](https://structurizr.com/help/getting-started). Once you have a |
| 22 | + workspace, take note of its ID, API key, and secret. In order to get started |
| 23 | + with creating a new workspace, take a look at [the |
| 24 | + examples](https://github.com/Midnighter/structurizr-python/tree/devel/examples). |
| 25 | + In particular the |
| 26 | + [getting-started](https://github.com/Midnighter/structurizr-python/blob/devel/examples/getting_started.py) |
| 27 | + script will be suitable. |
| 28 | + |
| 29 | + The `#!python main()` function in each example script creates a more or less involved |
| 30 | + workspace for you. When you have created a workspace, it is time to upload |
| 31 | + it so that you can create diagrams for it. You will need to create a |
| 32 | + `#!python StructurizrClient` instance and its settings. The settings can be provided |
| 33 | + as arguments, be read from environment variables, or be provided in a `.env` |
| 34 | + file. |
| 35 | + |
| 36 | + ```python |
| 37 | + from structurizr import StructurizrClient, StructurizrClientSettings |
| 38 | + |
| 39 | + workspace = main() |
| 40 | + settings = StructurizrClientSettings( |
| 41 | + workspace_id=1234, |
| 42 | + api_key='your api key', |
| 43 | + api_secret='your api secret', |
| 44 | + ) |
| 45 | + client = StructurizrClient(settings=settings) |
| 46 | + client.put_workspace(workspace) |
| 47 | + ``` |
| 48 | + |
| 49 | + The example should now be available in your online workspace. |
| 50 | + |
| 51 | +2. In case you already have a comprehensive workspace online, the Python client |
| 52 | + can help with creating local copies and modifying it. |
| 53 | + |
| 54 | + ```python |
| 55 | + from structurizr import StructurizrClient, StructurizrClientSettings |
| 56 | + |
| 57 | + settings = StructurizrClientSettings( |
| 58 | + workspace_id=1234, |
| 59 | + api_key='your api key', |
| 60 | + api_secret='your api secret', |
| 61 | + ) |
| 62 | + client = StructurizrClient(settings=settings) |
| 63 | + workspace = client.get_workspace() |
| 64 | + ``` |
| 65 | + |
| 66 | + You can then modify the workspace as you please and upload your new version |
| 67 | + as shown above. |
| 68 | + |
| 69 | +## Copyright |
| 70 | + |
| 71 | +* Copyright © 2020, Moritz E. Beber. |
| 72 | +* Free software distributed under the [Apache Software License |
| 73 | + 2.0](https://www.apache.org/licenses/LICENSE-2.0). |
0 commit comments