Skip to main content

Python package that acts as a wrapper for the Microsoft Graph API.

Project description

grafap

grafap (graph-wrap) is a Python package for interacting with the Microsoft Graph API, primarily sharepoint lists. Creating new items, querying lists, etc.

Installation

pip install grafap

Usage

Several environment variables are required for grafap to function.

> Note: The SP (SharePoint) environment variables are only needed if using the Get Site User By Lookup ID function since it uses a separate API that is for some godforsaken reason not available through Microsoft Graph. Even though Microsoft constantly shoves Graph down your throat and how cool and awesome it is. They may be same values as the Graph variables if you've given access to both APIs to the same app. Nevermind, they just decided it would be cool and fun to hide the user information list. You just have to know a guy to get into the club.

Required? Env Variable Description
Yes GRAPH_LOGIN_BASE_URL Should be https://login.microsoftonline.com/
Yes GRAPH_BASE_URL Should be https://graph.microsoft.com/v1.0/sites/
Yes GRAPH_TENANT_ID Tenant ID from app registration created in Azure.
Yes GRAPH_CLIENT_ID Client ID from app registration created in Azure.
Yes GRAPH_CLIENT_SECRET Client secret from app registration created in Azure.
Yes GRAPH_GRANT_TYPE Should be 'client_credentials'
Yes GRAPH_SCOPES Should typically be https://graph.microsoft.com/.default unless using more fine-grained permissions.
No SP_SITE Base Site URL you're interacting with. Should be https://DOMAIN.sharepoint.com/

Get SharePoint Sites

Gets all SharePoint sites in the tenant.

Get SharePoint Lists

Gets all SharePoint lists in a site. Takes one parameter:

site_id - ID for the given site.

Get SharePoint List Items

Gets all items in a sharepoint list. Takes 2 required parameters and 1 optional.

site_id - ID for which site list is in list_id - ID for the list being queried filter_query - Optional OData filter query, e.g. "Department eq 1234"

Note: If you're using the filter_query expression, whichever field you want to filter on needs to be indexed or you'll get an error. To index a column, just add it in the sharepoint list settings.

Create SharePoint List Item

Creates a new item in a given sharepoint list. Takes three parameters:

site_id - long string with three components separated by commas. Starts with SP site URL (DOMAIN.sharepoint.com) list_id - Unique ID for the given list you want to add an item to. Use the get_sp_lists function to get the IDs for all lists in a site. field_data - Dictionary of fields you are populating. Formatted like below.

{
    "FieldName": "FieldValue",
    "Field2Name": true
}

Update SharePoint List Item

Updates one or more fields of a particular item in a list. Formatted almost identically to create item function, but only including fields whose values are being updated, as well as additional item ID parameter. Takes four parameters:

site_id - long string with three components separated by commas. Starts with SP site URL (DOMAIN.sharepoint.com) list_id - Unique ID for the given list you want to update item on. Use the get_sp_lists function to get the IDs for all lists in a site. item_id - ID of the list item being updated field_data - Dictionary of fields you are updating. Formatted like below.

{
    "FieldName": "FieldValue",
    "Field2Name": true
}

Get all Sharepoint Users' Info

Queries hidden User Information List SP list. Returns all user info so can be associated with lookup values.

site_id - ID for which site list is in, can be 'root'

Get a Sharepoint User's Info

Queries hidden User Information List. Returns info for a specific user ID.

site_id - ID for which site list is in, can be 'root' user_id - ID of the list item being queried

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

grafap-0.1.1.tar.gz (8.3 kB view details)

Uploaded Source

Built Distribution

grafap-0.1.1-py3-none-any.whl (7.1 kB view details)

Uploaded Python 3

File details

Details for the file grafap-0.1.1.tar.gz.

File metadata

  • Download URL: grafap-0.1.1.tar.gz
  • Upload date:
  • Size: 8.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for grafap-0.1.1.tar.gz
Algorithm Hash digest
SHA256 39ae9d7b36c4a1cee2e1769e4968bddd3f61ff903e324b98d9231d8832093b99
MD5 0afbf626674c5528e5887e086f54b99e
BLAKE2b-256 25fc8424a6be2d1fd04941cec2c15bbe2fd171f55f01abd36e9c4bedc1dd7d77

See more details on using hashes here.

File details

Details for the file grafap-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: grafap-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.9.19

File hashes

Hashes for grafap-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 6383d0284487b2734e827c8fc5f1a2e98fba29adf7aaf314b9e7f213ce7cf9be
MD5 335a0aea54acb35bf2cc3b99940faa39
BLAKE2b-256 94685de9505770dc07bf66cd388ef0f86c068b1d5709608332f3a4bf3d648b23

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page