dynamics-client


Namedynamics-client JSON
Version 0.8.4 PyPI version JSON
download
home_pagehttps://github.com/MrThearMan/dynamics-client/
SummaryClient for making Web API request from a Microsoft Dynamics 365 Database.
upload_time2024-09-16 13:50:59
maintainerNone
docs_urlNone
authorMatti Lamppu
requires_python<4,>=3.9
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": null,
    "docs_url": null,
    "requires_python": "<4,>=3.9",
    "maintainer_email": null,
    "keywords": "Microsoft, Dynamics, client",
    "author": "Matti Lamppu",
    "author_email": "lamppu.matti.akseli@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/c6/43/7830909c45e599386d2c67d0a0ab862d83f316950ba0819bca4c56e76c74/dynamics_client-0.8.4.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.4",
    "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": "4d1f976a81270e08a4978873dff56f4f84d571eca87fcde9fc45cab810b7f21d",
                "md5": "b99752ca245c70b1855a6d847331dd67",
                "sha256": "9cd20adb8de106ffe6ee4d6ef798f17b4911defd78fded54ac0e9b8da2aaeebd"
            },
            "downloads": -1,
            "filename": "dynamics_client-0.8.4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "b99752ca245c70b1855a6d847331dd67",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4,>=3.9",
            "size": 46186,
            "upload_time": "2024-09-16T13:50:56",
            "upload_time_iso_8601": "2024-09-16T13:50:56.779413Z",
            "url": "https://files.pythonhosted.org/packages/4d/1f/976a81270e08a4978873dff56f4f84d571eca87fcde9fc45cab810b7f21d/dynamics_client-0.8.4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "c6437830909c45e599386d2c67d0a0ab862d83f316950ba0819bca4c56e76c74",
                "md5": "548fca03c40978d5e96e4eed5c443c9d",
                "sha256": "d596ab2aa8ab145e9c1e93615489185a357e9f12c6ec6b67024eb8e69b5553b7"
            },
            "downloads": -1,
            "filename": "dynamics_client-0.8.4.tar.gz",
            "has_sig": false,
            "md5_digest": "548fca03c40978d5e96e4eed5c443c9d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4,>=3.9",
            "size": 40475,
            "upload_time": "2024-09-16T13:50:59",
            "upload_time_iso_8601": "2024-09-16T13:50:59.066806Z",
            "url": "https://files.pythonhosted.org/packages/c6/43/7830909c45e599386d2c67d0a0ab862d83f316950ba0819bca4c56e76c74/dynamics_client-0.8.4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-16 13:50:59",
    "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.37203s