Skip to content

Commit

Permalink
Adds the 'external item add' command. Closes pnp#5530
Browse files Browse the repository at this point in the history
  • Loading branch information
waldekmastykarz authored and Waldek Mastykarz committed Dec 3, 2023
1 parent edf2793 commit f1dea1a
Show file tree
Hide file tree
Showing 5 changed files with 910 additions and 1 deletion.
145 changes: 145 additions & 0 deletions docs/docs/cmd/external/item/item-add.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
import Global from '/docs/cmd/_global.mdx';
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

# external item add

Creates external item

## Usage

```sh
m365 external item add [options]
```

## Options

```md definition-list
`-i, --id <id>`
: The ID of the item to create

`--externalConnectionId <name>`
: The ID of the external connection on which to create the item

`--content <content>`
: External item content

`--contentType [contentType]`
: Type of content to load. Allowed values: `text` (default), `html`

`--acls <acls>`
: List of permissions to set on the item, in the format `accessType1,type1,value1;accessType2,type2,value2`, eg. `grant,everyone,everyone`
```
<Global />

## Remarks

When creating an external item, the options you specify will map to the external item properties, eg. `--author "Steve"` will set the `author` property of the external item to `Steve`.

If in your schema you have a multi-value property, to specify its value you need two things:

- you need to separate multiple values using `;#`, eg. `--author "Steve;#Bill"`
- you need to specify the type of the property as defined in the schema, eg. `[email protected] "Collection(String)"`

When creating items you can specify one or more permissions that define who can access the external item. The format of the permissions is `accessType1,type1,value1;accessType2,type2,value2`, eg. `grant,everyone,everyone`.

You can use the following access types:

- `grant` - grants access to the specified users or groups
- `deny` - denies access to the specified users or groups

You can use the following types:

- `everyone` - everyone
- `group` - an Entra group
- `user` - an Entra user
- `everyoneExceptGuests` - everyone except external users
- `externalGroup` - a group defined in the external system from which you're importing the content

For more information about using these options, see the Microsoft Graph API documentation and documentation about Microsoft Graph connectors.

## Examples

Creates an external item with simple properties that everyone is allowed to access

```sh
m365 external item add --id "pnp-ensure-siteassets-library" --connectionId "samplesolutiongallery" --content "Ensure that the Site Assets library is created." --title "Ensure the Site Assets Library is created" --description "Ensure that the Site Assets library is created." --authors "Phil Harding" --acls "grant,everyone,everyone"
```

Creates an external item with multi-value properties accessible only to users from the specified Entra group

```sh
m365 external item add --id "pnp-ensure-siteassets-library" --connectionId "samplesolutiongallery" --content "Ensure that the Site Assets library is created." --title "Ensure the Site Assets Library is created" --description "Ensure that the Site Assets library is created." [email protected] "Collection(String)" --authors "Phil Harding;#Steve Smith" --acls "grant,group,Super users"
```

## Response

<Tabs>
<TabItem value="JSON">

```json
{
"id": "pnp-ensure-siteassets-library",
"acl": [
{
"type": "everyone",
"value": "everyone",
"accessType": "grant"
}
],
"properties": {
"title": "Ensure the Site Assets Library is created",
"description": "Ensure that the Site Assets library is created.",
"authors": "Phil Harding"
},
"content": {
"value": "Ensure that the Site Assets library is created.",
"type": "text"
},
"activities": []
}
```

</TabItem>
<TabItem value="Text">

```text
acl : [{"type":"everyone","value":"everyone","accessType":"grant"}]
activities: []
content : {"value":"Ensure that the Site Assets library is created.","type":"text"}
id : pnp-ensure-siteassets-library
properties: {"title":"Ensure the Site Assets Library is created","description":"Ensure that the Site Assets library is created.","authors":"Phil Harding"}
```

</TabItem>
<TabItem value="CSV">

```csv
id
pnp-ensure-siteassets-library
```

</TabItem>
<TabItem value="Markdown">

```md
# m365 external item add --id "pnp-ensure-siteassets-library" --connectionId "samplesolutiongallery" --content "Ensure that the Site Assets library is created." --title "Ensure the Site Assets Library is created" --description "Ensure that the Site Assets library is created." --authors "Phil Harding" --acls "grant,everyone,everyone"

Date: 2023-10-28

## pnp-ensure-siteassets-library

Property | Value
---------|-------
id | pnp-ensure-siteassets-library
```

</TabItem>
</Tabs>

## More information

- Microsoft Graph connectors access control list [https://learn.microsoft.com/graph/connecting-external-content-manage-items#access-control-list](https://learn.microsoft.com/graph/connecting-external-content-manage-items#access-control-list)
- Create, update, and delete items added by your application via Microsoft Graph connectors [https://learn.microsoft.com/graph/connecting-external-content-manage-items](https://learn.microsoft.com/graph/connecting-external-content-manage-items)
- Use external groups to manage permissions to Microsoft Graph connectors data sources [https://learn.microsoft.com/graph/connecting-external-content-external-groups](https://learn.microsoft.com/graph/connecting-external-content-external-groups)
- Create externalItem [https://learn.microsoft.com/graph/api/externalconnectors-externalconnection-put-items?view=graph-rest-1.0&tabs=http](https://learn.microsoft.com/graph/api/externalconnectors-externalconnection-put-items?view=graph-rest-1.0&tabs=http)
9 changes: 9 additions & 0 deletions docs/src/config/sidebars.js
Original file line number Diff line number Diff line change
Expand Up @@ -637,6 +637,15 @@ const sidebars = {
id: 'cmd/external/connection/connection-schema-add'
}
]
},
{
item: [
{
type: 'doc',
label: 'item add',
id: 'cmd/external/item/item-add'
}
]
}
]
},
Expand Down
3 changes: 2 additions & 1 deletion src/m365/external/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ export default {
EXTERNALCONNECTION_GET: `${searchPrefix} externalconnection get`,
EXTERNALCONNECTION_LIST: `${searchPrefix} externalconnection list`,
EXTERNALCONNECTION_REMOVE: `${searchPrefix} externalconnection remove`,
EXTERNALCONNECTION_SCHEMA_ADD: `${searchPrefix} externalconnection schema add`
EXTERNALCONNECTION_SCHEMA_ADD: `${searchPrefix} externalconnection schema add`,
ITEM_ADD: `${prefix} item add`
};
Loading

0 comments on commit f1dea1a

Please sign in to comment.