mattermost-api-reference-client


Namemattermost-api-reference-client JSON
Version 4.1.0 PyPI version JSON
download
home_pageNone
SummaryA client library for accessing Mattermost API
upload_time2025-09-07 19:33:27
maintainerNone
docs_urlNone
authorNicolas Cedilnik
requires_python>=3.9
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # mattermost-api-reference-client
A client library for accessing Mattermost API

[![pypi](https://badge.fury.io/py/mattermost-api-reference-client.svg)](https://pypi.org/project/mattermost-api-reference-client/)
[![builds.sr.ht status](https://builds.sr.ht/~nicoco/mattermost-api-reference-client/commits/master/.build.yml.svg)](https://builds.sr.ht/~nicoco/mattermost-api-reference-client/commits/master/.build.yml?)

Generated using the awesome [openapi-python-client](https://pypi.org/project/openapi-python-client/) using
the schema that can be built from the [mattermost repository](https://github.com/mattermost/mattermost/tree/master/api)

Should provide correct signatures for endpoint calls and correct type hinting for all response models.
Auto-completion works like a charm in pycharm (pun intended), and probably other editors.

## Usage
First, create a client:

```python
from mattermost_api_reference_client import Client

client = Client(base_url="https://api.example.com")
```

If the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead.
Get your token either by using the `users.login` endpoint or by grabbing the `MMAUTHTOKEN` from
a web session, using the "storage" tab of developer console to inspect cookies.

```python
from mattermost_api_reference_client import AuthenticatedClient

client = AuthenticatedClient(base_url="https://api.example.com", token="SuperSecretToken")
```

Now call your endpoint and use your models:

```python
from mattermost_api_reference_client.models import User
from mattermost_api_reference_client.api.users import get_user
from mattermost_api_reference_client.types import Response

with client as client:
    my_data: User = get_user.sync("me", client=client)
    # or if you need more info (e.g. status_code)
    response: Response[User] = get_user.sync_detailed("me", client=client)
```

Or do the same thing with an async version:

```python
async with client as client:
    my_data: User = await get_user.asyncio(client=client)
    response: Response[User] = await get_user.asyncio_detailed(client=client)
```

By default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.

```python
client = AuthenticatedClient(
    base_url="https://internal_api.example.com", 
    token="MMAUTHTOKEN_VALUE",
    verify_ssl="/path/to/certificate_bundle.pem",
)
```

You can also disable certificate validation altogether, but beware that **this is a security risk**.

```python
client = AuthenticatedClient(
    base_url="https://internal_api.example.com", 
    token="MMAUTHTOKEN_VALUE", 
    verify_ssl=False
)
```

Things to know:
1. Every path/method combo becomes a Python module with four functions:
    1. `sync`: Blocking request that returns parsed data (if successful) or `None`
    1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.
    1. `asyncio`: Like `sync` but async instead of blocking
    1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking

1. All path/query params, and bodies become method arguments.
1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)
1. Any endpoint which did not have a tag will be in `mattermost_api_reference_client.api.default`

## Advanced customizations

There are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):

```python
from mattermost_api_reference_client import Client

def log_request(request):
    print(f"Request event hook: {request.method} {request.url} - Waiting for response")

def log_response(response):
    request = response.request
    print(f"Response event hook: {request.method} {request.url} - Status {response.status_code}")

client = Client(
    base_url="https://api.example.com",
    httpx_args={"event_hooks": {"request": [log_request], "response": [log_response]}},
)

# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()
```

You can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):

```python
import httpx
from mattermost_api_reference_client import Client

client = Client(
    base_url="https://api.example.com",
)
# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.
client.set_httpx_client(httpx.Client(base_url="https://api.example.com", proxies="http://localhost:8030"))
```

## Similar to

- https://github.com/Vaelor/python-mattermost-driver
- https://pypi.org/project/mattermost/

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "mattermost-api-reference-client",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.9",
    "maintainer_email": null,
    "keywords": null,
    "author": "Nicolas Cedilnik",
    "author_email": "Nicolas Cedilnik <nicoco@nicoco.fr>",
    "download_url": "https://files.pythonhosted.org/packages/93/1d/39515d74dfab6b6053e19e98f92ead4e6c54830c056542385aecd718d587/mattermost_api_reference_client-4.1.0.tar.gz",
    "platform": null,
    "description": "# mattermost-api-reference-client\nA client library for accessing Mattermost API\n\n[![pypi](https://badge.fury.io/py/mattermost-api-reference-client.svg)](https://pypi.org/project/mattermost-api-reference-client/)\n[![builds.sr.ht status](https://builds.sr.ht/~nicoco/mattermost-api-reference-client/commits/master/.build.yml.svg)](https://builds.sr.ht/~nicoco/mattermost-api-reference-client/commits/master/.build.yml?)\n\nGenerated using the awesome [openapi-python-client](https://pypi.org/project/openapi-python-client/) using\nthe schema that can be built from the [mattermost repository](https://github.com/mattermost/mattermost/tree/master/api)\n\nShould provide correct signatures for endpoint calls and correct type hinting for all response models.\nAuto-completion works like a charm in pycharm (pun intended), and probably other editors.\n\n## Usage\nFirst, create a client:\n\n```python\nfrom mattermost_api_reference_client import Client\n\nclient = Client(base_url=\"https://api.example.com\")\n```\n\nIf the endpoints you're going to hit require authentication, use `AuthenticatedClient` instead.\nGet your token either by using the `users.login` endpoint or by grabbing the `MMAUTHTOKEN` from\na web session, using the \"storage\" tab of developer console to inspect cookies.\n\n```python\nfrom mattermost_api_reference_client import AuthenticatedClient\n\nclient = AuthenticatedClient(base_url=\"https://api.example.com\", token=\"SuperSecretToken\")\n```\n\nNow call your endpoint and use your models:\n\n```python\nfrom mattermost_api_reference_client.models import User\nfrom mattermost_api_reference_client.api.users import get_user\nfrom mattermost_api_reference_client.types import Response\n\nwith client as client:\n    my_data: User = get_user.sync(\"me\", client=client)\n    # or if you need more info (e.g. status_code)\n    response: Response[User] = get_user.sync_detailed(\"me\", client=client)\n```\n\nOr do the same thing with an async version:\n\n```python\nasync with client as client:\n    my_data: User = await get_user.asyncio(client=client)\n    response: Response[User] = await get_user.asyncio_detailed(client=client)\n```\n\nBy default, when you're calling an HTTPS API it will attempt to verify that SSL is working correctly. Using certificate verification is highly recommended most of the time, but sometimes you may need to authenticate to a server (especially an internal server) using a custom certificate bundle.\n\n```python\nclient = AuthenticatedClient(\n    base_url=\"https://internal_api.example.com\", \n    token=\"MMAUTHTOKEN_VALUE\",\n    verify_ssl=\"/path/to/certificate_bundle.pem\",\n)\n```\n\nYou can also disable certificate validation altogether, but beware that **this is a security risk**.\n\n```python\nclient = AuthenticatedClient(\n    base_url=\"https://internal_api.example.com\", \n    token=\"MMAUTHTOKEN_VALUE\", \n    verify_ssl=False\n)\n```\n\nThings to know:\n1. Every path/method combo becomes a Python module with four functions:\n    1. `sync`: Blocking request that returns parsed data (if successful) or `None`\n    1. `sync_detailed`: Blocking request that always returns a `Request`, optionally with `parsed` set if the request was successful.\n    1. `asyncio`: Like `sync` but async instead of blocking\n    1. `asyncio_detailed`: Like `sync_detailed` but async instead of blocking\n\n1. All path/query params, and bodies become method arguments.\n1. If your endpoint had any tags on it, the first tag will be used as a module name for the function (my_tag above)\n1. Any endpoint which did not have a tag will be in `mattermost_api_reference_client.api.default`\n\n## Advanced customizations\n\nThere are more settings on the generated `Client` class which let you control more runtime behavior, check out the docstring on that class for more info. You can also customize the underlying `httpx.Client` or `httpx.AsyncClient` (depending on your use-case):\n\n```python\nfrom mattermost_api_reference_client import Client\n\ndef log_request(request):\n    print(f\"Request event hook: {request.method} {request.url} - Waiting for response\")\n\ndef log_response(response):\n    request = response.request\n    print(f\"Response event hook: {request.method} {request.url} - Status {response.status_code}\")\n\nclient = Client(\n    base_url=\"https://api.example.com\",\n    httpx_args={\"event_hooks\": {\"request\": [log_request], \"response\": [log_response]}},\n)\n\n# Or get the underlying httpx client to modify directly with client.get_httpx_client() or client.get_async_httpx_client()\n```\n\nYou can even set the httpx client directly, but beware that this will override any existing settings (e.g., base_url):\n\n```python\nimport httpx\nfrom mattermost_api_reference_client import Client\n\nclient = Client(\n    base_url=\"https://api.example.com\",\n)\n# Note that base_url needs to be re-set, as would any shared cookies, headers, etc.\nclient.set_httpx_client(httpx.Client(base_url=\"https://api.example.com\", proxies=\"http://localhost:8030\"))\n```\n\n## Similar to\n\n- https://github.com/Vaelor/python-mattermost-driver\n- https://pypi.org/project/mattermost/\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A client library for accessing Mattermost API",
    "version": "4.1.0",
    "project_urls": {
        "Repository": "https://git.sr.ht/~nicoco/mattermost-api-reference-client"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "427e104ad2004c90f000ebe432f3af4bf0c7b58c1c741b4f2dd0884de91b0b2a",
                "md5": "662782842bdbd13144c8b64ad9efc09b",
                "sha256": "8a7cef828bab728026798a16cf280ddae82fcf7b469afebf37a857313eae7b6a"
            },
            "downloads": -1,
            "filename": "mattermost_api_reference_client-4.1.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "662782842bdbd13144c8b64ad9efc09b",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.9",
            "size": 1182338,
            "upload_time": "2025-09-07T19:33:25",
            "upload_time_iso_8601": "2025-09-07T19:33:25.687571Z",
            "url": "https://files.pythonhosted.org/packages/42/7e/104ad2004c90f000ebe432f3af4bf0c7b58c1c741b4f2dd0884de91b0b2a/mattermost_api_reference_client-4.1.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "931d39515d74dfab6b6053e19e98f92ead4e6c54830c056542385aecd718d587",
                "md5": "4ac4d63a520c8e1aaf28a652f9ac43fa",
                "sha256": "75112bf0178b28c2599172d8ed2ae864e00329b0807416a0d1253ecf76d79391"
            },
            "downloads": -1,
            "filename": "mattermost_api_reference_client-4.1.0.tar.gz",
            "has_sig": false,
            "md5_digest": "4ac4d63a520c8e1aaf28a652f9ac43fa",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.9",
            "size": 311904,
            "upload_time": "2025-09-07T19:33:27",
            "upload_time_iso_8601": "2025-09-07T19:33:27.138650Z",
            "url": "https://files.pythonhosted.org/packages/93/1d/39515d74dfab6b6053e19e98f92ead4e6c54830c056542385aecd718d587/mattermost_api_reference_client-4.1.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-09-07 19:33:27",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "mattermost-api-reference-client"
}
        
Elapsed time: 3.36402s