diff --git a/CHANGELOG.md b/CHANGELOG.md index 2109b9247..e68db6faa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,6 +26,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added `Add-PnPFlowOwner` and `Remove-PnPFlowOwner` cmdlets which allow granting or removing permissions to a Power Automate flow [#3343](https://github.com/pnp/powershell/pull/3343) - Added `Get-PnPFlowOwner` cmdlet which allows retrieving the owners of a Power Automate flow [#3314](https://github.com/pnp/powershell/pull/3314) - Added `-AvailableForTagging` to `Set-PnPTerm` which allows the available for tagging property on a Term to be set [#3321](https://github.com/pnp/powershell/pull/3321) +- Added `Get-PnPPowerPlatformConnector` cmdlet which allows for all custom connectors to be retrieved [#3309](https://github.com/pnp/powershell/pull/3309) ### Fixed diff --git a/documentation/Get-PnPPowerPlatformConnector.md b/documentation/Get-PnPPowerPlatformConnector.md new file mode 100644 index 000000000..34709cb87 --- /dev/null +++ b/documentation/Get-PnPPowerPlatformConnector.md @@ -0,0 +1,106 @@ +--- +Module Name: PnP.PowerShell +schema: 2.0.0 +applicable: SharePoint Online +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPPowerPlatformConnector.html +external help file: PnP.PowerShell.dll-Help.xml +title: Get-PnPPowerPlatformConnector +--- + +# Get-PnPPowerPlatformConnector + +## SYNOPSIS + +**Required Permissions** + +* Azure: management.azure.com + +Returns the Custom Power Platform Connectors for a given environment + +## SYNTAX + +```powershell +Get-PnPPowerPlatformConnector [-Environment ] [-Identity ] [-AsAdmin] [-Verbose] +``` + +## DESCRIPTION +This cmdlet returns the custom connectors on a given enviroment. + +## EXAMPLES + +### Example 1 +```powershell +Get-PnPPowerPlatformConnector -Environment (Get-PnPPowerPlatformEnvironment) +``` +This returns all the custom connectors for a given Power Platform environment + +### Example 2 +```powershell +Get-PowerPlatformConnectorPipeBind -Environment (Get-PnPPowerPlatformEnvironment -IsDefault) -Identity fba63225-baf9-4d76-86a1-1b42c917a182 +``` +This returns a specific custom connector on the default Power Platform environment + +## PARAMETERS + +### -Environment +The name of the Power Platform environment or an Environment instance to retrieve the available custom connectors for. If omitted, the default environment will be used. + +```yaml +Type: PowerPlatformEnvironmentPipeBind +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: The default environment +Accept pipeline input: True +Accept wildcard characters: False +``` + +### -Identity +The Id of the connector to retrieve. If not provided, all custom connectors will be returned. + +```yaml +Type: PowerPlatformConnectorPipeBind +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +Accept wildcard characters: False +``` + +### -AsAdmin +If specified returns all the custom connectors as admin. If not specified only the custom connectors for the current user will be returned. + +```yaml +Type: SwitchParameter +Parameter Sets: (All) +Aliases: + +Required: False +Position: Named +Default value: None +Accept pipeline input: False +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) \ No newline at end of file diff --git a/src/Commands/Base/PipeBinds/PowerPlatformConnectorPipeBind.cs b/src/Commands/Base/PipeBinds/PowerPlatformConnectorPipeBind.cs new file mode 100644 index 000000000..02c619136 --- /dev/null +++ b/src/Commands/Base/PipeBinds/PowerPlatformConnectorPipeBind.cs @@ -0,0 +1,26 @@ +namespace PnP.PowerShell.Commands.Base.PipeBinds +{ + public sealed class PowerPlatformConnectorPipeBind + { + private readonly string _name; + private readonly Model.PowerPlatform.Environment.PowerPlatformConnector _connector; + public PowerPlatformConnectorPipeBind(string input) + { + _name = input; + } + + public PowerPlatformConnectorPipeBind(Model.PowerPlatform.Environment.PowerPlatformConnector connector) + { + _connector = connector; + } + + public string GetName() + { + if (_connector != null) + { + return _connector.Name; + } + return _name; + } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnector.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnector.cs new file mode 100644 index 000000000..234c091c0 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnector.cs @@ -0,0 +1,37 @@ +using PnP.Framework.Extensions; +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnector + { + /// + /// Name of the connector as its GUID + /// + [JsonPropertyName("name")] + public string Name { get; set; } + /// + /// Unique identifier of this connector. + /// + [JsonPropertyName("id")] + public string Id { get; set; } + /// + /// Type of object, typically Microsoft.PowerApps/apis + /// + [JsonPropertyName("type")] + public string Type { get; set; } + /// + /// Additional information on the Connector + /// + [JsonPropertyName("properties")] + public PowerPlatformConnectorProperties Properties { get; set; } + public bool IsCustomConnector + { + get { return Properties.isCustomApi; } + } + public string DisplayName + { + get { return Properties.displayName; } + } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorApiDefinitions.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorApiDefinitions.cs new file mode 100644 index 000000000..c15b514a1 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorApiDefinitions.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorApiDefinitions + { + [JsonPropertyName("originalSwaggerUrl")] + public string originalSwaggerUrl { get; set; } + + [JsonPropertyName("modifiedSwaggerUrl")] + public string modifiedSwaggerUrl { get; set; } + } + +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorAuthorizationUrl.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorAuthorizationUrl.cs new file mode 100644 index 000000000..495c8211e --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorAuthorizationUrl.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorAuthorizationUrl + { + [JsonPropertyName("value")] + public string value { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorBackendService.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorBackendService.cs new file mode 100644 index 000000000..2f5d53780 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorBackendService.cs @@ -0,0 +1,12 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorBackendService + { + [JsonPropertyName("serviceUrl")] + public string serviceUrl { get; set; } + } + + +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorConnectionParameters.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorConnectionParameters.cs new file mode 100644 index 000000000..d319eaa82 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorConnectionParameters.cs @@ -0,0 +1,14 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorConnectionParameters + { + [JsonPropertyName("token")] + public PowerPlatformConnectorToken token { get; set; } + + [JsonPropertyName("token:TenantId")] + public PowerPlatformConnectorTokenTenantId tokenTenantId { get; set; } + } + +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorConstraints.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorConstraints.cs new file mode 100644 index 000000000..f28a04df3 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorConstraints.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorConstraints + { + [JsonPropertyName("required")] + public string required { get; set; } + + [JsonPropertyName("hidden")] + public string hidden { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorContact.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorContact.cs new file mode 100644 index 000000000..40b9e5636 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorContact.cs @@ -0,0 +1,6 @@ +//namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +//{ +// public class PowerPlatformConnectorContact +// { +// } +//} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorCreatedBy.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorCreatedBy.cs new file mode 100644 index 000000000..a06185849 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorCreatedBy.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorCreatedBy + { + [JsonPropertyName("id")] + public string id { get; set; } + + [JsonPropertyName("displayName")] + public string displayName { get; set; } + + [JsonPropertyName("email")] + public string email { get; set; } + + [JsonPropertyName("type")] + public string type { get; set; } + + [JsonPropertyName("tenantId")] + public string tenantId { get; set; } + + [JsonPropertyName("userPrincipalName")] + public string userPrincipalName { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorCustomParameters.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorCustomParameters.cs new file mode 100644 index 000000000..09eda5e14 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorCustomParameters.cs @@ -0,0 +1,28 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorCustomParameters + { + [JsonPropertyName("loginUri")] + public PowerPlatformConnectorLoginUri loginUri { get; set; } + + [JsonPropertyName("tenantId")] + public PowerPlatformConnectorTenantId tenantId { get; set; } + + [JsonPropertyName("resourceUri")] + public PowerPlatformConnectorResourceUri resourceUri { get; set; } + + [JsonPropertyName("authorizationUrl")] + public PowerPlatformConnectorAuthorizationUrl authorizationUrl { get; set; } + + [JsonPropertyName("tokenUrl")] + public PowerPlatformConnectorTokenUrl tokenUrl { get; set; } + + [JsonPropertyName("refreshUrl")] + public PowerPlatformConnectorRefreshUrl refreshUrl { get; set; } + + [JsonPropertyName("enableOnbehalfOfLogin")] + public PowerPlatformConnectorEnableOnbehalfOfLogin enableOnbehalfOfLogin { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorEnableOnbehalfOfLogin.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorEnableOnbehalfOfLogin.cs new file mode 100644 index 000000000..c2f61c328 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorEnableOnbehalfOfLogin.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorEnableOnbehalfOfLogin + { + [JsonPropertyName("value")] + public string value { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorEnvironment.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorEnvironment.cs new file mode 100644 index 000000000..e190e093b --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorEnvironment.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorEnvironment + { + [JsonPropertyName("id")] + public string id { get; set; } + + [JsonPropertyName("name")] + public string name { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorLicense.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorLicense.cs new file mode 100644 index 000000000..402a03f96 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorLicense.cs @@ -0,0 +1,6 @@ +//namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +//{ +// public class PowerPlatformConnectorLicense +// { +// } +//} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorLoginUri.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorLoginUri.cs new file mode 100644 index 000000000..31fb1b4fd --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorLoginUri.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorLoginUri + { + [JsonPropertyName("value")] + public string value { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorMetadata.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorMetadata.cs new file mode 100644 index 000000000..595831cef --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorMetadata.cs @@ -0,0 +1,55 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorMetadata + { + [JsonPropertyName("sourceType")] + public string sourceType { get; set; } + + [JsonPropertyName("source")] + public string source { get; set; } + + [JsonPropertyName("brandColor")] + public string brandColor { get; set; } + + //[JsonPropertyName("contact")] + //public PowerPlatformConnectorContact contact { get; set; } + + //[JsonPropertyName("license")] + //public PowerPlatformConnectorLicense license { get; set; } + + [JsonPropertyName("publisherUrl")] + public object publisherUrl { get; set; } + + [JsonPropertyName("serviceUrl")] + public object serviceUrl { get; set; } + + [JsonPropertyName("documentationUrl")] + public object documentationUrl { get; set; } + + [JsonPropertyName("environmentName")] + public string environmentName { get; set; } + + [JsonPropertyName("xrmConnectorId")] + public object xrmConnectorId { get; set; } + + [JsonPropertyName("almMode")] + public string almMode { get; set; } + + [JsonPropertyName("useNewApimVersion")] + public bool useNewApimVersion { get; set; } + + [JsonPropertyName("createdBy")] + public string createdBy { get; set; } + + [JsonPropertyName("modifiedBy")] + public string modifiedBy { get; set; } + + [JsonPropertyName("allowSharing")] + public bool allowSharing { get; set; } + + [JsonPropertyName("parameters")] + public PowerPlatformConnectorParameters parameters { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorModifiedBy.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorModifiedBy.cs new file mode 100644 index 000000000..47d0c80ca --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorModifiedBy.cs @@ -0,0 +1,25 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorModifiedBy + { + [JsonPropertyName("id")] + public string id { get; set; } + + [JsonPropertyName("displayName")] + public string displayName { get; set; } + + [JsonPropertyName("email")] + public string email { get; set; } + + [JsonPropertyName("type")] + public string type { get; set; } + + [JsonPropertyName("tenantId")] + public string tenantId { get; set; } + + [JsonPropertyName("userPrincipalName")] + public string userPrincipalName { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorOAuthSettings.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorOAuthSettings.cs new file mode 100644 index 000000000..a63a2a341 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorOAuthSettings.cs @@ -0,0 +1,29 @@ +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorOAuthSettings + { + [JsonPropertyName("identityProvider")] + public string identityProvider { get; set; } + + [JsonPropertyName("clientId")] + public string clientId { get; set; } + + [JsonPropertyName("scopes")] + public List scopes { get; set; } + + [JsonPropertyName("redirectMode")] + public string redirectMode { get; set; } + + [JsonPropertyName("redirectUrl")] + public string redirectUrl { get; set; } + + [JsonPropertyName("properties")] + public PowerPlatformConnectorProperties properties { get; set; } + + [JsonPropertyName("customParameters")] + public PowerPlatformConnectorCustomParameters customParameters { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorParameters.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorParameters.cs new file mode 100644 index 000000000..9355ffe36 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorParameters.cs @@ -0,0 +1,19 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorParameters + { + [JsonPropertyName("x-ms-apimTemplateParameter.name")] + public string xmsapimTemplateParametername { get; set; } + + [JsonPropertyName("x-ms-apimTemplateParameter.value")] + public string xmsapimTemplateParametervalue { get; set; } + + [JsonPropertyName("x-ms-apimTemplateParameter.existsAction")] + public string xmsapimTemplateParameterexistsAction { get; set; } + + [JsonPropertyName("x-ms-apimTemplate-policySection")] + public string xmsapimTemplatepolicySection { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorPolicyTemplateInstance.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorPolicyTemplateInstance.cs new file mode 100644 index 000000000..01dc47cdf --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorPolicyTemplateInstance.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorPolicyTemplateInstance + { + [JsonPropertyName("templateId")] + public string templateId { get; set; } + + [JsonPropertyName("title")] + public string title { get; set; } + + [JsonPropertyName("parameters")] + public PowerPlatformConnectorParameters parameters { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorProperties.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorProperties.cs new file mode 100644 index 000000000..c2362429e --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorProperties.cs @@ -0,0 +1,93 @@ +using System; +using System.Collections.Generic; +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorProperties + { + [JsonPropertyName("displayName")] + public string displayName { get; set; } + + [JsonPropertyName("iconUri")] + public string iconUri { get; set; } + + [JsonPropertyName("iconBrandColor")] + public string iconBrandColor { get; set; } + + //[JsonPropertyName("contact")] + //public PowerPlatformConnectorContact contact { get; set; } + + //[JsonPropertyName("license")] + //public PowerPlatformConnectorLicense license { get; set; } + + [JsonPropertyName("apiEnvironment")] + public string apiEnvironment { get; set; } + + [JsonPropertyName("isCustomApi")] + public bool isCustomApi { get; set; } + + [JsonPropertyName("connectionParameters")] + public PowerPlatformConnectorConnectionParameters connectionParameters { get; set; } + + [JsonPropertyName("runtimeUrls")] + public List runtimeUrls { get; set; } + + [JsonPropertyName("primaryRuntimeUrl")] + public string primaryRuntimeUrl { get; set; } + + [JsonPropertyName("metadata")] + public PowerPlatformConnectorMetadata metadata { get; set; } + + [JsonPropertyName("capabilities")] + public List capabilities { get; set; } + + [JsonPropertyName("description")] + public string description { get; set; } + + [JsonPropertyName("apiDefinitions")] + public PowerPlatformConnectorApiDefinitions apiDefinitions { get; set; } + + [JsonPropertyName("backendService")] + public PowerPlatformConnectorBackendService backendService { get; set; } + + [JsonPropertyName("createdBy")] + public PowerPlatformConnectorCreatedBy createdBy { get; set; } + + [JsonPropertyName("modifiedBy")] + public PowerPlatformConnectorModifiedBy modifiedBy { get; set; } + + [JsonPropertyName("createdTime")] + public DateTimeOffset createdTime { get; set; } + + [JsonPropertyName("changedTime")] + public DateTimeOffset changedTime { get; set; } + + [JsonPropertyName("environment")] + public PowerPlatformConnectorEnvironment environment { get; set; } + + [JsonPropertyName("tier")] + public string tier { get; set; } + + [JsonPropertyName("publisher")] + public string publisher { get; set; } + + [JsonPropertyName("almMode")] + public string almMode { get; set; } + + [JsonPropertyName("parameters")] + public PowerPlatformConnectorParameters parameters { get; set; } + + [JsonPropertyName("policyTemplateInstances")] + public List policyTemplateInstances { get; set; } + + [JsonPropertyName("IsFirstParty")] + public string IsFirstParty { get; set; } + + [JsonPropertyName("AzureActiveDirectoryResourceId")] + public string AzureActiveDirectoryResourceId { get; set; } + + [JsonPropertyName("IsOnbehalfofLoginSupported")] + public bool IsOnbehalfofLoginSupported { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorRefreshUrl.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorRefreshUrl.cs new file mode 100644 index 000000000..a286cd62c --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorRefreshUrl.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorRefreshUrl + { + [JsonPropertyName("value")] + public string value { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorResourceUri.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorResourceUri.cs new file mode 100644 index 000000000..624404b64 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorResourceUri.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorResourceUri + { + [JsonPropertyName("value")] + public string value { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorTenantId.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorTenantId.cs new file mode 100644 index 000000000..fd946996b --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorTenantId.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorTenantId + { + [JsonPropertyName("value")] + public string value { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorToken.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorToken.cs new file mode 100644 index 000000000..11834fca6 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorToken.cs @@ -0,0 +1,13 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorToken + { + [JsonPropertyName("type")] + public string type { get; set; } + + [JsonPropertyName("oAuthSettings")] + public PowerPlatformConnectorOAuthSettings oAuthSettings { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorTokenTenantId.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorTokenTenantId.cs new file mode 100644 index 000000000..5bf05b1f0 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorTokenTenantId.cs @@ -0,0 +1,16 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorTokenTenantId + { + [JsonPropertyName("type")] + public string type { get; set; } + + [JsonPropertyName("metadata")] + public PowerPlatformConnectorMetadata metadata { get; set; } + + [JsonPropertyName("uiDefinition")] + public PowerPlatformConnectorUiDefinition uiDefinition { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorTokenUrl.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorTokenUrl.cs new file mode 100644 index 000000000..2273efed6 --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorTokenUrl.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorTokenUrl + { + [JsonPropertyName("value")] + public string value { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorUiDefinition.cs b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorUiDefinition.cs new file mode 100644 index 000000000..b1d8afe3f --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Connector/PowerPlatformConnectorUiDefinition.cs @@ -0,0 +1,10 @@ +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment +{ + public class PowerPlatformConnectorUiDefinition + { + [JsonPropertyName("constraints")] + public PowerPlatformConnectorConstraints constraints { get; set; } + } +} \ No newline at end of file diff --git a/src/Commands/PowerPlatform/Environment/GetPowerPlatformConnector.cs b/src/Commands/PowerPlatform/Environment/GetPowerPlatformConnector.cs new file mode 100644 index 000000000..870b9ae25 --- /dev/null +++ b/src/Commands/PowerPlatform/Environment/GetPowerPlatformConnector.cs @@ -0,0 +1,62 @@ +using PnP.PowerShell.Commands.Base; +using PnP.PowerShell.Commands.Utilities.REST; +using System; +using System.Management.Automation; +using System.Linq; +using PnP.PowerShell.Commands.Base.PipeBinds; + +namespace PnP.PowerShell.Commands.PowerPlatform.Environment +{ + [Cmdlet(VerbsCommon.Get, "PnPPowerPlatformConnector")] + public class GetPowerPlatformConnector : PnPAzureManagementApiCmdlet + { + + [Parameter(Mandatory = false, ValueFromPipeline = true)] + public PowerPlatformEnvironmentPipeBind Environment; + + [Parameter(Mandatory = false)] + public SwitchParameter AsAdmin; + + [Parameter(Mandatory = false)] + public PowerPlatformConnectorPipeBind Identity; + + protected override void ExecuteCmdlet() + { + string environmentName = null; + if (ParameterSpecified(nameof(Environment))) + { + environmentName = Environment.GetName(); + WriteVerbose($"Using environment as provided '{environmentName}'"); + } + else + { + var environments = GraphHelper.GetResultCollectionAsync(Connection, "https://management.azure.com/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult(); + environmentName = environments.FirstOrDefault(e => e.Properties.IsDefault.HasValue && e.Properties.IsDefault == true)?.Name; + + if (string.IsNullOrEmpty(environmentName)) + { + throw new Exception($"No default environment found, please pass in a specific environment name using the {nameof(Environment)} parameter"); + } + + WriteVerbose($"Using default environment as retrieved '{environmentName}'"); + } + + if (ParameterSpecified(nameof(Identity))) + { + var appName = Identity.GetName(); + + WriteVerbose($"Retrieving specific Custom Connector with the provided name '{appName}' within the environment '{environmentName}'"); + + var result = GraphHelper.GetAsync(Connection, $"https://api.powerapps.com/providers/Microsoft.PowerApps{(AsAdmin ? "/scopes/admin/environments/" + environmentName : "")}/apis/{appName}?api-version=2016-11-01&$filter=environment eq '{environmentName}' and isCustomApi eq 'True'", AccessToken).GetAwaiter().GetResult(); + WriteObject(result, false); + } + else + { + WriteVerbose($"Retrieving all Connectors within environment '{environmentName}'"); + + var connectors = GraphHelper.GetResultCollectionAsync(Connection, $"https://api.powerapps.com/providers/Microsoft.PowerApps/apis?api-version=2016-11-01&$filter=environment eq '{environmentName}' and isCustomApi eq 'True'", AccessToken).GetAwaiter().GetResult(); + WriteObject(connectors, true); + } + } + } +} \ No newline at end of file