forked from pnp/powershell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetSearchExternalConnection.cs
More file actions
41 lines (35 loc) · 1.79 KB
/
GetSearchExternalConnection.cs
File metadata and controls
41 lines (35 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
using System.Management.Automation;
using PnP.PowerShell.Commands.Base;
using PnP.PowerShell.Commands.Attributes;
using System.Collections.Generic;
namespace PnP.PowerShell.Commands.Search
{
[Cmdlet(VerbsCommon.Get, "PnPSearchExternalConnection")]
[RequiredApiDelegatedOrApplicationPermissions("graph/ExternalConnection.ReadWrite.OwnedBy")]
[RequiredApiDelegatedOrApplicationPermissions("graph/ExternalConnection.Read.All")]
[RequiredApiDelegatedOrApplicationPermissions("graph/ExternalConnection.ReadWrite.OwnedBy")]
[OutputType(typeof(IEnumerable<Model.Graph.MicrosoftSearch.ExternalConnection>))]
[OutputType(typeof(Model.Graph.MicrosoftSearch.ExternalConnection))]
public class GetSearchExternalConnection : PnPGraphCmdlet
{
[Parameter(Mandatory = false, Position = 0, ValueFromPipeline = true)]
public string Identity;
protected override void ExecuteCmdlet()
{
var graphApiUrl = $"v1.0/external/connections";
if(ParameterSpecified(nameof(Identity)))
{
graphApiUrl += $"/{Identity}";
WriteVerbose($"Retrieving external connection with Identity '{Identity}'");
var externalConnectionResult = Utilities.REST.GraphHelper.Get<Model.Graph.MicrosoftSearch.ExternalConnection>(this, Connection, graphApiUrl, AccessToken);
WriteObject(externalConnectionResult, false);
}
else
{
WriteVerbose("Retrieving all external connections");
var externalConnectionResults = Utilities.REST.GraphHelper.GetResultCollection<Model.Graph.MicrosoftSearch.ExternalConnection>(this, Connection, graphApiUrl, AccessToken);
WriteObject(externalConnectionResults, true);
}
}
}
}