Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added additional constructor for AzOpsRoleEligibilityScheduleRequest #902

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/AzOps.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#
# Generated by: Customer Architecture Team (CAT)
#
# Generated on: 09/09/2024
# Generated on: 12/2/2024
#

@{
Expand Down Expand Up @@ -51,11 +51,11 @@ PowerShellVersion = '7.2'
# ProcessorArchitecture = ''

# Modules that must be imported into the global environment prior to importing this module
RequiredModules = @(@{ModuleName = 'PSFramework'; RequiredVersion = '1.11.343'; },
@{ModuleName = 'Az.Accounts'; RequiredVersion = '3.0.4'; },
@{ModuleName = 'Az.Billing'; RequiredVersion = '2.0.4'; },
@{ModuleName = 'Az.ResourceGraph'; RequiredVersion = '1.0.0'; },
@{ModuleName = 'Az.Resources'; RequiredVersion = '7.4.0'; })
RequiredModules = @(@{ModuleName = 'PSFramework'; RequiredVersion = '1.12.346'; },
@{ModuleName = 'Az.Accounts'; RequiredVersion = '4.0.0'; },
@{ModuleName = 'Az.Billing'; RequiredVersion = '2.1.0'; },
@{ModuleName = 'Az.ResourceGraph'; RequiredVersion = '1.0.1'; },
@{ModuleName = 'Az.Resources'; RequiredVersion = '7.6.0'; })

# Assemblies that must be loaded prior to importing this module
# RequiredAssemblies = @()
Expand Down
23 changes: 22 additions & 1 deletion src/internal/classes/AzOpsRoleEligibilityScheduleRequest.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,29 @@
StartDateTime = $roleEligibilitySchedule.StartDateTime
}
}
$this.Id = $roleEligibilityScheduleRequest.Id
$this.Id = $roleEligibilitySchedule.RequestId
$this.Name = $roleEligibilitySchedule.Name
$this.ResourceType = $roleEligibilityScheduleRequest.Type
}

AzOpsRoleEligibilityScheduleRequest($roleEligibilitySchedule) {
$this.Properties = [ordered]@{
Condition = $roleEligibilitySchedule.Condition
ConditionVersion = $roleEligibilitySchedule.ConditionVersion
PrincipalId = $roleEligibilitySchedule.PrincipalId
RoleDefinitionId = $roleEligibilitySchedule.RoleDefinitionId
RequestType = "AdminAssign"
ScheduleInfo = [ordered]@{
Expiration = [ordered]@{
EndDateTime = $roleEligibilitySchedule.EndDateTime
Duration = $roleEligibilitySchedule.ExpirationDuration
ExpirationType = if ($roleEligibilitySchedule.ExpirationType) {$roleEligibilitySchedule.ExpirationType.ToString()}
}
StartDateTime = $roleEligibilitySchedule.StartDateTime
}
}
$this.Id = $roleEligibilitySchedule.RequestId
$this.Name = $roleEligibilitySchedule.Name
$this.ResourceType = "Microsoft.Authorization/roleEligibilityScheduleRequests"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,18 @@
if ($roleEligibilitySchedules) {
foreach ($roleEligibilitySchedule in $roleEligibilitySchedules) {
# Process roleEligibilitySchedule together with RoleEligibilityScheduleRequest
$roleEligibilityScheduleRequest = $null
$roleEligibilityScheduleRequest = Get-AzRoleEligibilityScheduleRequest -Scope $ScopeObject.Scope -Name $roleEligibilitySchedule.Name -ErrorAction SilentlyContinue
if ($roleEligibilityScheduleRequest) {
Write-AzOpsMessage -LogLevel Debug -LogString 'Get-AzOpsRoleEligibilityScheduleRequest.Assignment' -LogStringValues $roleEligibilitySchedule.Name -Target $ScopeObject
# Construct AzOpsRoleEligibilityScheduleRequest by combining information from roleEligibilitySchedule and roleEligibilityScheduleRequest
[AzOpsRoleEligibilityScheduleRequest]::new($roleEligibilitySchedule, $roleEligibilityScheduleRequest)
}
else {
Write-AzOpsMessage -LogLevel Verbose -LogString 'Get-AzOpsRoleEligibilityScheduleRequest.Processing.NotFound' -LogStringValues $ScopeObject.Scope, $roleEligibilitySchedule.Name -Target $ScopeObject
# Construct AzOpsRoleEligibilityScheduleRequest from roleEligibilitySchedule since no AzRoleEligibilityScheduleRequest was found
[AzOpsRoleEligibilityScheduleRequest]::new($roleEligibilitySchedule)
}
}
}
}
Expand Down
1 change: 1 addition & 0 deletions src/localized/en-us/Strings.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,7 @@
'Get-AzOpsRoleDefinition.Definition' = 'Processing object {0}' # $roleDefinition.id

'Get-AzOpsRoleEligibilityScheduleRequest.Processing' = 'Retrieving Privileged Identity Management RoleEligibilitySchedule at [{0}]' # $ScopeObject.Scope
'Get-AzOpsRoleEligibilityScheduleRequest.Processing.NotFound' = 'No RoleEligibilityScheduleRequest found at [{0}] for RoleEligibilitySchedule [{1}], creating template based on RoleEligibilitySchedule' # $ScopeObject.Scope, $roleEligibilitySchedule.Name
'Get-AzOpsRoleEligibilityScheduleRequest.Assignment' = 'Found Privileged Identity Management RoleEligibilityScheduleRequest assignment [{0}]' # $roleEligibilitySchedule.Name

'Get-AzOpsSubscription.Excluded.Offers' = 'Excluded subscription offers: {0}' # ($ExcludedOffers -join ',')
Expand Down
4 changes: 2 additions & 2 deletions src/tests/templates/azuredeploy.jsonc
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@
"name": "TestPolicyAssignment",
"properties": {
"metadata": {
"customkey": "customvalue",
"customkey": "customvalue"
},
"policyDefinitionId": "/providers/Microsoft.Authorization/policyDefinitions/0a914e76-4921-4c19-b460-a2d36003525a"
}
Expand Down Expand Up @@ -551,7 +551,7 @@
},
{
"type": "Microsoft.Authorization/policyExemptions",
"apiVersion": "2020-07-01-preview",
"apiVersion": "2022-07-01-preview",
"name": "PolicyExemptionTest",
"properties": {
"displayName": "TestPolicyAssignment - PolicyExemptionTest",
Expand Down
Loading