microsoft.onenote
Module microsoft.onenote
API
ballerinax/microsoft.onenote Ballerina library
Overview
Ballerina connector for Microsoft OneNote connects the Microsoft OneNote API through Ballerina. It provides the capability to perform CRUD operations on OneNote notebooks, sections and pages.
This module supports Microsoft Graph API v1.0 version and only allows to perform functions behalf of the currently logged in user.
Prerequisites
Before using this connector in your Ballerina application, complete the following:
- Create a Microsoft Office365 account
- Obtain tokens - Follow this link
Quickstart
To use the MS OneNote connector in your Ballerina application, update the .bal file as follows:
Step 1: Import connector
First, import the ballerinax/microsoft.onenote
module as shown below.
import ballerinax/microsoft.onenote;
Step 2: Create a new connector instance
Create a microsoft.onenote:Configuration
with the OAuth2 tokens obtained and initialize the connector with it.
microsoft.onenote:Configuration configuration = { authConfig: { refreshUrl: <REFRESH_URL>, refreshToken : <REFRESH_TOKEN>, clientId : <CLIENT_ID>, clientSecret : <CLIENT_SECRET> } }; microsoft.onenote:Client oneNoteClient = check new(configuration);
Step 3: Invoke connector operation
Now you can use the operations available within the connector. Note that they are in the form of remote operations.
Following is an example on how to create a notebook using the connector.
public function main() returns error? { Notebook notebook = check oneNoteClient->createNotebook("test"); }
Clients![](/images/permalink.svg)
microsoft.onenote: Client![](/images/permalink.svg)
Ballerina Microsoft OneNote connector provides the capability to access Microsoft Graph OneNote API It provides capability to perform perform CRUD (Create, Read, Update, and Delete) operations on [OneNote] (https://docs.microsoft.com/en-us/graph/api/resources/onenote-api-overview?view=graph-rest-1.0).
Constructor![](/images/permalink.svg)
Initializes the connector. During initialization you can pass either http:BearerTokenConfig if you have a bearer token or http:OAuth2RefreshTokenGrantConfig if you have OAuth tokens. Create a Microsoft account and obtain tokens following this guide
init (Configuration config)
- config Configuration - Configuration required to initialize the client
createNotebook![](/images/permalink.svg)
Creates a notebook.
Parameters
- noteBookName string - Display name for notebook
listNotebooks![](/images/permalink.svg)
Lists notebooks.
Parameters
- oDataQuery string? (default ()) - Optional. OData Query. Example: "$top=2&$count=true". For details, refer https://docs.microsoft.com/en-us/graph/query-parameters#odata-system-query-options
getNotebook![](/images/permalink.svg)
Gets a notebook.
Parameters
- notebookId string - Notebook ID
getRecentNotebooks![](/images/permalink.svg)
function getRecentNotebooks() returns RecentNotebook[]|error
Lists recent notebooks.
Return Type
- RecentNotebook[]|error - RecentNotebook[] if successful or else an error
listSections![](/images/permalink.svg)
Lists sections.
Parameters
- notebookId string - Notebook ID
- oDataQuery string? (default ()) - Optional. OData Query. Example: "$top=2&$count=true". For details, refer https://docs.microsoft.com/en-us/graph/query-parameters#odata-system-query-options
getSection![](/images/permalink.svg)
Gets a section.
Parameters
- sectionId string - Section ID
createSection![](/images/permalink.svg)
Creates a section.
listSectionGroups![](/images/permalink.svg)
function listSectionGroups(string notebookId, string? oDataQuery) returns SectionGroup[]|error
Lists section groups.
Parameters
- notebookId string - Notebook ID
- oDataQuery string? (default ()) - Optional. OData Query. Example: "$top=2&$count=true". For details, refer https://docs.microsoft.com/en-us/graph/query-parameters#odata-system-query-options
Return Type
- SectionGroup[]|error - SectionGroup[] if successful or else an error
createSectionGroup![](/images/permalink.svg)
function createSectionGroup(string notebookId, string sectionGroupName) returns SectionGroup|error
Creates a section group.
Return Type
- SectionGroup|error - Section if successful or else an error
getSectionGroup![](/images/permalink.svg)
function getSectionGroup(string sectionGroupId) returns SectionGroup|error
Gets a section group.
Parameters
- sectionGroupId string - Section group ID
Return Type
- SectionGroup|error - Section if successful or else an error
createSectionInSectionGroup![](/images/permalink.svg)
function createSectionInSectionGroup(string sectionGroupId, string sectionName) returns Section|error
Creates a section in a section group.
listPages![](/images/permalink.svg)
Lists pages of a section.
Parameters
- sectionId string - Section ID
- oDataQuery string? (default ()) - Optional. OData Query. Example: "$top=2&$count=true". For details, refer https://docs.microsoft.com/en-us/graph/query-parameters#odata-system-query-options
getPage![](/images/permalink.svg)
Gets a page.
Parameters
- pageId string - Page ID
createPage![](/images/permalink.svg)
Creates a page.
createPageWithHTML![](/images/permalink.svg)
Creates a page with HTML content.
deletePage![](/images/permalink.svg)
Deletes a page.
Parameters
- pageId string - Page ID
Return Type
- error? -
()
if the page deletion is successful or else an error if failed
Records![](/images/permalink.svg)
microsoft.onenote: Configuration![](/images/permalink.svg)
OneNote Connection Configuration
Fields
- authConfig BearerTokenConfig|OAuth2RefreshTokenGrantConfig - Auth configuration
- secureSocketConfig ClientSecureSocket? - Optional. Secure socket configuration
microsoft.onenote: Notebook![](/images/permalink.svg)
Represents a Notebook.
Fields
- id string - The unique identifier of the notebook
- displayName string - The name of the notebook.
- createdBy json - Identity of the user, device, and application which created the item
- createdDateTime string - The date and time when the notebook was created
- isDefault boolean - Indicates whether this is the user's default notebook
- isShared boolean - Indicates whether the notebook is shared. If true, the contents of the notebook can be seen by people other than the owner.
- lastModifiedBy json - Identity of the user, device, and application which created the item
- lastModifiedDateTime string - The date and time when the notebook was last modified
- links json - Links for opening the notebook. The oneNoteClientURL link opens the notebook in the OneNote native client if it's installed. The oneNoteWebURL link opens the notebook in OneNote on the web.
- sectionGroupsUrl string - The URL for the sectionGroups navigation property, which returns all the section groups in the notebook
- sectionsUrl string - The URL for the sections navigation property, which returns all the sections in the notebook
- self string - The endpoint where you can get details about the notebook
- userRole string - Possible values are: Owner, Contributor, Reader, None. Owner represents owner-level access to the notebook. Contributor represents read/write access to the notebook. Reader represents read-only access to the notebook.
microsoft.onenote: Page![](/images/permalink.svg)
Represents a Page.
Fields
- id string - The unique identifier of the page
- title string - The title of the page
- createdDateTime string - The date and time when the page was created
- lastModifiedDateTime string - The date and time when the page was last modified
- self string - The endpoint where you can get details about the page
- content byte[]? - The page's HTML content
- contentUrl string - The URL for the page's HTML content
- createdByAppId string? - The unique identifier of the application that created the page. Read-only
microsoft.onenote: RecentNotebook![](/images/permalink.svg)
Represents a RecentNotebook.
Fields
- displayName string - The name of the notebook
- lastAccessedTime string - The date and time when the notebook was last accessed
- links json - Links for opening the notebook
- sourceService string - Source service
microsoft.onenote: Section![](/images/permalink.svg)
Represents a Section.
Fields
- id string - The unique identifier of the section
- displayName string - The name of the section
- createdBy json - Identity of the user, device, and application which created the item
- createdDateTime string - The date and time when the section was created
- isDefault boolean - Indicates whether this is the user's default section
- lastModifiedBy json - Identity of the user, device, and application which created the item
- lastModifiedDateTime string - The date and time when the section was last modified
- pagesUrl string - The pages endpoint where you can get details for all the pages in the section
- self string - The endpoint where you can get details about the section
microsoft.onenote: SectionGroup![](/images/permalink.svg)
Represents a SectionGroup.
Fields
- id string - The unique identifier of the section group
- displayName string - The name of the section group
- createdBy json - Identity of the user, device, and application which created the item
- createdDateTime string - The date and time when the section group was created
- lastModifiedBy json - Identity of the user, device, and application which created the item
- lastModifiedDateTime string - The date and time when the section group was last modified
- sectionGroupsUrl string - The URL for the sectionGroups navigation property, which returns all the section groups in the section group
- sectionsUrl string - The URL for the sections navigation property, which returns all the sections in the section group
- self string - The endpoint where you can get details about the section group
Import
import ballerinax/microsoft.onenote;
Metadata
Released date: about 3 years ago
Version: 1.0.0
License: Apache-2.0
Compatibility
Platform: any
Ballerina version: slbeta2
GraalVM compatible: Yes
Pull count
Total: 0
Current verison: 0
Weekly downloads
Keywords
Microsoft
OneNote
note
Contributors
Dependencies