py-msgraph


Namepy-msgraph JSON
Version 0.0.3 PyPI version JSON
download
home_page
Summarylibrary to use MS graph API
upload_time2023-08-05 04:27:57
maintainer
docs_urlNone
author
requires_python>=3.7
licenseThe MIT License (MIT) Copyright (c) 2023 Sungwon Um Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords microsoft graph api
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Installation

Use pip:

```
pip install py-msgraph
```
or

```
pip install git+https://github.com/shineum/py_msgraph.git
```


# Prerequisite
To use MS graph API, MS application is necessary and tenant_id, client_id and client_secret are prepared.
It is needed to assign the permissions in the MS application depending on the APIs.

Here are reference URLs.
```
# Set up a Tenant
https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-create-new-tenant

# Register an application
https://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app

# Graph API Permissions
https://learn.microsoft.com/en-us/graph/permissions-reference
```


# Getting Started
Initialize MSGraphServiceClient instance.

```
from py_msgraph import MSGraphServiceClient

config = {
    'tenant_id':      '<tentant_id>',
    'client_id':      '<client_id>',
    'client_secret':  '<client_secret>'
}

client: MSGraphServiceClient = MSGraphServiceClient(config)
```

# Usages

### Get data
To get data, use "get_data" method.

```
data = client.get_data('<api_name>', '<options - optional>', '<version: api version - optional>')
```

ex)
```
data = client.get_data('users', {'$filter': "userPrincipalName eq 'youremail@yourdomain.com'", '$select': 'id'})
print(data)
```

### Post request
To send post request, use "post_data" method.

```
result = client.post_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')
```

ex)
```
user_id = "<user guid>"
group_id = "<group guid>"
req_body = {
    "@odata.id": f"https://graph.microsoft.com/v1.0/users/{user_id}"
}
result = client.post_data(f"groups/{group_id}/members/$ref", req_body)
print(result)
```

### Others
This library also support put, patch and delete methods.

```
result = client.put_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')

result = client.patch_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')

result = client.delete_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')
```



            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "py-msgraph",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": "",
    "keywords": "microsoft,graph api",
    "author": "",
    "author_email": "Sungwon Um <shineum@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/0e/5d/78ab3551d64f234ccfaffde74b96f337f95732cf9e3a9467b73be90cb487/py-msgraph-0.0.3.tar.gz",
    "platform": null,
    "description": "# Installation\r\n\r\nUse pip:\r\n\r\n```\r\npip install py-msgraph\r\n```\r\nor\r\n\r\n```\r\npip install git+https://github.com/shineum/py_msgraph.git\r\n```\r\n\r\n\r\n# Prerequisite\r\nTo use MS graph API, MS application is necessary and tenant_id, client_id and client_secret are prepared.\r\nIt is needed to assign the permissions in the MS application depending on the APIs.\r\n\r\nHere are reference URLs.\r\n```\r\n# Set up a Tenant\r\nhttps://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-create-new-tenant\r\n\r\n# Register an application\r\nhttps://learn.microsoft.com/en-us/azure/active-directory/develop/quickstart-register-app\r\n\r\n# Graph API Permissions\r\nhttps://learn.microsoft.com/en-us/graph/permissions-reference\r\n```\r\n\r\n\r\n# Getting Started\r\nInitialize MSGraphServiceClient instance.\r\n\r\n```\r\nfrom py_msgraph import MSGraphServiceClient\r\n\r\nconfig = {\r\n    'tenant_id':      '<tentant_id>',\r\n    'client_id':      '<client_id>',\r\n    'client_secret':  '<client_secret>'\r\n}\r\n\r\nclient: MSGraphServiceClient = MSGraphServiceClient(config)\r\n```\r\n\r\n# Usages\r\n\r\n### Get data\r\nTo get data, use \"get_data\" method.\r\n\r\n```\r\ndata = client.get_data('<api_name>', '<options - optional>', '<version: api version - optional>')\r\n```\r\n\r\nex)\r\n```\r\ndata = client.get_data('users', {'$filter': \"userPrincipalName eq 'youremail@yourdomain.com'\", '$select': 'id'})\r\nprint(data)\r\n```\r\n\r\n### Post request\r\nTo send post request, use \"post_data\" method.\r\n\r\n```\r\nresult = client.post_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')\r\n```\r\n\r\nex)\r\n```\r\nuser_id = \"<user guid>\"\r\ngroup_id = \"<group guid>\"\r\nreq_body = {\r\n    \"@odata.id\": f\"https://graph.microsoft.com/v1.0/users/{user_id}\"\r\n}\r\nresult = client.post_data(f\"groups/{group_id}/members/$ref\", req_body)\r\nprint(result)\r\n```\r\n\r\n### Others\r\nThis library also support put, patch and delete methods.\r\n\r\n```\r\nresult = client.put_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')\r\n\r\nresult = client.patch_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')\r\n\r\nresult = client.delete_data('<api_name>', '<data: request body - optional>', '<headers: headers - optional>', '<version: api version - optional>', '<files: attachment - optional>')\r\n```\r\n\r\n\r\n",
    "bugtrack_url": null,
    "license": "The MIT License (MIT)  Copyright (c) 2023 Sungwon Um  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.",
    "summary": "library to use MS graph API",
    "version": "0.0.3",
    "project_urls": {
        "Homepage": "https://github.com/shineum/py-msgraph"
    },
    "split_keywords": [
        "microsoft",
        "graph api"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3a47e65b425ecb4d81956066c6647cccf5cbc60454908cb7a4d084d277a2a85",
                "md5": "370cb6e39e03db1d06bf9b0c00879ec1",
                "sha256": "ed1e133a66001c8ee8bd813e90559e9b2c6968c9ca9a43df773701dcfb7a4e3a"
            },
            "downloads": -1,
            "filename": "py_msgraph-0.0.3-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "370cb6e39e03db1d06bf9b0c00879ec1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 4731,
            "upload_time": "2023-08-05T04:27:55",
            "upload_time_iso_8601": "2023-08-05T04:27:55.762997Z",
            "url": "https://files.pythonhosted.org/packages/b3/a4/7e65b425ecb4d81956066c6647cccf5cbc60454908cb7a4d084d277a2a85/py_msgraph-0.0.3-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "0e5d78ab3551d64f234ccfaffde74b96f337f95732cf9e3a9467b73be90cb487",
                "md5": "1206bdc82070979f8bebe075e5e0610f",
                "sha256": "03f189baf8f2db5e746f66f7f289b0d6a73d31bba124349417ef6ca8c371e4f5"
            },
            "downloads": -1,
            "filename": "py-msgraph-0.0.3.tar.gz",
            "has_sig": false,
            "md5_digest": "1206bdc82070979f8bebe075e5e0610f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 3871,
            "upload_time": "2023-08-05T04:27:57",
            "upload_time_iso_8601": "2023-08-05T04:27:57.418248Z",
            "url": "https://files.pythonhosted.org/packages/0e/5d/78ab3551d64f234ccfaffde74b96f337f95732cf9e3a9467b73be90cb487/py-msgraph-0.0.3.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-05 04:27:57",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "shineum",
    "github_project": "py-msgraph",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "py-msgraph"
}
        
Elapsed time: 0.14328s