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

Add as a git submodule for now. Intend on at some point making available as a proper package.

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_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.0.tar.gz (8.4 kB view details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for grafap-0.1.0.tar.gz
Algorithm Hash digest
SHA256 3aaf7469b38b233fc144af1727bce63747a057092b9e6d3018f7ea755009a4df
MD5 d1d2c1863cc294cee9c86750547a90e9
BLAKE2b-256 d4cba95969c24417c55d560f39d3235b411ec24318751621b2ed49d9c024f867

See more details on using hashes here.

File details

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

File metadata

  • Download URL: grafap-0.1.0-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.12.0

File hashes

Hashes for grafap-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28cfad49e34ec042e8b978545259b653462d793ea96a50ed8898cfc7553df0bc
MD5 0819014e1b647384452e5bc4174aeffb
BLAKE2b-256 6db9d1d9fb35b19f8049e6620cf8f10d5a08b2f5c519fdf66e730f9a7f0e8dd4

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