Skip to content

Commit

Permalink
Add learn-copilot-me-plugin sample
Browse files Browse the repository at this point in the history
  • Loading branch information
garrytrinder committed Jul 23, 2024
1 parent 05c7d7c commit 6a1a75c
Show file tree
Hide file tree
Showing 6 changed files with 233 additions and 0 deletions.
61 changes: 61 additions & 0 deletions samples/learn-copilot-me-plugin/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# CRUD API for the "Connect Copilot for Microsoft 365 to your external data in real-time with message extension plugins built with .NET and Visual Studio" learn module

## Summary

This sample contains a CRUD API for the [Connect Copilot for Microsoft 365 to your external data in real-time with message extension plugins built with .NET and Visual Studio](https://learn.microsoft.com/training/modules/copilot-message-extension-plugins/) learn module. The CRUD API simulates the behavior of a custom API protected with Microsoft Entra that returns product data. Using this preset you can complete exercises from the learn module without having to create a real custom API.

## Compatibility

![Dev Proxy v0.19.1](https://img.shields.io/badge/devproxy-v0.19.1-green.svg)

## Contributors

- [Garry Trinder](https://github.com/waldekmastykarz)

## Version history

Version|Date|Comments
-------|----|--------
1.0|July 23, 2024|Initial release

## Minimal path to awesome

- Get the preset using Dev Proxy by running `devproxy preset get learn-copilot-me-plugin`
- Start Dev Proxy with the config file, by running `devproxy --config-file "~appFolder/presets/learn-copilot-me-plugin/products-api-config.json"`
- Follow along with the [Connect Copilot for Microsoft 365 to your external data in real-time with message extension plugins built with .NET and Visual Studio](https://learn.microsoft.com/en-us/training/modules/copilot-message-extension-plugins/) learn module

## Features

This preset contains the following endpoints and operations.

### Authentication

The CRUD API is configured to use Microsoft Entra authentication.

> [!IMPORTANT]
> All requests must send an OAuth 2.0 Bearer Token containing a scope named `Product.Read`.
### Products

Endpoint|Method|Description|Example
--------|------|-----------|-------
`products`|`GET`|Get all products|`GET https://api.contoso.com/v1/products`
`products?name={name}`|`GET`|Get products by name|`GET https://api.contoso.com/v1/products?name=mark8`
`products?category={category}`|`GET`|Get products by category |`GET https://api.contoso.com/v1/products?category=Consumer`
`products?name={name}&category={category}`|`GET`|Get products by name and category |`GET https://api.contoso.com/v1/products?name=mark8&category=Consumer`

## Help

We do not support samples, but this community is always willing to help, and we want to improve these samples. We use GitHub to track issues, which makes it easy for community members to volunteer their time and help resolve issues.

You can try looking at [issues related to this sample](https://github.com/pnp/proxy-samples/issues?q=label%3A%22sample%3A%learn-msgraph-toolkit-intro%22) to see if anybody else is having the same issues.

If you encounter any issues using this sample, [create a new issue](https://github.com/pnp/proxy-samples/issues/new).

Finally, if you have an idea for improvement, [make a suggestion](https://github.com/pnp/proxy-samples/issues/new).

## Disclaimer

**THIS CODE IS PROVIDED *AS IS* WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, INCLUDING ANY IMPLIED WARRANTIES OF FITNESS FOR A PARTICULAR PURPOSE, MERCHANTABILITY, OR NON-INFRINGEMENT.**

![](https://m365-visitor-stats.azurewebsites.net/SamplesGallery/pnp-devproxy-learn-copilot-me-plugin)
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
77 changes: 77 additions & 0 deletions samples/learn-copilot-me-plugin/assets/sample.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
[
{
"name": "pnp-devproxy-learn-copilot-me-plugin",
"source": "pnp",
"title": "CRUD APIs with Northwind database data",
"shortDescription": "This sample contains a CRUD API for the 'Connect Copilot for Microsoft 365 to your external data in real-time with message extension plugins built with .NET and Visual Studio' learn module. The CRUD API simulates the behavior of a custom API protected with Microsoft Entra that returns product data. Using this preset you can complete exercises from the learn module without having to create a real custom API.",
"url": "https://github.com/pnp/proxy-samples/tree/main/samples/learn-copilot-me-plugin",
"downloadUrl": "https://pnp.github.io/download-partial/?url=https://github.com/pnp/proxy-samples/tree/main/samples/learn-copilot-me-plugin",
"longDescription": [
"This sample contains a CRUD API for the 'Connect Copilot for Microsoft 365 to your external data in real-time with message extension plugins built with .NET and Visual Studio' learn module. The CRUD API simulates the behavior of a custom API protected with Microsoft Entra that returns product data. Using this preset you can complete exercises from the learn module without having to create a real custom API."
],
"creationDateTime": "2024-07-23",
"updateDateTime": "2024-07-23",
"products": [
"Dev Proxy"
],
"metadata": [
{
"key": "SAMPLE ID",
"value": "learn-copilot-me-plugin"
},
{
"key": "PRESET",
"value": "Yes"
},
{
"key": "MOCKS",
"value": "Yes"
},
{
"key": "PLUGIN",
"value": "No"
},
{
"key": "PROXY VERSION",
"value": "v0.19.1"
}
],
"thumbnails": [
{
"type": "image",
"order": 100,
"url": "https://github.com/pnp/proxy-samples/raw/main/samples/learn-copilot-me-plugin/assets/products.png",
"alt": "Dev Proxy simulating a products API endpoint"
}
],
"authors": [
{
"gitHubAccount": "garrytrinder",
"pictureUrl": "https://github.com/garrytrinder.png",
"name": "Garry Trinder"
}
],
"references": [
{
"name": "Simulate a CRUD API",
"description": "Learn how to use the Dev Proxy to simulate a CRUD API.",
"url": "https://learn.microsoft.com/microsoft-cloud/dev/dev-proxy/how-to/simulate-crud-api"
},
{
"name": "Simulate a CRUD API secured with Microsoft Entra",
"description": "Learn how to use the Dev Proxy to simulate a CRUD API secured with Microsoft Entra.",
"url": "https://learn.microsoft.com/microsoft-cloud/dev/dev-proxy/how-to/simulate-crud-api-entra"
},
{
"name": "Get started with the Dev Proxy",
"description": "The tutorial will introduce you to the Dev Proxy and show you how to use its features.",
"url": "https://learn.microsoft.com/microsoft-cloud/dev/dev-proxy/get-started"
},
{
"name": "Use preset configurations",
"description": "Instructions on how to configure the Dev Proxy to use a different configuration file.",
"url": "https://learn.microsoft.com/microsoft-cloud/dev/dev-proxy/how-to/use-preset-configurations"
}
]
}
]
17 changes: 17 additions & 0 deletions samples/learn-copilot-me-plugin/products-api-config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.19.1/rc.schema.json",
"plugins": [
{
"name": "CrudApiPlugin",
"enabled": true,
"pluginPath": "~appFolder/plugins/dev-proxy-plugins.dll",
"configSection": "productsApi",
"urlsToWatch": [
"https://api.contoso.com/*"
]
}
],
"productsApi": {
"apiFile": "products-api.json"
}
}
36 changes: 36 additions & 0 deletions samples/learn-copilot-me-plugin/products-api.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"$schema": "https://raw.githubusercontent.com/microsoft/dev-proxy/main/schemas/v0.19.1/crudapiplugin.schema.json",
"auth": "entra",
"entraAuthConfig": {
"scopes": [
"Product.Read"
]
},
"actions": [
{
"action": "getAll",
"method": "GET",
"url": "/products"
},
{
"action": "getMany",
"method": "GET",
"url": "/products?name={name}",
"query": "$[?(@.name =~ /^{name}.*/i)]"
},
{
"action": "getMany",
"method": "GET",
"url": "/products?category={category}",
"query": "$[?(@.category == '{category}')]"
},
{
"action": "getMany",
"method": "GET",
"url": "/products?name={name}&category={category}",
"query": "$[?(@.name =~ /^{name}.*/i && @.category == '{category}')]"
}
],
"baseUrl": "https://api.contoso.com/v1",
"dataFile": "products-data.json"
}
42 changes: 42 additions & 0 deletions samples/learn-copilot-me-plugin/products-data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
[
{
"productId": 1,
"name": "Contoso Quad",
"imageUrl": "https://raw.githubusercontent.com/SharePoint/sp-dev-provisioning-templates/master/tenant/productsupport/source/Product%20Imagery/Contoso4.png",
"category": "Enterprise",
"callVolume": 36,
"releaseDate": "2019-02-09"
},
{
"productId": 2,
"name": "Eagle Air",
"imageUrl": "https://raw.githubusercontent.com/SharePoint/sp-dev-provisioning-templates/master/tenant/productsupport/source/Product%20Imagery/EagleAir.png",
"category": "Enterprise",
"callVolume": 423,
"releaseDate": "2016-08-24"
},
{
"productId": 3,
"name": "Gimbal Case",
"imageUrl": "https://raw.githubusercontent.com/SharePoint/sp-dev-provisioning-templates/master/tenant/productsupport/source/Product%20Imagery/AerialGimbal.png",
"category": "Consumer",
"callVolume": 398,
"releaseDate": "2018-08-01"
},
{
"productId": 4,
"name": "Mark8",
"imageUrl": "https://raw.githubusercontent.com/SharePoint/sp-dev-provisioning-templates/master/tenant/productsupport/source/Product%20Imagery/Mark8.png",
"category": "Consumer",
"callVolume": 1201,
"releaseDate": "2020-01-02"
},
{
"productId": 5,
"name": "Mark8 controller",
"imageUrl": "https://raw.githubusercontent.com/SharePoint/sp-dev-provisioning-templates/master/tenant/productsupport/source/Product%20Imagery/Mark8-remotecontroller.png",
"category": "Consumer",
"callVolume": 812,
"releaseDate": "2020-01-02"
}
]

0 comments on commit 6a1a75c

Please sign in to comment.