dynamics-client


Namedynamics-client JSON
Version 0.8.3 PyPI version JSON
download
home_pagehttps://github.com/MrThearMan/dynamics-client/
SummaryClient for making Web API request from a Microsoft Dynamics 365 Database.
upload_time2023-11-07 17:49:19
maintainer
docs_urlNone
authorMatti Lamppu
requires_python>=3.8,<4
licenseMIT
keywords microsoft dynamics client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Dynamics Web API Client

[![Coverage Status][coverage-badge]][coverage]
[![GitHub Workflow Status][status-badge]][status]
[![PyPI][pypi-badge]][pypi]
[![GitHub][licence-badge]][licence]
[![GitHub Last Commit][repo-badge]][repo]
[![GitHub Issues][issues-badge]][issues]
[![Downloads][downloads-badge]][pypi]
[![Python Version][version-badge]][pypi]

```shell
pip install dynamics-client
```

---

**Documentation**: [https://mrthearman.github.io/dynamics-client/](https://mrthearman.github.io/dynamics-client/)

**Source Code**: [https://github.com/MrThearMan/dynamics-client/](https://github.com/MrThearMan/dynamics-client/)

**Contributing**: [https://github.com/MrThearMan/dynamics-client/blob/main/CONTRIBUTING.md](https://github.com/MrThearMan/dynamics-client/blob/main/CONTRIBUTING.md)

---

Client for making Web API request from a Microsoft Dynamics 365 Database.

You should also read the [Dynamics Web API Reference Docs][ref-docs]:


## Basic usage:

```python
from dynamics import DynamicsClient, ftr

# Init the client:
client = DynamicsClient(...)

### Example GET request:

client.table = "accounts"

# Get only these columns for the account.
client.select = ["accountid", "name"]

# Filter to only the accounts that have been created on or after the
# given ISO date string, AND that have 200 or more employees.
client.filter = [
    ftr.on_or_after("createdon", "2020-01-01T00:00:00Z"),
    ftr.ge("numberofemployees", 200),
]

# Expand to the contacts (collection-values navigation property)
# on the account that have 'gmail.com' in their email address 1 OR 2.
# Get only the 'firstname', 'lastname' and 'mobilephone' columns for these contacts.
# Also expand the primary contact (single-valued navigation property).
# Get only the 'emailaddress1' column for the primary contact.
client.expand = {
    "contact_customer_accounts": {
        "select": ["firstname", "lastname", "mobilephone"],
        "filter": {
            ftr.contains("emailaddress1", "gmail.com"),
            ftr.contains("emailaddress2", "gmail.com"),
        }
    },
    "primarycontactid": {
        "select": ["emailaddress1"],
    },
}

result = client.get()

print(result.data)
# [
#     {
#         "accountid": ...,
#         "name": ...,
#         "contact_customer_accounts": [
#             {
#                 "contactid": ...,  # id field is always given
#                 "firstname": ...,
#                 "lastname": ...,
#                 "mobilephone": ...
#             },
#             ...
#         ],
#         "primarycontactid": {
#             "contactid": ...,
#             "emailaddress1": ...
#         }
#     },
#     ...
# ]

### Example POST request

# IMPORTANT!!!
client.reset_query()

client.table = "contacts"

# Get only these columns from the created contact
client.select = ["firstname", "lastname", "emailaddress1"]

# The data to create the contact with. '@odata.bind' is used to link
# the contact to the given navigation property.
accountid = ...
data = {
    "firstname": ...,
    "lastname": ...,
    "emailaddress1": ...,
    "parentcustomerid_account@odata.bind": f"/accounts({accountid})"
}

result = client.post(data=data)

print(result.data)
# {
#     "contactid": ...,
#     "firstname": ...,
#     "lastname": ...,
#     "emailaddress1": ...
# }


### Example PATCH request

client.reset_query()

client.table = "contacts"
client.row_id = result["contactid"]

data = {
    "firstname": ...,
    "lastname": ...,
}

result = client.patch(data=data)

print(result.data)
# Return all rows on the updated contact,
# since no select statement was given
#
# {
#     ...
#     "contactid": ...,
#     "firstname": ...,
#     "lastname": ...,
#     ...
# }


### Example DELETE request

client.reset_query()

client.table = "contacts"
client.row_id = result["contactid"]

client.delete()
```


[ref-docs]: https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/query-data-web-api

[coverage-badge]: https://coveralls.io/repos/github/MrThearMan/dynamics-client/badge.svg?branch=main
[status-badge]: https://img.shields.io/github/actions/workflow/status/MrThearMan/dynamics-client/test.yml?branch=main
[pypi-badge]: https://img.shields.io/pypi/v/dynamics-client
[licence-badge]: https://img.shields.io/github/license/MrThearMan/dynamics-client
[repo-badge]: https://img.shields.io/github/last-commit/MrThearMan/dynamics-client
[issues-badge]: https://img.shields.io/github/issues-raw/MrThearMan/dynamics-client
[version-badge]: https://img.shields.io/pypi/pyversions/dynamics-client
[downloads-badge]: https://img.shields.io/pypi/dm/dynamics-client

[coverage]: https://coveralls.io/github/MrThearMan/dynamics-client?branch=main
[status]: https://github.com/MrThearMan/dynamics-client/actions/workflows/test.yml
[pypi]: https://pypi.org/project/dynamics-client
[licence]: https://github.com/MrThearMan/dynamics-client/blob/main/LICENSE
[repo]: https://github.com/MrThearMan/dynamics-client/commits/main
[issues]: https://github.com/MrThearMan/dynamics-client/issues

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/MrThearMan/dynamics-client/",
    "name": "dynamics-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4",
    "maintainer_email": "",
    "keywords": "Microsoft,Dynamics,client",
    "author": "Matti Lamppu",
    "author_email": "lamppu.matti.akseli@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/7d/7b/8f1ffdeed4c6bd32c5ae7ceb574df09033cb67c149a9c54a61a693dab4b1/dynamics_client-0.8.3.tar.gz",
    "platform": null,
    "description": "# Dynamics Web API Client\n\n[![Coverage Status][coverage-badge]][coverage]\n[![GitHub Workflow Status][status-badge]][status]\n[![PyPI][pypi-badge]][pypi]\n[![GitHub][licence-badge]][licence]\n[![GitHub Last Commit][repo-badge]][repo]\n[![GitHub Issues][issues-badge]][issues]\n[![Downloads][downloads-badge]][pypi]\n[![Python Version][version-badge]][pypi]\n\n```shell\npip install dynamics-client\n```\n\n---\n\n**Documentation**: [https://mrthearman.github.io/dynamics-client/](https://mrthearman.github.io/dynamics-client/)\n\n**Source Code**: [https://github.com/MrThearMan/dynamics-client/](https://github.com/MrThearMan/dynamics-client/)\n\n**Contributing**: [https://github.com/MrThearMan/dynamics-client/blob/main/CONTRIBUTING.md](https://github.com/MrThearMan/dynamics-client/blob/main/CONTRIBUTING.md)\n\n---\n\nClient for making Web API request from a Microsoft Dynamics 365 Database.\n\nYou should also read the [Dynamics Web API Reference Docs][ref-docs]:\n\n\n## Basic usage:\n\n```python\nfrom dynamics import DynamicsClient, ftr\n\n# Init the client:\nclient = DynamicsClient(...)\n\n### Example GET request:\n\nclient.table = \"accounts\"\n\n# Get only these columns for the account.\nclient.select = [\"accountid\", \"name\"]\n\n# Filter to only the accounts that have been created on or after the\n# given ISO date string, AND that have 200 or more employees.\nclient.filter = [\n    ftr.on_or_after(\"createdon\", \"2020-01-01T00:00:00Z\"),\n    ftr.ge(\"numberofemployees\", 200),\n]\n\n# Expand to the contacts (collection-values navigation property)\n# on the account that have 'gmail.com' in their email address 1 OR 2.\n# Get only the 'firstname', 'lastname' and 'mobilephone' columns for these contacts.\n# Also expand the primary contact (single-valued navigation property).\n# Get only the 'emailaddress1' column for the primary contact.\nclient.expand = {\n    \"contact_customer_accounts\": {\n        \"select\": [\"firstname\", \"lastname\", \"mobilephone\"],\n        \"filter\": {\n            ftr.contains(\"emailaddress1\", \"gmail.com\"),\n            ftr.contains(\"emailaddress2\", \"gmail.com\"),\n        }\n    },\n    \"primarycontactid\": {\n        \"select\": [\"emailaddress1\"],\n    },\n}\n\nresult = client.get()\n\nprint(result.data)\n# [\n#     {\n#         \"accountid\": ...,\n#         \"name\": ...,\n#         \"contact_customer_accounts\": [\n#             {\n#                 \"contactid\": ...,  # id field is always given\n#                 \"firstname\": ...,\n#                 \"lastname\": ...,\n#                 \"mobilephone\": ...\n#             },\n#             ...\n#         ],\n#         \"primarycontactid\": {\n#             \"contactid\": ...,\n#             \"emailaddress1\": ...\n#         }\n#     },\n#     ...\n# ]\n\n### Example POST request\n\n# IMPORTANT!!!\nclient.reset_query()\n\nclient.table = \"contacts\"\n\n# Get only these columns from the created contact\nclient.select = [\"firstname\", \"lastname\", \"emailaddress1\"]\n\n# The data to create the contact with. '@odata.bind' is used to link\n# the contact to the given navigation property.\naccountid = ...\ndata = {\n    \"firstname\": ...,\n    \"lastname\": ...,\n    \"emailaddress1\": ...,\n    \"parentcustomerid_account@odata.bind\": f\"/accounts({accountid})\"\n}\n\nresult = client.post(data=data)\n\nprint(result.data)\n# {\n#     \"contactid\": ...,\n#     \"firstname\": ...,\n#     \"lastname\": ...,\n#     \"emailaddress1\": ...\n# }\n\n\n### Example PATCH request\n\nclient.reset_query()\n\nclient.table = \"contacts\"\nclient.row_id = result[\"contactid\"]\n\ndata = {\n    \"firstname\": ...,\n    \"lastname\": ...,\n}\n\nresult = client.patch(data=data)\n\nprint(result.data)\n# Return all rows on the updated contact,\n# since no select statement was given\n#\n# {\n#     ...\n#     \"contactid\": ...,\n#     \"firstname\": ...,\n#     \"lastname\": ...,\n#     ...\n# }\n\n\n### Example DELETE request\n\nclient.reset_query()\n\nclient.table = \"contacts\"\nclient.row_id = result[\"contactid\"]\n\nclient.delete()\n```\n\n\n[ref-docs]: https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/query-data-web-api\n\n[coverage-badge]: https://coveralls.io/repos/github/MrThearMan/dynamics-client/badge.svg?branch=main\n[status-badge]: https://img.shields.io/github/actions/workflow/status/MrThearMan/dynamics-client/test.yml?branch=main\n[pypi-badge]: https://img.shields.io/pypi/v/dynamics-client\n[licence-badge]: https://img.shields.io/github/license/MrThearMan/dynamics-client\n[repo-badge]: https://img.shields.io/github/last-commit/MrThearMan/dynamics-client\n[issues-badge]: https://img.shields.io/github/issues-raw/MrThearMan/dynamics-client\n[version-badge]: https://img.shields.io/pypi/pyversions/dynamics-client\n[downloads-badge]: https://img.shields.io/pypi/dm/dynamics-client\n\n[coverage]: https://coveralls.io/github/MrThearMan/dynamics-client?branch=main\n[status]: https://github.com/MrThearMan/dynamics-client/actions/workflows/test.yml\n[pypi]: https://pypi.org/project/dynamics-client\n[licence]: https://github.com/MrThearMan/dynamics-client/blob/main/LICENSE\n[repo]: https://github.com/MrThearMan/dynamics-client/commits/main\n[issues]: https://github.com/MrThearMan/dynamics-client/issues\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Client for making Web API request from a Microsoft Dynamics 365 Database.",
    "version": "0.8.3",
    "project_urls": {
        "Bug Tracker": "https://github.com/MrThearMan/dynamics-client/issues",
        "Homepage": "https://github.com/MrThearMan/dynamics-client/",
        "Repository": "https://github.com/MrThearMan/dynamics-client/"
    },
    "split_keywords": [
        "microsoft",
        "dynamics",
        "client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "473179772cf14ac0a7d05e238f730c0a831d8d41826f7b3a82a79b75ae8cdd45",
                "md5": "c393ce4ade77937fc9816f73cfb66ee2",
                "sha256": "26f7a49c4bf70e83486125605ea47211bcfa25b0ce51d8e2347c8400fb52ec4d"
            },
            "downloads": -1,
            "filename": "dynamics_client-0.8.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "c393ce4ade77937fc9816f73cfb66ee2",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4",
            "size": 46265,
            "upload_time": "2023-11-07T17:49:17",
            "upload_time_iso_8601": "2023-11-07T17:49:17.319735Z",
            "url": "https://files.pythonhosted.org/packages/47/31/79772cf14ac0a7d05e238f730c0a831d8d41826f7b3a82a79b75ae8cdd45/dynamics_client-0.8.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "7d7b8f1ffdeed4c6bd32c5ae7ceb574df09033cb67c149a9c54a61a693dab4b1",
                "md5": "84026f2af3e0695c9c1438beb50c2f61",
                "sha256": "cf3c6b2510c65f919ab05e3e5709a7cd16003e88a91abaed0ceb873d661081cd"
            },
            "downloads": -1,
            "filename": "dynamics_client-0.8.3.tar.gz",
            "has_sig": false,
            "md5_digest": "84026f2af3e0695c9c1438beb50c2f61",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4",
            "size": 40529,
            "upload_time": "2023-11-07T17:49:19",
            "upload_time_iso_8601": "2023-11-07T17:49:19.346861Z",
            "url": "https://files.pythonhosted.org/packages/7d/7b/8f1ffdeed4c6bd32c5ae7ceb574df09033cb67c149a9c54a61a693dab4b1/dynamics_client-0.8.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-11-07 17:49:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "MrThearMan",
    "github_project": "dynamics-client",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "dynamics-client"
}
        
Elapsed time: 0.15372s