wflow-cli 0.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
wflow_cli/__init__.py ADDED
@@ -0,0 +1,3 @@
1
+ from importlib.metadata import version
2
+
3
+ __version__ = version("wflow-cli")
wflow_cli/commands.py ADDED
@@ -0,0 +1,243 @@
1
+ """One command per wflow_api operation, generated from its signature and docstring."""
2
+
3
+ import asyncio
4
+ import inspect
5
+ import re
6
+ from collections.abc import Awaitable, Callable, Coroutine
7
+ from pathlib import Path
8
+ from types import UnionType
9
+ from typing import Annotated, Any, Union, cast, get_args, get_origin, get_type_hints
10
+
11
+ import typer
12
+ from pydantic import BaseModel
13
+ from pydantic.fields import FieldInfo
14
+
15
+ from wflow_api import FileContent, WflowApiError, WflowClient, WflowError
16
+ from wflow_api.auth import TOKEN_PATH
17
+ from wflow_api.operations import operations
18
+ from wflow_cli import __version__
19
+ from wflow_cli.credentials import ConfigError
20
+ from wflow_cli.io import STDIN, check_output, print_json, read_json, save_download
21
+
22
+ SIMPLE = (str, int, float, bool)
23
+ KEYWORD = inspect.Parameter.KEYWORD_ONLY
24
+ EMPTY = inspect.Parameter.empty
25
+ SIZE_LIMIT = "max_bytes"
26
+ DOWNLOAD_HELP = (
27
+ "Writes the bytes to `--output` and prints their filename, contentType, sizeBytes and path as JSON; "
28
+ "`--output -` writes only the bytes to stdout."
29
+ )
30
+
31
+ MakeClient = Callable[[], WflowClient]
32
+ Operation = Callable[..., Awaitable[Any]]
33
+
34
+
35
+ def command_name(name: str) -> str:
36
+ return name.replace("_", "-")
37
+
38
+
39
+ def option_name(name: str) -> str:
40
+ return "--" + re.sub(r"(?<=[a-z0-9])(?=[A-Z])", "-", name).replace("_", "-").lower()
41
+
42
+
43
+ def explain(error: WflowError) -> str:
44
+ message = str(error)
45
+ if isinstance(error, WflowApiError) and (error.status == 401 or error.path == TOKEN_PATH):
46
+ return f"{message} Check WFLOW_CLIENT_ID and WFLOW_CLIENT_SECRET."
47
+ if isinstance(error, WflowApiError) and error.status == 403:
48
+ return f"{message} Is this API client allowed in the workspace? Settings → Integrations → API accesses."
49
+ return message
50
+
51
+
52
+ def _one_line(message: str) -> str:
53
+ return "; ".join(line.strip() for line in message.splitlines() if line.strip())
54
+
55
+
56
+ def _described(annotation: Any) -> tuple[Any, str | None]:
57
+ if get_origin(annotation) is not Annotated:
58
+ return annotation, None
59
+ base, *metadata = get_args(annotation)
60
+ descriptions = [item.description for item in metadata if isinstance(item, FieldInfo) and item.description]
61
+ return base, descriptions[-1] if descriptions else None
62
+
63
+
64
+ def _bare(annotation: Any) -> Any:
65
+ if get_origin(annotation) in (Union, UnionType):
66
+ rest = [arg for arg in get_args(annotation) if arg is not type(None)]
67
+ if len(rest) == 1:
68
+ return rest[0]
69
+ return annotation
70
+
71
+
72
+ def _json_help(bare: Any, description: str | None) -> str:
73
+ many = get_origin(bare) is list
74
+ item = get_args(bare)[0] if many and get_args(bare) else bare
75
+ if isinstance(item, type) and issubclass(item, BaseModel):
76
+ fields = ", ".join(info.alias or name for name, info in item.model_fields.items())
77
+ shape = f"A JSON {'list of objects' if many else 'object'} with fields: {fields}."
78
+ else:
79
+ shape = "A JSON list." if many else "A JSON value."
80
+ lead = f"{description.rstrip('.')}. " if description else ""
81
+ return f"{lead}{shape} Inline JSON, @file.json, or - for stdin."
82
+
83
+
84
+ def _annotated(base: Any, option: Any) -> Any:
85
+ return cast(Any, Annotated)[base, option]
86
+
87
+
88
+ def _option(name: str, bare: Any, description: str | None) -> Any:
89
+ if name == "organization":
90
+ return typer.Option("--organization", "-o", help=description, envvar="WFLOW_ORGANIZATION")
91
+ if name == SIZE_LIMIT:
92
+ return typer.Option(option_name(name), min=0, help="Refuse a file larger than this many bytes.")
93
+ if bare is bool:
94
+ flag = option_name(name)
95
+ return typer.Option(f"{flag}/--no-{flag[2:]}", help=description)
96
+ return typer.Option(option_name(name), help=description)
97
+
98
+
99
+ def _options(fn: Operation) -> tuple[list[inspect.Parameter], dict[str, str]]:
100
+ original = inspect.unwrap(fn)
101
+ hints = get_type_hints(original, include_extras=True)
102
+ uploads = "content" in hints and _bare(_described(hints["content"])[0]) is bytes
103
+ parameters: list[inspect.Parameter] = []
104
+ kinds: dict[str, str] = {}
105
+ for name, parameter in inspect.signature(original).parameters.items():
106
+ if name == "client" or (parameter.kind is KEYWORD and name != SIZE_LIMIT):
107
+ continue
108
+ annotation, description = _described(hints[name])
109
+ bare = _bare(annotation)
110
+ optional = parameter.default is not EMPTY or (uploads and name == "filename")
111
+ default = (None if parameter.default is EMPTY else parameter.default) if optional else EMPTY
112
+ if uploads and name == "content":
113
+ kinds[name] = "file"
114
+ option = typer.Option("--file", help="The file to upload.", exists=True, dir_okay=False, readable=True)
115
+ parameters.append(inspect.Parameter(name, KEYWORD, annotation=_annotated(Path, option)))
116
+ continue
117
+ if bare in SIMPLE:
118
+ kinds[name] = "value"
119
+ option = _option(name, bare, description)
120
+ typed = bare | None if optional else bare
121
+ else:
122
+ kinds[name] = "json"
123
+ option = typer.Option(option_name(name), help=_json_help(bare, description))
124
+ typed = str | None if optional else str
125
+ if uploads and name == "filename":
126
+ option = typer.Option(
127
+ "--filename", help="Name wflow stores the file under; defaults to the file's own name."
128
+ )
129
+ parameters.append(inspect.Parameter(name, KEYWORD, annotation=_annotated(typed, option), default=default))
130
+ if hints.get("return") is FileContent:
131
+ if {"output", "force"} & set(kinds):
132
+ raise RuntimeError(f"{original.__name__} already has a parameter named output or force")
133
+ parameters.append(
134
+ inspect.Parameter(
135
+ "output",
136
+ KEYWORD,
137
+ annotation=_annotated(
138
+ str,
139
+ typer.Option(
140
+ "--output",
141
+ help="File to write, then print its filename, contentType, sizeBytes and path as JSON; "
142
+ "- writes the bytes to stdout instead.",
143
+ ),
144
+ ),
145
+ )
146
+ )
147
+ parameters.append(
148
+ inspect.Parameter(
149
+ "force",
150
+ KEYWORD,
151
+ annotation=_annotated(bool, typer.Option("--force", help="Overwrite an existing file.")),
152
+ default=False,
153
+ )
154
+ )
155
+ return parameters, kinds
156
+
157
+
158
+ def _stdin_readers(kinds: dict[str, str], values: dict[str, Any]) -> list[str]:
159
+ return [name for name, kind in kinds.items() if kind == "json" and values.get(name) == STDIN]
160
+
161
+
162
+ def _arguments(kinds: dict[str, str], values: dict[str, Any]) -> dict[str, Any]:
163
+ arguments: dict[str, Any] = {}
164
+ for name, value in values.items():
165
+ if kinds[name] == "json":
166
+ arguments[name] = None if value is None else read_json(value, option_name(name))
167
+ elif kinds[name] == "file":
168
+ arguments[name] = value.read_bytes()
169
+ else:
170
+ arguments[name] = value
171
+ if "file" in kinds.values() and arguments.get("filename") is None:
172
+ upload = next(name for name, kind in kinds.items() if kind == "file")
173
+ arguments["filename"] = values[upload].name
174
+ return arguments
175
+
176
+
177
+ def _command(fn: Operation, kinds: dict[str, str], make_client: MakeClient) -> Callable[..., None]:
178
+ def run(**values: Any) -> None:
179
+ output = values.pop("output", None)
180
+ force = values.pop("force", False)
181
+ if len(readers := _stdin_readers(kinds, values)) > 1:
182
+ raise typer.BadParameter(
183
+ f"only one option can read stdin, but {', '.join(map(option_name, readers))} all ask for it"
184
+ )
185
+ if output is not None:
186
+ check_output(output, force)
187
+ arguments = _arguments(kinds, values)
188
+ try:
189
+ result = asyncio.run(cast(Coroutine[Any, Any, Any], fn(make_client(), **arguments)))
190
+ except ConfigError as error:
191
+ typer.echo(_one_line(str(error)), err=True)
192
+ raise typer.Exit(2) from None
193
+ except WflowError as error:
194
+ typer.echo(_one_line(explain(error)), err=True)
195
+ raise typer.Exit(1) from None
196
+ if isinstance(result, FileContent):
197
+ save_download(result, output or STDIN, force)
198
+ else:
199
+ print_json(result)
200
+
201
+ return run
202
+
203
+
204
+ def _register(app: typer.Typer, module: str, fn: Operation, make_client: MakeClient) -> None:
205
+ parameters, kinds = _options(fn)
206
+ run: Any = _command(fn, kinds, make_client)
207
+ run.__signature__ = inspect.Signature(parameters)
208
+ run.__annotations__ = {parameter.name: parameter.annotation for parameter in parameters}
209
+ run.__name__ = fn.__name__
210
+ help_text = inspect.getdoc(fn) or ""
211
+ if "output" in {parameter.name for parameter in parameters}:
212
+ help_text = f"{help_text}\n\n{DOWNLOAD_HELP}"
213
+ app.command(name=command_name(fn.__name__), help=help_text, rich_help_panel=module.replace("_", " ").capitalize())(
214
+ run
215
+ )
216
+
217
+
218
+ def _version(value: bool) -> None:
219
+ if value:
220
+ typer.echo(__version__)
221
+ raise typer.Exit()
222
+
223
+
224
+ def build_app(make_client: MakeClient) -> typer.Typer:
225
+ app = typer.Typer(
226
+ name="wflow",
227
+ help="The wflow.com public API from the command line. Set WFLOW_CLIENT_ID and WFLOW_CLIENT_SECRET; "
228
+ "every command prints JSON.",
229
+ no_args_is_help=True,
230
+ rich_markup_mode="markdown",
231
+ )
232
+
233
+ @app.callback()
234
+ def main(
235
+ version: Annotated[
236
+ bool, typer.Option("--version", callback=_version, is_eager=True, help="Print the version and exit.")
237
+ ] = False,
238
+ ) -> None:
239
+ pass
240
+
241
+ for module, fn in operations():
242
+ _register(app, module, fn, make_client)
243
+ return app
@@ -0,0 +1,34 @@
1
+ """The CLI's identity comes from the environment and nowhere else."""
2
+
3
+ import os
4
+ from collections.abc import Mapping
5
+
6
+ from wflow_api import ENVIRONMENTS, ClientCredentials, WflowClient
7
+ from wflow_cli import __version__
8
+
9
+ HEADERS = {"X-Client-Id": "wflowinternal", "X-Integration-Id": "wflow_cli", "X-Integration-Version": __version__}
10
+ REQUIRED = ("WFLOW_CLIENT_ID", "WFLOW_CLIENT_SECRET")
11
+
12
+
13
+ class ConfigError(Exception):
14
+ """The environment does not say how to reach wflow."""
15
+
16
+
17
+ def client_from_env(environ: Mapping[str, str] | None = None) -> WflowClient:
18
+ env = os.environ if environ is None else environ
19
+ values = {name: env.get(name, "").strip() for name in REQUIRED}
20
+ if missing := [name for name, value in values.items() if not value]:
21
+ raise ConfigError(
22
+ f"{' and '.join(missing)} must be set. Create an API client with the client_credentials grant "
23
+ "in admin.wflow.com, then allow it in each workspace under Settings → Integrations → API accesses."
24
+ )
25
+ name = env.get("WFLOW_ENV", "").strip().lower() or "prod"
26
+ if name not in ENVIRONMENTS:
27
+ raise ConfigError(f"WFLOW_ENV={name!r} is not one of: {', '.join(sorted(ENVIRONMENTS))}.")
28
+ api_base, account_base = ENVIRONMENTS[name]
29
+ token = ClientCredentials(
30
+ values["WFLOW_CLIENT_ID"],
31
+ values["WFLOW_CLIENT_SECRET"],
32
+ env.get("WFLOW_ACCOUNT_BASE", "").strip() or account_base,
33
+ )
34
+ return WflowClient(token, api_base=env.get("WFLOW_API_BASE", "").strip() or api_base, headers=HEADERS)
wflow_cli/io.py ADDED
@@ -0,0 +1,77 @@
1
+ """JSON arguments in; JSON results and downloaded files out."""
2
+
3
+ import json
4
+ import os
5
+ import sys
6
+ from pathlib import Path
7
+ from typing import Any
8
+
9
+ import typer
10
+ from pydantic_core import to_json
11
+
12
+ from wflow_api import FileContent
13
+
14
+ STDIN = "-"
15
+
16
+
17
+ def read_json(text: str, option: str) -> Any:
18
+ if text == STDIN:
19
+ raw: bytes | str = sys.stdin.buffer.read()
20
+ elif text.startswith("@"):
21
+ path = Path(text[1:]).expanduser()
22
+ try:
23
+ raw = path.read_bytes()
24
+ except OSError as error:
25
+ raise typer.BadParameter(f"cannot read {path}: {error.strerror or error}", param_hint=option) from None
26
+ else:
27
+ raw = text
28
+ try:
29
+ return json.loads(raw.encode() if isinstance(raw, str) else raw)
30
+ except json.JSONDecodeError as error:
31
+ raise typer.BadParameter(
32
+ f"not valid JSON ({error.msg} at line {error.lineno} column {error.colno})", param_hint=option
33
+ ) from None
34
+ except UnicodeError:
35
+ raise typer.BadParameter("not UTF-8 text; save it as UTF-8 and try again", param_hint=option) from None
36
+
37
+
38
+ def print_json(value: Any) -> None:
39
+ sys.stdout.buffer.write(to_json(value, indent=2) + b"\n")
40
+ sys.stdout.buffer.flush()
41
+
42
+
43
+ def check_output(output: str, force: bool) -> None:
44
+ if output == STDIN:
45
+ return
46
+ path = Path(output)
47
+ if path.is_dir():
48
+ raise typer.BadParameter(f"{path} is a directory; name the file to write", param_hint="--output")
49
+ if not path.parent.is_dir():
50
+ raise typer.BadParameter(f"{path.parent} does not exist", param_hint="--output")
51
+ if path.exists() or path.is_symlink():
52
+ if not force:
53
+ raise typer.BadParameter(f"{path} already exists; pass --force to overwrite it", param_hint="--output")
54
+ if path.exists() and not os.access(path, os.W_OK):
55
+ raise typer.BadParameter(f"cannot write {path}: permission denied", param_hint="--output")
56
+ elif not os.access(path.parent, os.W_OK):
57
+ raise typer.BadParameter(f"cannot write {path}: {path.parent} is not writable", param_hint="--output")
58
+
59
+
60
+ def save_download(file: FileContent, output: str, force: bool) -> None:
61
+ if output == STDIN:
62
+ sys.stdout.buffer.write(file.content)
63
+ sys.stdout.buffer.flush()
64
+ return
65
+ path = Path(output)
66
+ try:
67
+ with path.open("wb" if force else "xb") as target:
68
+ target.write(file.content)
69
+ except FileExistsError:
70
+ raise typer.BadParameter(
71
+ f"{path} already exists; pass --force to overwrite it", param_hint="--output"
72
+ ) from None
73
+ except OSError as error:
74
+ raise typer.BadParameter(f"cannot write {path}: {error.strerror or error}", param_hint="--output") from None
75
+ print_json(
76
+ {"filename": file.filename, "contentType": file.content_type, "sizeBytes": len(file.content), "path": str(path)}
77
+ )
wflow_cli/main.py ADDED
@@ -0,0 +1,4 @@
1
+ from wflow_cli.commands import build_app
2
+ from wflow_cli.credentials import client_from_env
3
+
4
+ app = build_app(client_from_env)
wflow_cli/py.typed ADDED
File without changes
@@ -0,0 +1,116 @@
1
+ Metadata-Version: 2.4
2
+ Name: wflow-cli
3
+ Version: 0.1.0
4
+ Summary: Command-line client for the wflow.com public API
5
+ Keywords: wflow,cli,api,documents,approval
6
+ Author: wflow.com
7
+ License-Expression: Apache-2.0
8
+ License-File: LICENSE
9
+ Classifier: Environment :: Console
10
+ Classifier: Intended Audience :: Developers
11
+ Classifier: Operating System :: OS Independent
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: Programming Language :: Python :: 3.12
14
+ Classifier: Programming Language :: Python :: 3.13
15
+ Classifier: Programming Language :: Python :: 3.14
16
+ Requires-Dist: wflow-api==0.1.0
17
+ Requires-Dist: typer~=0.27.3
18
+ Requires-Python: >=3.12
19
+ Project-URL: Homepage, https://www.wflow.com
20
+ Project-URL: Documentation, https://developers.wflow.com
21
+ Description-Content-Type: text/markdown
22
+
23
+ # wflow CLI
24
+
25
+ The [wflow.com](https://www.wflow.com) public API from the command line. Every API operation is one
26
+ command, every command prints JSON (except a download to `--output -`, which writes the file's raw bytes to
27
+ stdout), and `wflow <command> --help` documents what it sends and returns.
28
+
29
+ ## Install
30
+
31
+ ```bash
32
+ pipx install wflow-cli # or: uv tool install wflow-cli or: pip install wflow-cli
33
+ wflow --version
34
+ ```
35
+
36
+ Python 3.12 or newer. `pipx` and `uv tool` keep the CLI in its own environment.
37
+
38
+ ## Set up an API client
39
+
40
+ The CLI signs in as an API client with the `client_credentials` grant — a machine identity, not a person.
41
+
42
+ 1. Create an API client with the `client_credentials` grant in [admin.wflow.com](https://admin.wflow.com).
43
+ 2. Allow the client in each workspace it should reach: in the workspace, **Settings → Integrations → API accesses**.
44
+ 3. Give the CLI the credentials:
45
+
46
+ ```bash
47
+ export WFLOW_CLIENT_ID="your-full-client-id"
48
+ export WFLOW_CLIENT_SECRET="your-client-secret"
49
+ export WFLOW_ORGANIZATION="your-workspace" # optional: the default for --organization/-o
50
+ ```
51
+
52
+ | Variable | Meaning |
53
+ |---|---|
54
+ | `WFLOW_CLIENT_ID`, `WFLOW_CLIENT_SECRET` | required |
55
+ | `WFLOW_ENV` | `prod` (default) or `test` |
56
+ | `WFLOW_ORGANIZATION` | default workspace slug for `-o` |
57
+ | `WFLOW_API_BASE`, `WFLOW_ACCOUNT_BASE` | override the API and identity hosts |
58
+
59
+ Credentials are read from the environment only; no option takes a secret.
60
+
61
+ ## Use it
62
+
63
+ ```bash
64
+ wflow --help # every command, grouped by area
65
+ wflow get-organization -o acme
66
+ wflow list-register-partners -o acme --page-size 50 --query 'name = "Acme s.r.o."'
67
+ wflow list-documents -o acme --sort "created desc"
68
+ ```
69
+
70
+ A list command that takes `--page` and `--page-size` returns one page: `{items, totalItems, pageSize, page}`.
71
+ Compare `totalItems` with what you have before assuming you have everything.
72
+
73
+ ### Writing
74
+
75
+ Options that take a record or a list of records take JSON — inline, from a file with `@`, or from stdin with `-`
76
+ (one option per command can read stdin):
77
+
78
+ ```bash
79
+ wflow patch-register-partners -o acme --partners @partners.json
80
+ cat partners.json | wflow patch-register-partners -o acme --partners -
81
+ ```
82
+
83
+ `update-register-*` replaces the whole register: every record you leave out is retired. `patch-register-*` leaves
84
+ the records you do not send alone. Both replace each record you send as a whole, so send the full record. wflow
85
+ keeps no version history — read `wflow <command> --help` before writing.
86
+
87
+ ### Files
88
+
89
+ ```bash
90
+ wflow upload-document-file -o acme --document-id <id> --file ./invoice.pdf
91
+ wflow download-document-file -o acme --file-id <id> --output ./invoice.pdf
92
+ wflow download-document-file -o acme --file-id <id> --output - > invoice.pdf
93
+ ```
94
+
95
+ An upload is stored under the file's own name unless you pass `--filename`. A download never overwrites an
96
+ existing file unless you pass `--force`.
97
+
98
+ ## Exit codes
99
+
100
+ | Code | Meaning |
101
+ |---|---|
102
+ | `0` | success; the result is on stdout as JSON, or the file's raw bytes for a download with `--output -` |
103
+ | `1` | wflow refused or failed the call, or the input was refused before anything was sent; one line on stderr says why |
104
+ | `2` | the command line or the environment is wrong; stderr has a usage message or says what to set |
105
+
106
+ ## For AI agents
107
+
108
+ Every command prints its result as JSON on stdout and the reason for a failure on stderr, so an agent can run
109
+ `wflow` from a shell, check the exit code and parse the result. The one exception is a download with `--output -`,
110
+ which writes the file's raw bytes to stdout instead. `wflow <command> --help` is the documentation for
111
+ that command.
112
+
113
+ ## Python
114
+
115
+ The commands are generated from the [`wflow-api`](https://pypi.org/project/wflow-api/) package, which you can use
116
+ directly.
@@ -0,0 +1,11 @@
1
+ wflow_cli/__init__.py,sha256=40pT_yZ5ELdWqtYGE_KVDYpAxSIlH2ALfp1wOBRzO_Y,75
2
+ wflow_cli/commands.py,sha256=UwSS1MCXXBp-l7GND86wporR8a2j-kdia3gN2spqjNU,9793
3
+ wflow_cli/credentials.py,sha256=IthWhtuLHBYyWJgh9IpfS2zqU2uVurIV0qhtrWmw8dY,1541
4
+ wflow_cli/io.py,sha256=MLFOd69comkGVDvrPq1mpgF8sJC2VRpcFicHsl7v4go,2868
5
+ wflow_cli/main.py,sha256=5v03SCmvKXKKn3GL5Eq1i5eGTpnRVdayZ6nWTfQwvuY,125
6
+ wflow_cli/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
7
+ wflow_cli-0.1.0.dist-info/licenses/LICENSE,sha256=z8d0m5b2O9McPEK1xHG_dWgUBT6EfBDz6wA0F7xSPTA,11358
8
+ wflow_cli-0.1.0.dist-info/WHEEL,sha256=hbX8mDThv1n7VEIpQRy6c2yAFTw4iAQlEC53gDAhHSo,80
9
+ wflow_cli-0.1.0.dist-info/entry_points.txt,sha256=KmW1Jd1PF9zqa8KFVxRQuSn0gpqEbzEg7RphBZwowek,46
10
+ wflow_cli-0.1.0.dist-info/METADATA,sha256=3lcZbUeS8TFbvRwMl40w6OwBvmagJRd2iqin9DFitOc,4596
11
+ wflow_cli-0.1.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: uv 0.10.6
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,3 @@
1
+ [console_scripts]
2
+ wflow = wflow_cli.main:app
3
+
@@ -0,0 +1,202 @@
1
+
2
+ Apache License
3
+ Version 2.0, January 2004
4
+ http://www.apache.org/licenses/
5
+
6
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
7
+
8
+ 1. Definitions.
9
+
10
+ "License" shall mean the terms and conditions for use, reproduction,
11
+ and distribution as defined by Sections 1 through 9 of this document.
12
+
13
+ "Licensor" shall mean the copyright owner or entity authorized by
14
+ the copyright owner that is granting the License.
15
+
16
+ "Legal Entity" shall mean the union of the acting entity and all
17
+ other entities that control, are controlled by, or are under common
18
+ control with that entity. For the purposes of this definition,
19
+ "control" means (i) the power, direct or indirect, to cause the
20
+ direction or management of such entity, whether by contract or
21
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
22
+ outstanding shares, or (iii) beneficial ownership of such entity.
23
+
24
+ "You" (or "Your") shall mean an individual or Legal Entity
25
+ exercising permissions granted by this License.
26
+
27
+ "Source" form shall mean the preferred form for making modifications,
28
+ including but not limited to software source code, documentation
29
+ source, and configuration files.
30
+
31
+ "Object" form shall mean any form resulting from mechanical
32
+ transformation or translation of a Source form, including but
33
+ not limited to compiled object code, generated documentation,
34
+ and conversions to other media types.
35
+
36
+ "Work" shall mean the work of authorship, whether in Source or
37
+ Object form, made available under the License, as indicated by a
38
+ copyright notice that is included in or attached to the work
39
+ (an example is provided in the Appendix below).
40
+
41
+ "Derivative Works" shall mean any work, whether in Source or Object
42
+ form, that is based on (or derived from) the Work and for which the
43
+ editorial revisions, annotations, elaborations, or other modifications
44
+ represent, as a whole, an original work of authorship. For the purposes
45
+ of this License, Derivative Works shall not include works that remain
46
+ separable from, or merely link (or bind by name) to the interfaces of,
47
+ the Work and Derivative Works thereof.
48
+
49
+ "Contribution" shall mean any work of authorship, including
50
+ the original version of the Work and any modifications or additions
51
+ to that Work or Derivative Works thereof, that is intentionally
52
+ submitted to Licensor for inclusion in the Work by the copyright owner
53
+ or by an individual or Legal Entity authorized to submit on behalf of
54
+ the copyright owner. For the purposes of this definition, "submitted"
55
+ means any form of electronic, verbal, or written communication sent
56
+ to the Licensor or its representatives, including but not limited to
57
+ communication on electronic mailing lists, source code control systems,
58
+ and issue tracking systems that are managed by, or on behalf of, the
59
+ Licensor for the purpose of discussing and improving the Work, but
60
+ excluding communication that is conspicuously marked or otherwise
61
+ designated in writing by the copyright owner as "Not a Contribution."
62
+
63
+ "Contributor" shall mean Licensor and any individual or Legal Entity
64
+ on behalf of whom a Contribution has been received by Licensor and
65
+ subsequently incorporated within the Work.
66
+
67
+ 2. Grant of Copyright License. Subject to the terms and conditions of
68
+ this License, each Contributor hereby grants to You a perpetual,
69
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
70
+ copyright license to reproduce, prepare Derivative Works of,
71
+ publicly display, publicly perform, sublicense, and distribute the
72
+ Work and such Derivative Works in Source or Object form.
73
+
74
+ 3. Grant of Patent License. Subject to the terms and conditions of
75
+ this License, each Contributor hereby grants to You a perpetual,
76
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
77
+ (except as stated in this section) patent license to make, have made,
78
+ use, offer to sell, sell, import, and otherwise transfer the Work,
79
+ where such license applies only to those patent claims licensable
80
+ by such Contributor that are necessarily infringed by their
81
+ Contribution(s) alone or by combination of their Contribution(s)
82
+ with the Work to which such Contribution(s) was submitted. If You
83
+ institute patent litigation against any entity (including a
84
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
85
+ or a Contribution incorporated within the Work constitutes direct
86
+ or contributory patent infringement, then any patent licenses
87
+ granted to You under this License for that Work shall terminate
88
+ as of the date such litigation is filed.
89
+
90
+ 4. Redistribution. You may reproduce and distribute copies of the
91
+ Work or Derivative Works thereof in any medium, with or without
92
+ modifications, and in Source or Object form, provided that You
93
+ meet the following conditions:
94
+
95
+ (a) You must give any other recipients of the Work or
96
+ Derivative Works a copy of this License; and
97
+
98
+ (b) You must cause any modified files to carry prominent notices
99
+ stating that You changed the files; and
100
+
101
+ (c) You must retain, in the Source form of any Derivative Works
102
+ that You distribute, all copyright, patent, trademark, and
103
+ attribution notices from the Source form of the Work,
104
+ excluding those notices that do not pertain to any part of
105
+ the Derivative Works; and
106
+
107
+ (d) If the Work includes a "NOTICE" text file as part of its
108
+ distribution, then any Derivative Works that You distribute must
109
+ include a readable copy of the attribution notices contained
110
+ within such NOTICE file, excluding those notices that do not
111
+ pertain to any part of the Derivative Works, in at least one
112
+ of the following places: within a NOTICE text file distributed
113
+ as part of the Derivative Works; within the Source form or
114
+ documentation, if provided along with the Derivative Works; or,
115
+ within a display generated by the Derivative Works, if and
116
+ wherever such third-party notices normally appear. The contents
117
+ of the NOTICE file are for informational purposes only and
118
+ do not modify the License. You may add Your own attribution
119
+ notices within Derivative Works that You distribute, alongside
120
+ or as an addendum to the NOTICE text from the Work, provided
121
+ that such additional attribution notices cannot be construed
122
+ as modifying the License.
123
+
124
+ You may add Your own copyright statement to Your modifications and
125
+ may provide additional or different license terms and conditions
126
+ for use, reproduction, or distribution of Your modifications, or
127
+ for any such Derivative Works as a whole, provided Your use,
128
+ reproduction, and distribution of the Work otherwise complies with
129
+ the conditions stated in this License.
130
+
131
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
132
+ any Contribution intentionally submitted for inclusion in the Work
133
+ by You to the Licensor shall be under the terms and conditions of
134
+ this License, without any additional terms or conditions.
135
+ Notwithstanding the above, nothing herein shall supersede or modify
136
+ the terms of any separate license agreement you may have executed
137
+ with Licensor regarding such Contributions.
138
+
139
+ 6. Trademarks. This License does not grant permission to use the trade
140
+ names, trademarks, service marks, or product names of the Licensor,
141
+ except as required for reasonable and customary use in describing the
142
+ origin of the Work and reproducing the content of the NOTICE file.
143
+
144
+ 7. Disclaimer of Warranty. Unless required by applicable law or
145
+ agreed to in writing, Licensor provides the Work (and each
146
+ Contributor provides its Contributions) on an "AS IS" BASIS,
147
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
148
+ implied, including, without limitation, any warranties or conditions
149
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
150
+ PARTICULAR PURPOSE. You are solely responsible for determining the
151
+ appropriateness of using or redistributing the Work and assume any
152
+ risks associated with Your exercise of permissions under this License.
153
+
154
+ 8. Limitation of Liability. In no event and under no legal theory,
155
+ whether in tort (including negligence), contract, or otherwise,
156
+ unless required by applicable law (such as deliberate and grossly
157
+ negligent acts) or agreed to in writing, shall any Contributor be
158
+ liable to You for damages, including any direct, indirect, special,
159
+ incidental, or consequential damages of any character arising as a
160
+ result of this License or out of the use or inability to use the
161
+ Work (including but not limited to damages for loss of goodwill,
162
+ work stoppage, computer failure or malfunction, or any and all
163
+ other commercial damages or losses), even if such Contributor
164
+ has been advised of the possibility of such damages.
165
+
166
+ 9. Accepting Warranty or Additional Liability. While redistributing
167
+ the Work or Derivative Works thereof, You may choose to offer,
168
+ and charge a fee for, acceptance of support, warranty, indemnity,
169
+ or other liability obligations and/or rights consistent with this
170
+ License. However, in accepting such obligations, You may act only
171
+ on Your own behalf and on Your sole responsibility, not on behalf
172
+ of any other Contributor, and only if You agree to indemnify,
173
+ defend, and hold each Contributor harmless for any liability
174
+ incurred by, or claims asserted against, such Contributor by reason
175
+ of your accepting any such warranty or additional liability.
176
+
177
+ END OF TERMS AND CONDITIONS
178
+
179
+ APPENDIX: How to apply the Apache License to your work.
180
+
181
+ To apply the Apache License to your work, attach the following
182
+ boilerplate notice, with the fields enclosed by brackets "[]"
183
+ replaced with your own identifying information. (Don't include
184
+ the brackets!) The text should be enclosed in the appropriate
185
+ comment syntax for the file format. We also recommend that a
186
+ file or class name and description of purpose be included on the
187
+ same "printed page" as the copyright notice for easier
188
+ identification within third-party archives.
189
+
190
+ Copyright [yyyy] [name of copyright owner]
191
+
192
+ Licensed under the Apache License, Version 2.0 (the "License");
193
+ you may not use this file except in compliance with the License.
194
+ You may obtain a copy of the License at
195
+
196
+ http://www.apache.org/licenses/LICENSE-2.0
197
+
198
+ Unless required by applicable law or agreed to in writing, software
199
+ distributed under the License is distributed on an "AS IS" BASIS,
200
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
201
+ See the License for the specific language governing permissions and
202
+ limitations under the License.