Skip to content

Commit

Permalink
added name as primary key
Browse files Browse the repository at this point in the history
  • Loading branch information
ritikmit committed Oct 8, 2024
1 parent e314857 commit 5086ba8
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ function Get-TargetResource
[OutputType([System.Collections.Hashtable])]
param
(
[Parameter()]
[Parameter(Mandatory = $true)]
[System.String]
$Name,

Expand All @@ -13,12 +13,10 @@ function Get-TargetResource
[System.String]
$Region,

[Parameter(Mandatory = $true)]
[Parameter()]
[System.String]
$Id,

#endregion

[Parameter()]
[System.String]
[ValidateSet('Absent', 'Present')]
Expand Down Expand Up @@ -75,19 +73,42 @@ function Get-TargetResource

$getValue = $null
#region resource generator code
$getValue = Get-MgBetaOnPremisePublishingProfileConnectorGroup `
-ConnectorGroupId $Id `
-OnPremisesPublishingProfileId 'applicationProxy' -ErrorAction SilentlyContinue
if (-not [string]::IsNullOrEmpty($Id))
{
if ($null -ne $Script:exportedInstances -and $Script:ExportMode)
{
$getValue = $Script:exportedInstances | Where-Object -FilterScript {$_.Id -eq $Id}
}
else
{
$getValue = Get-MgBetaOnPremisePublishingProfileConnectorGroup -ConnectorGroupId $Id -OnPremisesPublishingProfileId 'applicationProxy' -ErrorAction SilentlyContinue
}
}

if ($null -eq $getValue -and -not [string]::IsNullOrEmpty($Id))
{
Write-Verbose -Message "Could not find an Azure AD Connector Group Application Proxy with Name {$Name}"
if (-Not [string]::IsNullOrEmpty($DisplayName))
{
if ($null -ne $Script:exportedInstances -and $Script:ExportMode)
{
$getValue = $Script:exportedInstances | Where-Object -FilterScript {$_.Name -eq $Name}
}
else
{
$getValue = Get-MgBetaOnPremisePublishingProfileConnectorGroup -OnPremisesPublishingProfileId 'applicationProxy' -Filter "Name eq '$Name'" -ErrorAction Stop
}
}
}
#endregion
if ($null -eq $getValue)
{
Write-Verbose -Message "Could not find an Azure AD Connector Group Application Proxy with Id {$Id}"
Write-Verbose -Message "Could not find an Azure AD Connector Group Application Proxy with Name {$Name}"
return $nullResult
}
#endregion

$Id = $getValue.Id
Write-Verbose -Message "An Azure AD Connector Group Application Proxy with Id {$Id} was found"
Write-Verbose -Message "An Azure AD Connector Group Application Proxy with Id {$Id} and Name {$Name} was found"

$enumRegion = $null
if ($null -ne $getValue.Region)
Expand Down Expand Up @@ -130,7 +151,7 @@ function Set-TargetResource
[CmdletBinding()]
param
(
[Parameter()]
[Parameter(Mandatory = $true)]
[System.String]
$Name,

Expand All @@ -139,11 +160,10 @@ function Set-TargetResource
[System.String]
$Region,

[Parameter(Mandatory = $true)]
[Parameter()]
[System.String]
$Id,

#endregion
[Parameter()]
[System.String]
[ValidateSet('Absent', 'Present')]
Expand Down Expand Up @@ -240,7 +260,7 @@ function Test-TargetResource
param
(
#region resource generator code
[Parameter()]
[Parameter(Mandatory = $true)]
[System.String]
$Name,

Expand All @@ -249,7 +269,7 @@ function Test-TargetResource
[System.String]
$Region,

[Parameter(Mandatory = $true)]
[Parameter()]
[System.String]
$Id,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
[ClassVersion("1.0.0.0"), FriendlyName("AADConnectorGroupApplicationProxy")]
class MSFT_AADConnectorGroupApplicationProxy : OMI_BaseResource
{
[Write, Description("The name associated with the connectorGroup.")] String Name;
[Key, Description("The name associated with the connectorGroup.")] String Name;
[Write, Description("The region the connectorGroup is assigned to and will optimize traffic for. This region can only be set if no connectors or applications are assigned to the connectorGroup. The possible values are: nam (for North America), eur (for Europe), aus (for Australia), asia (for Asia), ind (for India), and unknownFutureValue."), ValueMap{"nam","eur","aus","asia","ind","unknownFutureValue"}, Values{"nam","eur","aus","asia","ind","unknownFutureValue"}] String Region;
[Key, Description("The unique identifier for an entity. Read-only.")] String Id;
[Write, Description("The unique identifier for an entity. Read-only.")] String Id;
[Write, Description("Present ensures the policy exists, absent ensures it is removed."), ValueMap{"Present","Absent"}, Values{"Present","Absent"}] string Ensure;
[Write, Description("Credentials of the Admin"), EmbeddedInstance("MSFT_Credential")] string Credential;
[Write, Description("Id of the Azure Active Directory application to authenticate with.")] String ApplicationId;
Expand Down

0 comments on commit 5086ba8

Please sign in to comment.