-
Notifications
You must be signed in to change notification settings - Fork 305
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9a50e9
commit 0410436
Showing
9 changed files
with
144 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,26 +1,20 @@ | ||
import { Logger, LogLevel } from "@pnp/logging"; | ||
import { graphSetup } from "./setup.js"; | ||
import "@pnp/graph/sites"; | ||
import "@pnp/graph/users"; | ||
import "@pnp/graph/files"; | ||
import "@pnp/graph/operations"; | ||
|
||
declare var process: { exit(code?: number): void }; | ||
|
||
export async function Example(settings: any) { | ||
|
||
const graph = graphSetup(settings); | ||
const graph = graphSetup(settings); | ||
|
||
const site = await graph.sites.getByUrl("318studios.sharepoint.com", "/sites/dev") | ||
const users = await graph.users(); | ||
|
||
const ops = await site.operations(); | ||
|
||
Logger.log({ | ||
data: users, | ||
level: LogLevel.Info, | ||
message: "List of Users Data", | ||
}); | ||
|
||
Logger.log({ | ||
data: ops, | ||
level: LogLevel.Info, | ||
message: "List of Users Data", | ||
}); | ||
|
||
process.exit(0); | ||
process.exit(0); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# @pnp/graph/permissions | ||
|
||
Allows you to manipulate the permissions of various entities. | ||
|
||
[![Selective Imports Banner](https://img.shields.io/badge/Selective%20Imports-informational.svg)](../concepts/selective-imports.md) | ||
|
||
## site permissions | ||
|
||
[![Official Docs](https://img.shields.io/badge/Official_Graph_Docs-social.svg)](https://learn.microsoft.com/en-us/graph/api/resources/permission?view=graph-rest-1.0) | ||
|
||
Allows you to manage application permissions for sites. | ||
|
||
### list site permissions | ||
|
||
```TypeScript | ||
import { graphfi } from "@pnp/graph"; | ||
import "@pnp/graph/sites"; | ||
import "@pnp/graph/permissions"; | ||
|
||
const graph = graphfi(...); | ||
|
||
const permissions = await graph.sites.getById("{site id}").permissions(); | ||
``` | ||
|
||
### get a site permission | ||
|
||
```TypeScript | ||
import { graphfi } from "@pnp/graph"; | ||
import "@pnp/graph/sites"; | ||
import "@pnp/graph/permissions"; | ||
|
||
const graph = graphfi(...); | ||
|
||
const permissions = await graph.sites.getById("{site id}").permissions.getById("{permission id}")(); | ||
``` | ||
|
||
### add a site permission | ||
|
||
```TypeScript | ||
import { graphfi } from "@pnp/graph"; | ||
import "@pnp/graph/sites"; | ||
import "@pnp/graph/permissions"; | ||
|
||
const graph = graphfi(...); | ||
|
||
const permissions = await graph.sites.getById("{site id}").permissions.add({ | ||
roles: ["fullcontrol"], | ||
grantedToIdentities: [{ | ||
id: "89ea5c94-7736-4e25-95ad-3fa95f62b66e", | ||
displayName: "Contoso Time Manager App", | ||
}], | ||
}); | ||
``` | ||
|
||
### update a site permission | ||
|
||
```TypeScript | ||
import { graphfi } from "@pnp/graph"; | ||
import "@pnp/graph/sites"; | ||
import "@pnp/graph/permissions"; | ||
|
||
const graph = graphfi(...); | ||
|
||
const permissions = await graph.sites.getById("{site id}").permissions.getById("{permission id}").update({ | ||
roles: ["read"], | ||
}); | ||
``` | ||
|
||
### delete a site permission | ||
|
||
```TypeScript | ||
import { graphfi } from "@pnp/graph"; | ||
import "@pnp/graph/sites"; | ||
import "@pnp/graph/permissions"; | ||
|
||
const graph = graphfi(...); | ||
|
||
const permissions = await graph.sites.getById("{site id}").permissions.getById("{permission id}").delete(); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,4 +131,4 @@ See [Messages](./messages.md) | |
|
||
## User OneDrive | ||
|
||
See [OneDrive](./onedrive.md) | ||
See [Files](./files.md) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import "./site.js"; | ||
|
||
export { | ||
IPermission, | ||
IPermissions, | ||
Permission, | ||
Permissions, | ||
} from "./types.js"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { addProp } from "@pnp/queryable"; | ||
import { _Site } from "../sites/types.js"; | ||
import { IPermissions, Permissions } from "./types.js"; | ||
|
||
declare module "../sites/types" { | ||
interface _Site { | ||
readonly permissions: IPermissions; | ||
} | ||
interface ISite { | ||
readonly permissions: IPermissions; | ||
} | ||
} | ||
|
||
addProp(_Site, "permissions", Permissions); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { body } from "@pnp/queryable"; | ||
import { IDeleteable, IGetById, IUpdateable, defaultPath, deleteable, getById, updateable } from "../decorators.js"; | ||
import { graphInvokableFactory, _GraphCollection, _GraphInstance } from "../graphqueryable.js"; | ||
import { Permission as IPermissionType } from "@microsoft/microsoft-graph-types"; | ||
import { graphPost } from "../ops.js"; | ||
|
||
/** | ||
* Permission | ||
*/ | ||
@deleteable() | ||
@updateable() | ||
export class _Permission extends _GraphInstance<IPermissionType> {} | ||
export interface IPermission extends _Permission, IUpdateable<Partial<IPermissionType>>, IDeleteable { } | ||
export const Permission = graphInvokableFactory<IPermission>(_Permission); | ||
|
||
/** | ||
* Permissions | ||
*/ | ||
@defaultPath("permissions") | ||
@getById(Permission) | ||
export class _Permissions extends _GraphCollection<IPermissionType[]> { | ||
|
||
public add(permissions: Pick<IPermissionType, "roles"| "grantedToIdentities"| "expirationDateTime">): Promise<IPermissionType> { | ||
|
||
return graphPost(this, body(permissions)); | ||
} | ||
} | ||
export interface IPermissions extends _Permissions, IGetById<IPermission> { } | ||
export const Permissions = graphInvokableFactory<IPermissions>(_Permissions); |