diff --git a/documentation/Get-PnPPowerPlatformConnector.md b/documentation/Get-PnPPowerPlatformCustomConnector.md similarity index 60% rename from documentation/Get-PnPPowerPlatformConnector.md rename to documentation/Get-PnPPowerPlatformCustomConnector.md index 34709cb87..92c247105 100644 --- a/documentation/Get-PnPPowerPlatformConnector.md +++ b/documentation/Get-PnPPowerPlatformCustomConnector.md @@ -2,12 +2,12 @@ Module Name: PnP.PowerShell schema: 2.0.0 applicable: SharePoint Online -online version: https://pnp.github.io/powershell/cmdlets/Get-PnPPowerPlatformConnector.html +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPPowerPlatformCustomConnector.html external help file: PnP.PowerShell.dll-Help.xml -title: Get-PnPPowerPlatformConnector +title: Get-PnPPowerPlatformCustomConnector --- -# Get-PnPPowerPlatformConnector +# Get-PnPPowerPlatformCustomConnector ## SYNOPSIS @@ -20,7 +20,8 @@ Returns the Custom Power Platform Connectors for a given environment ## SYNTAX ```powershell -Get-PnPPowerPlatformConnector [-Environment ] [-Identity ] [-AsAdmin] [-Verbose] +Get-PnPPowerPlatformCustomConnector [-Environment ] [-Identity ] +[-Connection ] [-Verbose] ``` ## DESCRIPTION @@ -30,20 +31,22 @@ This cmdlet returns the custom connectors on a given enviroment. ### Example 1 ```powershell -Get-PnPPowerPlatformConnector -Environment (Get-PnPPowerPlatformEnvironment) +$environment = Get-PnPPowerPlatformEnvironment +Get-PnPPowerPlatformCustomConnector -Environment $environment ``` 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 +$environment = Get-PnPPowerPlatformEnvironment +Get-PowerPlatformCustomConnector -Environment $environment -Identity 'Tikit Connector' ``` -This returns a specific custom connector on the default Power Platform environment +This returns a specific custom connector based on connector display name ## 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. +The name of the Power Platform environment or an Environment object to retrieve the available custom connectors for. ```yaml Type: PowerPlatformEnvironmentPipeBind @@ -58,10 +61,10 @@ Accept wildcard characters: False ``` ### -Identity -The Id of the connector to retrieve. If not provided, all custom connectors will be returned. +The Display Name of the connector to retrieve. ```yaml -Type: PowerPlatformConnectorPipeBind +Type: PowerPlatformCustomConnectorPipeBind Parameter Sets: (All) Aliases: @@ -71,12 +74,12 @@ 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. +### -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: SwitchParameter +Type: PnPConnection Parameter Sets: (All) Aliases: diff --git a/documentation/Get-PnPPowerPlatformSolution.md b/documentation/Get-PnPPowerPlatformSolution.md new file mode 100644 index 000000000..5a8c3c729 --- /dev/null +++ b/documentation/Get-PnPPowerPlatformSolution.md @@ -0,0 +1,90 @@ +--- +Module Name: PnP.PowerShell +schema: 2.0.0 +applicable: SharePoint Online +online version: https://pnp.github.io/powershell/cmdlets/Get-PnPPowerPlatformSolution.html +external help file: PnP.PowerShell.dll-Help.xml +title: Get-PnPPowerPlatformSolution +--- + +# Get-PnPPowerPlatformSolution + +## SYNOPSIS + +**Required Permissions** + +* Azure: management.azure.com + +Returns the Power Platform Solution/s for a given environment + +## SYNTAX + +```powershell +Get-PnPPowerPlatformSolution [-Environment ] [-Name ] [-Verbose] +``` + +## DESCRIPTION +This cmdlet returns the PowerPlatform solution on a given enviroment. + +## EXAMPLES + +### Example 1 +```powershell +Get-PnPPowerPlatformSolution -Environment (Get-PnPPowerPlatformEnvironment) +``` +This returns all the solutions for a given Power Platform environment + +### Example 2 +```powershell +Get-PnPPowerPlatformSolution -Environment (Get-PnPPowerPlatformEnvironment -IsDefault) -Name 'My Solution Name' +``` +This returns a specific solution on the default Power Platform environment + +## PARAMETERS + +### -Environment +The name of the Power Platform environment or an Environment instance to retrieve the available solutions 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 +``` + +### -Name +The Name of the solution to retrieve. If not provided, all the solutions will be returned. + +```yaml +Type: PowerPlatformSolutionPipeBind +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/PowerPlatformCustomConnectorPipeBind.cs similarity index 66% rename from src/Commands/Base/PipeBinds/PowerPlatformConnectorPipeBind.cs rename to src/Commands/Base/PipeBinds/PowerPlatformCustomConnectorPipeBind.cs index 02c619136..577168fa6 100644 --- a/src/Commands/Base/PipeBinds/PowerPlatformConnectorPipeBind.cs +++ b/src/Commands/Base/PipeBinds/PowerPlatformCustomConnectorPipeBind.cs @@ -1,15 +1,15 @@ namespace PnP.PowerShell.Commands.Base.PipeBinds { - public sealed class PowerPlatformConnectorPipeBind + public sealed class PowerPlatformCustomConnectorPipeBind { private readonly string _name; private readonly Model.PowerPlatform.Environment.PowerPlatformConnector _connector; - public PowerPlatformConnectorPipeBind(string input) + public PowerPlatformCustomConnectorPipeBind(string input) { _name = input; } - public PowerPlatformConnectorPipeBind(Model.PowerPlatform.Environment.PowerPlatformConnector connector) + public PowerPlatformCustomConnectorPipeBind(Model.PowerPlatform.Environment.PowerPlatformConnector connector) { _connector = connector; } diff --git a/src/Commands/Base/PipeBinds/PowerPlatformSolutionPipeBind.cs b/src/Commands/Base/PipeBinds/PowerPlatformSolutionPipeBind.cs new file mode 100644 index 000000000..385e697c2 --- /dev/null +++ b/src/Commands/Base/PipeBinds/PowerPlatformSolutionPipeBind.cs @@ -0,0 +1,26 @@ +namespace PnP.PowerShell.Commands.Base.PipeBinds +{ + public sealed class PowerPlatformSolutionPipeBind + { + private readonly string _name; + private readonly Model.PowerPlatform.Environment.Solution.PowerPlatformSolution _solution; + public PowerPlatformSolutionPipeBind(string input) + { + _name = input; + } + + public PowerPlatformSolutionPipeBind(Model.PowerPlatform.Environment.Solution.PowerPlatformSolution solution) + { + _solution = solution; + } + + public string GetName() + { + if (_solution != null) + { + return _solution.FriendlyName; + } + return _name; + } + } +} diff --git a/src/Commands/Base/TokenHandling.cs b/src/Commands/Base/TokenHandling.cs index 4d85d5ad2..d332173ca 100644 --- a/src/Commands/Base/TokenHandling.cs +++ b/src/Commands/Base/TokenHandling.cs @@ -88,6 +88,26 @@ internal static string GetAccessToken(Cmdlet cmdlet, string appOnlyDefaultScope, return null; } + internal static string GetAccessTokenforPowerPlatformSolutions(Cmdlet cmdlet, PnPConnection connection,string enviormentBaseUrl) + { + var contextSettings = connection.Context.GetContextSettings(); + var authManager = contextSettings.AuthenticationManager; + if (authManager != null) + { + if (contextSettings.Type == Framework.Utilities.Context.ClientContextType.SharePointACSAppOnly) + { + // When connected using ACS, we cannot get a token for another endpoint + throw new PSInvalidOperationException("Trying to get a token for a different endpoint while being connected through an ACS token is not possible. Please connect differently."); + } + string[] requiredScopes = new string[1] { enviormentBaseUrl + "/.default" }; + cmdlet.WriteVerbose($"Acquiring oAuth token for {(requiredScopes.Length != 1 ? requiredScopes.Length + " " : "")}permission scope{(requiredScopes.Length != 1 ? "s" : "")} {string.Join(",", requiredScopes)}"); + var accessToken = authManager.GetAccessTokenAsync(requiredScopes).GetAwaiter().GetResult(); + cmdlet.WriteVerbose($"Access token acquired for PowerPlatformSolutions: {accessToken}"); + return accessToken; + } + return null; + } + /// /// Returns an access token based on a Managed Identity. Only works within Azure components supporting managed identities such as Azure Functions and Azure Runbooks. /// diff --git a/src/Commands/Model/PowerPlatform/Environment/Solution/PowerPlatformSolution.cs b/src/Commands/Model/PowerPlatform/Environment/Solution/PowerPlatformSolution.cs new file mode 100644 index 000000000..d852d270b --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Solution/PowerPlatformSolution.cs @@ -0,0 +1,204 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment.Solution +{ + public class PowerPlatformSolution + { + /// + /// Etag for the solution + /// + [JsonPropertyName("@odata.etag")] + public string? ODataEtag { get; set; } + + /// + /// Date and time when the solution was installed + /// + [JsonPropertyName("installedon")] + public string? InstalledOn { get; set; } + + /// + /// Version of the solution package + /// + [JsonPropertyName("solutionpackageversion")] + public string? SolutionPackageVersion { get; set; } + + /// + /// Configuration page ID (null in this case) + /// + [JsonPropertyName("_configurationpageid_value")] + public string? ConfigurationPageId { get; set; } + + /// + /// ID of the solution + /// + [JsonPropertyName("solutionid")] + public string? SolutionId { get; set; } + + /// + /// Date and time when the solution was last modified + /// + [JsonPropertyName("modifiedon")] + public string? ModifiedOn { get; set; } + + /// + /// Unique name of the solution + /// + [JsonPropertyName("uniquename")] + public string? UniqueName { get; set; } + + /// + /// Indicates if the solution is managed by API + /// + [JsonPropertyName("isapimanaged")] + public bool IsApiManaged { get; set; } + + /// + /// Publisher ID (null in this case) + /// + [JsonPropertyName("_publisherid_value")] + public string? PublisherIdValue { get; set; } + + /// + /// Indicates if the solution is managed + /// + [JsonPropertyName("ismanaged")] + public bool IsManaged { get; set; } + + /// + /// Indicates if the solution is visible + /// + [JsonPropertyName("isvisible")] + public bool IsVisible { get; set; } + + /// + /// Thumbprint (null in this case) + /// + [JsonPropertyName("thumbprint")] + public string? Thumbprint { get; set; } + + /// + /// Pinpoint publisher ID (null in this case) + /// + [JsonPropertyName("pinpointpublisherid")] + public string? PinpointPublisherId { get; set; } + + /// + /// Version of the solution + /// + [JsonPropertyName("version")] + public string? Version { get; set; } + + /// + /// Modified on behalf by value (null in this case) + /// + [JsonPropertyName("_modifiedonbehalfby_value")] + public string? ModifiedOnBehalfByValue { get; set; } + + /// + /// Parent solution ID value (null in this case) + /// + [JsonPropertyName("_parentsolutionid_value")] + public string? ParentSolutionIdValue { get; set; } + + /// + /// Pinpoint asset ID (null in this case) + /// + [JsonPropertyName("pinpointassetid")] + public string? PinpointAssetId { get; set; } + + /// + /// Pinpoint solution ID (null in this case) + /// + [JsonPropertyName("pinpointsolutionid")] + public string? PinpointSolutionId { get; set; } + + /// + /// Friendly name of the solution + /// + [JsonPropertyName("friendlyname")] + public string? FriendlyName { get; set; } + + /// + /// Organization ID value + /// + [JsonPropertyName("_organizationid_value")] + public string? OrganizationIdValue { get; set; } + + /// + /// Version number + /// + [JsonPropertyName("versionnumber")] + public int? VersionNumber { get; set; } + + /// + /// Template suffix (null in this case) + /// + [JsonPropertyName("templatesuffix")] + public string? TemplateSuffix { get; set; } + + /// + /// Upgrade information (null in this case) + /// + [JsonPropertyName("upgradeinfo")] + public string? UpgradeInfo { get; set; } + + /// + /// Created on behalf by value (null in this case) + /// + [JsonPropertyName("_createdonbehalfby_value")] + public string? CreatedOnBehalfByValue { get; set; } + + /// + /// Modified by value + /// + [JsonPropertyName("_modifiedby_value")] + public string? ModifiedByValue { get; set; } + + /// + /// Date and time when the solution was created + /// + [JsonPropertyName("createdon")] + public string? CreatedOn { get; set; } + + /// + /// Date and time when the solution was last updated (null in this case) + /// + [JsonPropertyName("updatedon")] + public string? UpdatedOn { get; set; } + + /// + /// Description of the solution (null in this case) + /// + [JsonPropertyName("description")] + public string? Description { get; set; } + + /// + /// Solution type (null in this case) + /// + [JsonPropertyName("solutiontype")] + public int? SolutionType { get; set; } + + /// + /// Pinpoint solution default locale (null in this case) + /// + [JsonPropertyName("pinpointsolutiondefaultlocale")] + public string? PinpointSolutionDefaultLocale { get; set; } + + /// + /// Created by value + /// + [JsonPropertyName("_createdby_value")] + public string? CreatedByValue { get; set; } + + /// + /// Publisher information + /// + [JsonPropertyName("publisherid")] + public PowerPlatformSolutionPublisher PublisherId { get; set; } + } +} diff --git a/src/Commands/Model/PowerPlatform/Environment/Solution/PowerPlatformSolutionPublisher.cs b/src/Commands/Model/PowerPlatform/Environment/Solution/PowerPlatformSolutionPublisher.cs new file mode 100644 index 000000000..df497e95f --- /dev/null +++ b/src/Commands/Model/PowerPlatform/Environment/Solution/PowerPlatformSolutionPublisher.cs @@ -0,0 +1,403 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Text.Json.Serialization; + +namespace PnP.PowerShell.Commands.Model.PowerPlatform.Environment.Solution +{ + public class PowerPlatformSolutionPublisher + { + /// + /// Etag for the publisher + /// + [JsonPropertyName("@odata.etag")] + public string? ODataEtag { get; set; } + + /// + /// Address line 1 (null in this case) + /// + [JsonPropertyName("address2_line1")] + public string? Address2Line1 { get; set; } + + /// + /// Pinpoint? publisher default locale (null in this case) + /// + [JsonPropertyName("pinpoint?publisherdefaultlocale")] + public string? PinpointPublisherDefaultLocale { get; set; } + + /// + /// County (null in this case) + /// + [JsonPropertyName("address1_county")] + public string? Address1County { get; set; } + + /// + /// Address 2 UTC offset (null in this case) + /// + [JsonPropertyName("address2_utcoffset")] + public string? Address2UtcOffset { get; set; } + + /// + /// Fax number (null in this case) + /// + [JsonPropertyName("address2_fax")] + public string? Address2Fax { get; set; } + + /// + /// Date and time when modified + /// + [JsonPropertyName("modifiedon")] + public string? ModifiedOn { get; set; } + + /// + /// Entity image URL (null in this case) + /// + [JsonPropertyName("entityimage_url")] + public string? EntityImageUrl { get; set; } + + /// + /// Name (null in this case) + /// + [JsonPropertyName("address1_name")] + public string? Address1Name { get; set; } + + /// + /// Address line 1 (null in this case) + /// + [JsonPropertyName("address1_line1")] + public string? Address1Line1 { get; set; } + + /// + /// Unique name + /// + [JsonPropertyName("uniquename")] + public string? UniqueName { get; set; } + + /// + /// Postal code (null in this case) + /// + [JsonPropertyName("address1_postalcode")] + public string? Address1PostalCode { get; set; } + + /// + /// Address 2 line 3 (null in this case) + /// + [JsonPropertyName("address2_line3")] + public string? Address2Line3 { get; set; } + + /// + /// Address 1 address ID + /// + [JsonPropertyName("address1_addressid")] + public string? Address1AddressId { get; set; } + + /// + /// Publisher ID + /// + [JsonPropertyName("publisherid")] + public string? PublisherId { get; set; } + + /// + /// Address 1 line 3 (null in this case) + /// + [JsonPropertyName("address1_line3")] + public string? Address1Line3 { get; set; } + + /// + /// Address 2 name (null in this case) + /// + [JsonPropertyName("address2_name")] + public string? Address2Name { get; set; } + + /// + /// Address 2 city (null in this case) + /// + [JsonPropertyName("address2_city")] + public string? Address2City { get; set; } + + /// + /// Address 1 UTC offset (null in this case) + /// + [JsonPropertyName("address1_utcoffset")] + public string? Address1UtcOffset { get; set; } + + /// + /// Pinpoint? publisher ID (null in this case) + /// + [JsonPropertyName("pinpoint?publisherid")] + public string? PinpointPublisherId { get; set; } + + /// + /// Address 2 county (null in this case) + /// + [JsonPropertyName("address2_county")] + public string? Address2County { get; set; } + + /// + /// Email address + /// + [JsonPropertyName("emailaddress")] + public string? EmailAddress { get; set; } + + /// + /// Address 2 post office box (null in this case) + /// + [JsonPropertyName("address2_postofficebox")] + public string? Address2PostOfficeBox { get; set; } + + /// + /// State or province (null in this case) + /// + [JsonPropertyName("address1_stateorprovince")] + public string? Address1StateOrProvince { get; set; } + + /// + /// Address 2 telephone 3 (null in this case) + /// + [JsonPropertyName("address2_telephone3")] + public string? Address2Telephone3 { get; set; } + + /// + /// Address 2 telephone 2 (null in this case) + /// + [JsonPropertyName("address2_telephone2")] + public string? Address2Telephone2 { get; set; } + + /// + /// Address 2 telephone 1 (null in this case) + /// + [JsonPropertyName("address2_telephone1")] + public string? Address2Telephone1 { get; set; } + + /// + /// Address 2 shipping method code + /// + [JsonPropertyName("address2_shippingmethodcode")] + public int? Address2ShippingMethodCode { get; set; } + + /// + /// Modified on behalf by value (null in this case) + /// + [JsonPropertyName("_modifiedonbehalfby_value")] + public string? ModifiedOnBehalfByValue { get; set; } + + /// + /// Indicates if it is read-only + /// + [JsonPropertyName("isreadonly")] + public bool IsReadOnly { get; set; } + + /// + /// Address 2 state or province (null in this case) + /// + [JsonPropertyName("address2_stateorprovince")] + public string? Address2StateOrProvince { get; set; } + + /// + /// Entity image timestamp (null in this case) + /// + [JsonPropertyName("entityimage_timestamp")] + public string? EntityImageTimestamp { get; set; } + + /// + /// Address 1 latitude (null in this case) + /// + [JsonPropertyName("address1_latitude")] + public string? Address1Latitude { get; set; } + + /// + /// Customization option value prefix + /// + [JsonPropertyName("customizationoptionvalueprefix")] + public int? CustomizationOptionValuePrefix { get; set; } + + /// + /// Address 2 latitude (null in this case) + /// + [JsonPropertyName("address2_latitude")] + public string? Address2Latitude { get; set; } + + /// + /// Address 1 longitude (null in this case) + /// + [JsonPropertyName("address1_longitude")] + public string? Address1Longitude { get; set; } + + /// + /// Address 1 line 2 (null in this case) + /// + [JsonPropertyName("address1_line2")] + public string? Address1Line2 { get; set; } + + /// + /// Friendly name + /// + [JsonPropertyName("friendlyname")] + public string? FriendlyName { get; set; } + + /// + /// Supporting website URL + /// + [JsonPropertyName("supportingwebsiteurl")] + public string? SupportingWebsiteUrl { get; set; } + + /// + /// Address 2 line 2 (null in this case) + /// + [JsonPropertyName("address2_line2")] + public string? Address2Line2 { get; set; } + + /// + /// Address 2 postal code (null in this case) + /// + [JsonPropertyName("address2_postalcode")] + public string? Address2PostalCode { get; set; } + + /// + /// Organization ID value + /// + [JsonPropertyName("_organizationid_value")] + public string? OrganizationIdValue { get; set; } + + /// + /// Version number + /// + [JsonPropertyName("versionnumber")] + public int? VersionNumber { get; set; } + + /// + /// Address 2 UPS zone (null in this case) + /// + [JsonPropertyName("address2_upszone")] + public string? Address2UpsZone { get; set; } + + /// + /// Address 2 longitude (null in this case) + /// + [JsonPropertyName("address2_longitude")] + public string? Address2Longitude { get; set; } + + /// + /// Address 1 fax (null in this case) + /// + [JsonPropertyName("address1_fax")] + public string? Address1Fax { get; set; } + + /// + /// Customization prefix + /// + [JsonPropertyName("customizationprefix")] + public string? CustomizationPrefix { get; set; } + + /// + /// Created on behalf by value (null in this case) + /// + [JsonPropertyName("_createdonbehalfby_value")] + public string? CreatedOnBehalfByValue { get; set; } + + /// + /// Modified by value + /// + [JsonPropertyName("_modifiedby_value")] + public string? ModifiedByValue { get; set; } + + /// + /// Date and time when created + /// + [JsonPropertyName("createdon")] + public string? CreatedOn { get; set; } + + /// + /// Address 2 country (null in this case) + /// + [JsonPropertyName("address2_country")] + public string? Address2Country { get; set; } + + /// + /// Description (null in this case) + /// + [JsonPropertyName("description")] + public string? Description { get; set; } + + /// + /// Address 2 address ID + /// + [JsonPropertyName("address2_addressid")] + public string? Address2AddressId { get; set; } + + /// + /// Address 1 shipping method code + /// + [JsonPropertyName("address1_shippingmethodcode")] + public int? Address1ShippingMethodCode { get; set; } + + /// + /// Address 1 post office box (null in this case) + /// + [JsonPropertyName("address1_postofficebox")] + public string? Address1PostOfficeBox { get; set; } + + /// + /// Address 1 UPS zone (null in this case) + /// + [JsonPropertyName("address1_upszone")] + public string? Address1UpsZone { get; set; } + + /// + /// Address 1 address type code + /// + [JsonPropertyName("address1_addresstypecode")] + public int? Address1AddressTypeCode { get; set; } + + /// + /// Address 1 country (null in this case) + /// + [JsonPropertyName("address1_country")] + public string? Address1Country { get; set; } + + /// + /// Entity image ID (null in this case) + /// + [JsonPropertyName("entityimageid")] + public string? EntityImageId { get; set; } + + /// + /// Entity image (null in this case) + /// + [JsonPropertyName("entityimage")] + public string? EntityImage { get; set; } + + /// + /// Created by value + /// + [JsonPropertyName("_createdby_value")] + public string? CreatedByValue { get; set; } + + /// + /// Address 1 telephone 3 (null in this case) + /// + [JsonPropertyName("address1_telephone3")] + public string? Address1Telephone3 { get; set; } + + /// + /// Address 1 city (null in this case) + /// + [JsonPropertyName("address1_city")] + public string? Address1City { get; set; } + + /// + /// Address 1 telephone 2 (null in this case) + /// + [JsonPropertyName("address1_telephone2")] + public string? Address1Telephone2 { get; set; } + + /// + /// Address 1 telephone 1 (null in this case) + /// + [JsonPropertyName("address1_telephone1")] + public string? Address1Telephone1 { get; set; } + } +} + diff --git a/src/Commands/PowerPlatform/Environment/GetPowerPlatformConnector.cs b/src/Commands/PowerPlatform/Environment/GetPowerPlatformCustomConnector.cs similarity index 70% rename from src/Commands/PowerPlatform/Environment/GetPowerPlatformConnector.cs rename to src/Commands/PowerPlatform/Environment/GetPowerPlatformCustomConnector.cs index 870b9ae25..53966935d 100644 --- a/src/Commands/PowerPlatform/Environment/GetPowerPlatformConnector.cs +++ b/src/Commands/PowerPlatform/Environment/GetPowerPlatformCustomConnector.cs @@ -7,18 +7,15 @@ namespace PnP.PowerShell.Commands.PowerPlatform.Environment { - [Cmdlet(VerbsCommon.Get, "PnPPowerPlatformConnector")] - public class GetPowerPlatformConnector : PnPAzureManagementApiCmdlet + [Cmdlet(VerbsCommon.Get, "PnPPowerPlatformCustomConnector")] + public class GetPowerPlatformCustomConnector : PnPAzureManagementApiCmdlet { [Parameter(Mandatory = false, ValueFromPipeline = true)] public PowerPlatformEnvironmentPipeBind Environment; [Parameter(Mandatory = false)] - public SwitchParameter AsAdmin; - - [Parameter(Mandatory = false)] - public PowerPlatformConnectorPipeBind Identity; + public PowerPlatformCustomConnectorPipeBind Identity; protected override void ExecuteCmdlet() { @@ -40,21 +37,22 @@ protected override void ExecuteCmdlet() WriteVerbose($"Using default environment as retrieved '{environmentName}'"); } - + var apiURL = $"https://api.powerapps.com/providers/Microsoft.PowerApps/apis?api-version=2016-11-01&$filter=environment eq '{environmentName}' and isCustomApi eq 'True'"; 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); + var connectors = GraphHelper.GetResultCollectionAsync(Connection, apiURL , AccessToken).GetAwaiter().GetResult(); + var connector = connectors.FirstOrDefault(e => e.Properties.displayName == appName); + WriteObject(connector, 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(); + var connectors = GraphHelper.GetResultCollectionAsync(Connection, apiURL, AccessToken).GetAwaiter().GetResult(); WriteObject(connectors, true); } } diff --git a/src/Commands/PowerPlatform/Environment/GetPowerPlatformSolution.cs b/src/Commands/PowerPlatform/Environment/GetPowerPlatformSolution.cs new file mode 100644 index 000000000..8a7d458eb --- /dev/null +++ b/src/Commands/PowerPlatform/Environment/GetPowerPlatformSolution.cs @@ -0,0 +1,64 @@ +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, "PnPPowerPlatformSolution")] + public class GetPowerPlatformSolution: PnPAzureManagementApiCmdlet + { + + [Parameter(Mandatory = false, ValueFromPipeline = true)] + public PowerPlatformEnvironmentPipeBind Environment; + + [Parameter(Mandatory = false)] + public PowerPlatformSolutionPipeBind Name; + + protected override void ExecuteCmdlet() + { + string environmentName = null; + string dynamicsScopeUrl = null; + var environments = GraphHelper.GetResultCollectionAsync(Connection, "https://management.azure.com/providers/Microsoft.ProcessSimple/environments?api-version=2016-11-01", AccessToken).GetAwaiter().GetResult(); + if (ParameterSpecified(nameof(Environment))) + { + environmentName = Environment.GetName().ToLower(); + WriteVerbose($"Using environment as provided '{environmentName}'"); + dynamicsScopeUrl = environments.FirstOrDefault(e => e.Properties.DisplayName.ToLower() == environmentName || e.Name.ToLower() == environmentName)?.Properties.LinkedEnvironmentMetadata.InstanceApiUrl; + } + else + { + environmentName = environments.FirstOrDefault(e => e.Properties.IsDefault.HasValue && e.Properties.IsDefault == true)?.Name; + dynamicsScopeUrl = environments.FirstOrDefault(e => e.Properties.IsDefault.HasValue && e.Properties.IsDefault == true)?.Properties.LinkedEnvironmentMetadata.InstanceApiUrl; + 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}'"); + } + + string accessTokenForGettingSolutions = TokenHandler.GetAccessTokenforPowerPlatformSolutions(this, Connection, dynamicsScopeUrl); + + if (ParameterSpecified(nameof(Name))) + { + var solutionName = Name.GetName(); + + WriteVerbose($"Retrieving specific solution with the provided name '{solutionName}' within the environment '{environmentName}'"); + + var requestUrl = dynamicsScopeUrl + "/api/data/v9.0/solutions?$filter=isvisible eq true and friendlyname eq '" + solutionName + "'&$expand=publisherid&api-version=9.1"; + var solution = GraphHelper.GetResultCollectionAsync(Connection, requestUrl, accessTokenForGettingSolutions).GetAwaiter().GetResult(); + WriteObject(solution, false); + } + else + { + WriteVerbose($"Retrieving all Solutions within environment '{environmentName}'"); + var requestUrl = dynamicsScopeUrl + "/api/data/v9.0/solutions?$filter=isvisible eq true&$expand=publisherid($select=friendlyname)&api-version=9.1"; + var solutions = GraphHelper.GetResultCollectionAsync(Connection, requestUrl, accessTokenForGettingSolutions).GetAwaiter().GetResult(); + WriteObject(solutions, true); + } + } + } +} \ No newline at end of file