-
Notifications
You must be signed in to change notification settings - Fork 347
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added
Get-PnPSearchExternalItem
(#4375)
* Added implementeion for Get-PnPSearchExternalItem * Added changelog entry * Added PR reference --------- Co-authored-by: Gautam Sheth <[email protected]>
- Loading branch information
1 parent
0dd3f95
commit 32c4237
Showing
13 changed files
with
369 additions
and
2 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
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,105 @@ | ||
--- | ||
Module Name: PnP.PowerShell | ||
schema: 2.0.0 | ||
applicable: SharePoint Online | ||
online version: https://pnp.github.io/powershell/cmdlets/Get-PnPSearchExternalItem.html | ||
external help file: PnP.PowerShell.dll-Help.xml | ||
title: Get-PnPSearchExternalItem | ||
--- | ||
|
||
# Get-PnPSearchExternalItem | ||
|
||
## SYNOPSIS | ||
|
||
**Required Permissions** | ||
|
||
* Microsoft Graph API: One of ExternalItem.ReadWrite.OwnedBy, ExternalItem.Read.All, ExternalItem.ReadWrite.All under a delegated context. Application context is not supported. | ||
|
||
Returns the external items indexed for a specific connector in Microsoft Search | ||
|
||
## SYNTAX | ||
|
||
```powershell | ||
Get-PnPSearchExternalItem -ConnectionId <SearchExternalConnectionPipeBind> [-Identity <String>] [-Verbose] [-Connection <PnPConnection>] | ||
``` | ||
|
||
## DESCRIPTION | ||
|
||
This cmdlet can be used to retrieve a list of indexed external items for a specific Microsoft Search external connector. The cmdlet will return all indexed external items for the specified connector. If you want to retrieve a specific external item, you can use the Identity parameter to specify the unique identifier of the external item. It uses a Microsoft Graph query in the background to retrieve the external items. This is why it will be unable to return the Access Control Lists (ACLs) information in the external items and the properties to contain more properties than you ingested yourself. | ||
|
||
It is only possible to run this cmdlet under a delegated context, application context is not supported by the Microsoft Graph search API endpoint for this type of query. | ||
|
||
## EXAMPLES | ||
|
||
### EXAMPLE 1 | ||
```powershell | ||
Get-PnPSearchExternalItem -ConnectionId "pnppowershell" -ItemId "12345" | ||
``` | ||
|
||
This will return the external item with the unique identifier "12345" for the custom connector with the Connection ID "pnppowershell". | ||
|
||
### EXAMPLE 2 | ||
```powershell | ||
Get-PnPSearchExternalItem -ConnectionId "pnppowershell" | ||
``` | ||
|
||
This will return all external items for the custom connector with the Connection ID "pnppowershell". | ||
|
||
## PARAMETERS | ||
|
||
### -Connection | ||
Optional connection to be used by the cmdlet. Retrieve the value for this parameter by either specifying -ReturnConnection on Connect-PnPOnline or by executing Get-PnPConnection. | ||
|
||
```yaml | ||
Type: PnPConnection | ||
Parameter Sets: (All) | ||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -Identity | ||
Unique identifier of the external item in Microsoft Search. You can provide any identifier you want to retrieve or check for a specific item in the index. If you omit it, all external items for the specified connector will be returned. | ||
```yaml | ||
Type: String | ||
Parameter Sets: (All) | ||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
### -ConnectionId | ||
The Connection ID or connection instance of the custom connector to use. This is the ID that was entered when registering the custom connector and will indicate for which custom connector the external items will be returned from the Microsoft Search index. | ||
```yaml | ||
Type: SearchExternalConnectionPipeBind | ||
Parameter Sets: (All) | ||
Required: True | ||
Default value: None | ||
Accept pipeline input: True | ||
Accept wildcard characters: False | ||
``` | ||
### -Verbose | ||
When provided, additional debug statements will be shown while executing the cmdlet. | ||
```yaml | ||
Type: SwitchParameter | ||
Parameter Sets: (All) | ||
|
||
Required: False | ||
Position: Named | ||
Default value: None | ||
Accept pipeline input: False | ||
Accept wildcard characters: False | ||
``` | ||
## RELATED LINKS | ||
[Microsoft 365 Patterns and Practices](https://aka.ms/m365pnp) | ||
[Microsoft Graph documentation](https://learn.microsoft.com/graph/search-concept-custom-types#example-1-retrieve-items-using-azure-sql-built-in-connector) |
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
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,40 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PnP.PowerShell.Commands.Model.Graph.MicrosoftSearch; | ||
|
||
/// <summary> | ||
/// Defines a hit in a search result from Microsoft Graph | ||
/// </summary> | ||
/// <seealso cref="https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0&tabs=http" /> | ||
public class SearchHit | ||
{ | ||
/// <summary> | ||
/// Unique identifier of the search result | ||
/// </summary> | ||
[JsonPropertyName("hitId")] | ||
public string Id { get; set; } | ||
|
||
/// <summary> | ||
/// Name of the source of the content | ||
/// </summary> | ||
[JsonPropertyName("contentSource")] | ||
public string ContentSource { get; set; } | ||
|
||
/// <summary> | ||
/// The rank of the search result | ||
/// </summary> | ||
[JsonPropertyName("rank")] | ||
public short Rank { get; set; } | ||
|
||
/// <summary> | ||
/// A summary of the search result | ||
/// </summary> | ||
[JsonPropertyName("summary")] | ||
public string Summary { get; set; } | ||
|
||
/// <summary> | ||
/// The resource properties of the search result | ||
/// </summary> | ||
[JsonPropertyName("resource")] | ||
public SearchResultResource Resource { get; set; } | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Commands/Model/Graph/MicrosoftSearch/SearchHitsContainer.cs
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,17 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PnP.PowerShell.Commands.Model.Graph.MicrosoftSearch; | ||
|
||
/// <summary> | ||
/// Defines a hitcontainer in a search result from Microsoft Graph | ||
/// </summary> | ||
/// <seealso cref="https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0&tabs=http" /> | ||
public class SearchHitsContainer | ||
{ | ||
/// <summary> | ||
/// Collection with search hits | ||
/// </summary> | ||
[JsonPropertyName("hits")] | ||
public List<SearchHit> Hits { get; set; } | ||
} |
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,28 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PnP.PowerShell.Commands.Model.Graph.MicrosoftSearch; | ||
|
||
/// <summary> | ||
/// Defines the body for a single search request to Microsoft Graph | ||
/// </summary> | ||
public class SearchRequest | ||
{ | ||
/// <summary> | ||
/// The types of entities to query, i.e. externalItem | ||
/// </summary> | ||
[JsonPropertyName("entityTypes")] | ||
public List<string> EntityTypes { get; set; } | ||
|
||
/// <summary> | ||
/// The names of the content sources to query, i.e. /external/connections/<externalconnectionname> | ||
/// </summary> | ||
[JsonPropertyName("contentSources")] | ||
public List<string> ContentSources { get; set; } | ||
|
||
/// <summary> | ||
/// The search query to execute | ||
/// </summary> | ||
[JsonPropertyName("query")] | ||
public SearchRequestQuery Query { get; set; } | ||
} |
15 changes: 15 additions & 0 deletions
15
src/Commands/Model/Graph/MicrosoftSearch/SearchRequestQuery.cs
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,15 @@ | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PnP.PowerShell.Commands.Model.Graph.MicrosoftSearch; | ||
|
||
/// <summary> | ||
/// Defines the query for request to Microsoft Graph | ||
/// </summary> | ||
public class SearchRequestQuery | ||
{ | ||
/// <summary> | ||
/// The search query to execute | ||
/// </summary> | ||
[JsonPropertyName("queryString")] | ||
public string QueryString { get; set; } | ||
} |
16 changes: 16 additions & 0 deletions
16
src/Commands/Model/Graph/MicrosoftSearch/SearchRequests.cs
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,16 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PnP.PowerShell.Commands.Model.Graph.MicrosoftSearch; | ||
|
||
/// <summary> | ||
/// Defines the body for a collection of search requests to Microsoft Graph | ||
/// </summary> | ||
public class SearchRequests | ||
{ | ||
/// <summary> | ||
/// Collection of search request items | ||
/// </summary> | ||
[JsonPropertyName("requests")] | ||
public List<SearchRequest> Requests { get; set; } | ||
} |
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,17 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PnP.PowerShell.Commands.Model.Graph.MicrosoftSearch; | ||
|
||
/// <summary> | ||
/// Defines a search result from Microsoft Graph | ||
/// </summary> | ||
/// <seealso cref="https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0&tabs=http" /> | ||
public class SearchResult | ||
{ | ||
/// <summary> | ||
/// Unique identifier of the search result | ||
/// </summary> | ||
[JsonPropertyName("hitsContainers")] | ||
public List<SearchHitsContainer> HitsContainers { get; set; } | ||
} |
17 changes: 17 additions & 0 deletions
17
src/Commands/Model/Graph/MicrosoftSearch/SearchResultResource.cs
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,17 @@ | ||
using System.Collections.Generic; | ||
using System.Text.Json.Serialization; | ||
|
||
namespace PnP.PowerShell.Commands.Model.Graph.MicrosoftSearch; | ||
|
||
/// <summary> | ||
/// Defines the resources within a search result from Microsoft Graph | ||
/// </summary> | ||
/// <seealso cref="https://learn.microsoft.com/en-us/graph/api/search-query?view=graph-rest-1.0&tabs=http" /> | ||
public class SearchResultResource | ||
{ | ||
/// <summary> | ||
/// The properties of the search result | ||
/// </summary> | ||
[JsonPropertyName("properties")] | ||
public Dictionary<string, object> Properties { get; set; } | ||
} |
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
Oops, something went wrong.