forked from Azure/azure-powershell
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add default filter to retrieve tickets from the past week for Get-AzS…
…upportTickets and Get-AzSupportTicketsNoSubscription (#10) * add custom filtering for list support ticket if no filter is applied
- Loading branch information
1 parent
615e1c5
commit 112512e
Showing
9 changed files
with
288 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 0 additions & 70 deletions
70
src/Support/Support.Autorest/UX/Microsoft.Support/supportTickets.json
This file was deleted.
Oops, something went wrong.
139 changes: 139 additions & 0 deletions
139
src/Support/Support.Autorest/custom/Get-AzSupportTicket.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
|
||
# ---------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code | ||
# is regenerated. | ||
# ---------------------------------------------------------------------------------- | ||
|
||
<# | ||
.Synopsis | ||
Get ticket details for an Azure subscription. | ||
Support ticket data is available for 18 months after ticket creation. | ||
If a ticket was created more than 18 months ago, a request for data might cause an error. | ||
If no parameters are specified, then this command will retrieve all tickets created in the last week by default. | ||
.Description | ||
Get ticket details for an Azure subscription. | ||
Support ticket data is available for 18 months after ticket creation. | ||
If a ticket was created more than 18 months ago, a request for data might cause an error. | ||
If no parameters are specified, then this command will retrieve all tickets created in the last week by default. | ||
.Example | ||
{{ Add code here }} | ||
.Example | ||
{{ Add code here }} | ||
.Outputs | ||
Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportTicketDetails | ||
.Link | ||
https://learn.microsoft.com/powershell/module/az.support/get-azsupportticket | ||
#> | ||
function Get-AzSupportTicket { | ||
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportTicketDetails])] | ||
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] | ||
param( | ||
[Parameter(ParameterSetName='Get', Mandatory)] | ||
[Alias('SupportTicketName')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')] | ||
[System.String] | ||
# Support ticket name. | ||
${Name}, | ||
|
||
[Parameter(ParameterSetName='Get')] | ||
[Parameter(ParameterSetName='List')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')] | ||
[System.String[]] | ||
# Azure subscription Id. | ||
${SubscriptionId}, | ||
|
||
[Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportIdentity] | ||
# Identity Parameter | ||
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table. | ||
${InputObject}, | ||
|
||
[Parameter(ParameterSetName='List')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Query')] | ||
[System.String] | ||
# The filter to apply on the operation. | ||
# We support 'odata v4.0' filter semantics. | ||
# [Learn more](https://docs.microsoft.com/odata/concepts/queryoptions-overview). | ||
# _Status_, _ServiceId_, and _ProblemClassificationId_ filters can only be used with Equals ('eq') operator. | ||
# For _CreatedDate_ filter, the supported operators are Greater Than ('gt') and Greater Than or Equals ('ge'). | ||
# When using both filters, combine them using the logical 'AND'. | ||
${Filter}, | ||
|
||
[Parameter(ParameterSetName='List')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Query')] | ||
[System.Int32] | ||
# The number of values to return in the collection. | ||
# Default is 25 and max is 100. | ||
${Top}, | ||
|
||
[Parameter()] | ||
[Alias('AzureRMContext', 'AzureCredential')] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Azure')] | ||
[System.Management.Automation.PSObject] | ||
# The DefaultProfile parameter is not functional. | ||
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription. | ||
${DefaultProfile}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
# Wait for .NET debugger to attach | ||
${Break}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be appended to the front of the pipeline | ||
${HttpPipelineAppend}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be prepended to the front of the pipeline | ||
${HttpPipelinePrepend}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[System.Uri] | ||
# The URI for the proxy server to use | ||
${Proxy}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[System.Management.Automation.PSCredential] | ||
# Credentials for a proxy server to use for the remote call | ||
${ProxyCredential}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
# Use the default credentials for the proxy | ||
${ProxyUseDefaultCredentials} | ||
) | ||
|
||
process { | ||
If($PSCmdlet.ParameterSetName -eq 'List' -and !$PSBoundParameters.ContainsKey('Top') -and !$PSBoundParameters.ContainsKey('Filter')){ | ||
$OneWeekAgo = (Get-Date).AddDays(-7).ToString("yyyy-MM-ddTHH:mm:ssZ") | ||
$Filter = "CreatedDate ge $($OneWeekAgo)" | ||
$PSBoundParameters.Add('Filter', $Filter) | ||
} | ||
Az.Support.internal\Get-AzSupportTicket @PSBoundParameters | ||
} | ||
} |
130 changes: 130 additions & 0 deletions
130
src/Support/Support.Autorest/custom/Get-AzSupportTicketsNoSubscription.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
|
||
# ---------------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code | ||
# is regenerated. | ||
# ---------------------------------------------------------------------------------- | ||
|
||
<# | ||
.Synopsis | ||
Gets details for a specific support ticket. | ||
Support ticket data is available for 18 months after ticket creation. | ||
If a ticket was created more than 18 months ago, a request for data might cause an error. | ||
If no parameters are specified, then this command will retrieve all tickets created in the last week by default. | ||
.Description | ||
Gets details for a specific support ticket. | ||
Support ticket data is available for 18 months after ticket creation. | ||
If a ticket was created more than 18 months ago, a request for data might cause an error. | ||
If no parameters are specified, then this command will retrieve all tickets created in the last week by default. | ||
.Example | ||
{{ Add code here }} | ||
.Example | ||
{{ Add code here }} | ||
.Outputs | ||
Microsoft.Azure.PowerShell.Cmdlets.Support.Models.IFileDetails | ||
.Link | ||
https://learn.microsoft.com/powershell/module/az.support/get-azsupportticketsnosubscription | ||
#> | ||
function Get-AzSupportTicketsNoSubscription { | ||
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportTicketDetails])] | ||
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)] | ||
param( | ||
[Parameter(ParameterSetName='Get', Mandatory)] | ||
[Alias('Name')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')] | ||
[System.String] | ||
# Support ticket name. | ||
${SupportTicketName}, | ||
|
||
[Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportIdentity] | ||
# Identity Parameter | ||
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table. | ||
${InputObject}, | ||
|
||
[Parameter(ParameterSetName='List')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Query')] | ||
[System.String] | ||
# The filter to apply on the operation. | ||
# We support 'odata v4.0' filter semantics. | ||
# <a target='_blank' href='https://docs.microsoft.com/odata/concepts/queryoptions-overview'>Learn more</a> <br/><i>Status</i> , <i>ServiceId</i>, and <i>ProblemClassificationId</i> filters can only be used with 'eq' operator. | ||
# For <i>CreatedDate</i> filter, the supported operators are 'gt' and 'ge'. | ||
# When using both filters, combine them using the logical 'AND'. | ||
${Filter}, | ||
|
||
[Parameter(ParameterSetName='List')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Query')] | ||
[System.Int32] | ||
# The number of values to return in the collection. | ||
# Default is 25 and max is 100. | ||
${Top}, | ||
|
||
[Parameter()] | ||
[Alias('AzureRMContext', 'AzureCredential')] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Azure')] | ||
[System.Management.Automation.PSObject] | ||
# The DefaultProfile parameter is not functional. | ||
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription. | ||
${DefaultProfile}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
# Wait for .NET debugger to attach | ||
${Break}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be appended to the front of the pipeline | ||
${HttpPipelineAppend}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.SendAsyncStep[]] | ||
# SendAsync Pipeline Steps to be prepended to the front of the pipeline | ||
${HttpPipelinePrepend}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[System.Uri] | ||
# The URI for the proxy server to use | ||
${Proxy}, | ||
|
||
[Parameter(DontShow)] | ||
[ValidateNotNull()] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[System.Management.Automation.PSCredential] | ||
# Credentials for a proxy server to use for the remote call | ||
${ProxyCredential}, | ||
|
||
[Parameter(DontShow)] | ||
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')] | ||
[System.Management.Automation.SwitchParameter] | ||
# Use the default credentials for the proxy | ||
${ProxyUseDefaultCredentials} | ||
) | ||
|
||
process { | ||
If($PSCmdlet.ParameterSetName -eq 'List' -and !$PSBoundParameters.ContainsKey('Top') -and !$PSBoundParameters.ContainsKey('Filter')){ | ||
$OneWeekAgo = (Get-Date).AddDays(-7).ToString("yyyy-MM-ddTHH:mm:ssZ") | ||
$Filter = "CreatedDate ge $($OneWeekAgo)" | ||
$PSBoundParameters.Add('Filter', $Filter) | ||
} | ||
Az.Support.internal\Get-AzSupportTicketsNoSubscription @PSBoundParameters | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.