Skip to content

Commit 112512e

Browse files
authored
Add default filter to retrieve tickets from the past week for Get-AzSupportTickets and Get-AzSupportTicketsNoSubscription (#10)
* add custom filtering for list support ticket if no filter is applied
1 parent 615e1c5 commit 112512e

File tree

9 files changed

+288
-73
lines changed

9 files changed

+288
-73
lines changed

src/Support/Support.Autorest/README.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,14 @@ directive:
153153
verb: New
154154
subject: FilesNoSubscription
155155
hide: true
156+
- where:
157+
verb: Get
158+
subject: SupportTicket
159+
hide: true
160+
- where:
161+
verb: Get
162+
subject: SupportTicketsNoSubscription
163+
hide: true
156164
- where:
157165
verb: Update
158166
subject: File

src/Support/Support.Autorest/UX/Microsoft.Support/supportTickets.json

Lines changed: 0 additions & 70 deletions
This file was deleted.
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
14+
# is regenerated.
15+
# ----------------------------------------------------------------------------------
16+
17+
<#
18+
.Synopsis
19+
Get ticket details for an Azure subscription.
20+
Support ticket data is available for 18 months after ticket creation.
21+
If a ticket was created more than 18 months ago, a request for data might cause an error.
22+
If no parameters are specified, then this command will retrieve all tickets created in the last week by default.
23+
.Description
24+
Get ticket details for an Azure subscription.
25+
Support ticket data is available for 18 months after ticket creation.
26+
If a ticket was created more than 18 months ago, a request for data might cause an error.
27+
If no parameters are specified, then this command will retrieve all tickets created in the last week by default.
28+
.Example
29+
{{ Add code here }}
30+
.Example
31+
{{ Add code here }}
32+
33+
.Outputs
34+
Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportTicketDetails
35+
.Link
36+
https://learn.microsoft.com/powershell/module/az.support/get-azsupportticket
37+
#>
38+
function Get-AzSupportTicket {
39+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportTicketDetails])]
40+
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
41+
param(
42+
[Parameter(ParameterSetName='Get', Mandatory)]
43+
[Alias('SupportTicketName')]
44+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')]
45+
[System.String]
46+
# Support ticket name.
47+
${Name},
48+
49+
[Parameter(ParameterSetName='Get')]
50+
[Parameter(ParameterSetName='List')]
51+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')]
52+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.DefaultInfo(Script='(Get-AzContext).Subscription.Id')]
53+
[System.String[]]
54+
# Azure subscription Id.
55+
${SubscriptionId},
56+
57+
[Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline)]
58+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')]
59+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportIdentity]
60+
# Identity Parameter
61+
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
62+
${InputObject},
63+
64+
[Parameter(ParameterSetName='List')]
65+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Query')]
66+
[System.String]
67+
# The filter to apply on the operation.
68+
# We support 'odata v4.0' filter semantics.
69+
# [Learn more](https://docs.microsoft.com/odata/concepts/queryoptions-overview).
70+
# _Status_, _ServiceId_, and _ProblemClassificationId_ filters can only be used with Equals ('eq') operator.
71+
# For _CreatedDate_ filter, the supported operators are Greater Than ('gt') and Greater Than or Equals ('ge').
72+
# When using both filters, combine them using the logical 'AND'.
73+
${Filter},
74+
75+
[Parameter(ParameterSetName='List')]
76+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Query')]
77+
[System.Int32]
78+
# The number of values to return in the collection.
79+
# Default is 25 and max is 100.
80+
${Top},
81+
82+
[Parameter()]
83+
[Alias('AzureRMContext', 'AzureCredential')]
84+
[ValidateNotNull()]
85+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Azure')]
86+
[System.Management.Automation.PSObject]
87+
# The DefaultProfile parameter is not functional.
88+
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
89+
${DefaultProfile},
90+
91+
[Parameter(DontShow)]
92+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
93+
[System.Management.Automation.SwitchParameter]
94+
# Wait for .NET debugger to attach
95+
${Break},
96+
97+
[Parameter(DontShow)]
98+
[ValidateNotNull()]
99+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
100+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.SendAsyncStep[]]
101+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
102+
${HttpPipelineAppend},
103+
104+
[Parameter(DontShow)]
105+
[ValidateNotNull()]
106+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
107+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.SendAsyncStep[]]
108+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
109+
${HttpPipelinePrepend},
110+
111+
[Parameter(DontShow)]
112+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
113+
[System.Uri]
114+
# The URI for the proxy server to use
115+
${Proxy},
116+
117+
[Parameter(DontShow)]
118+
[ValidateNotNull()]
119+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
120+
[System.Management.Automation.PSCredential]
121+
# Credentials for a proxy server to use for the remote call
122+
${ProxyCredential},
123+
124+
[Parameter(DontShow)]
125+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
126+
[System.Management.Automation.SwitchParameter]
127+
# Use the default credentials for the proxy
128+
${ProxyUseDefaultCredentials}
129+
)
130+
131+
process {
132+
If($PSCmdlet.ParameterSetName -eq 'List' -and !$PSBoundParameters.ContainsKey('Top') -and !$PSBoundParameters.ContainsKey('Filter')){
133+
$OneWeekAgo = (Get-Date).AddDays(-7).ToString("yyyy-MM-ddTHH:mm:ssZ")
134+
$Filter = "CreatedDate ge $($OneWeekAgo)"
135+
$PSBoundParameters.Add('Filter', $Filter)
136+
}
137+
Az.Support.internal\Get-AzSupportTicket @PSBoundParameters
138+
}
139+
}
Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
2+
# ----------------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
# http://www.apache.org/licenses/LICENSE-2.0
8+
# Unless required by applicable law or agreed to in writing, software
9+
# distributed under the License is distributed on an "AS IS" BASIS,
10+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11+
# See the License for the specific language governing permissions and
12+
# limitations under the License.
13+
# Code generated by Microsoft (R) AutoRest Code Generator.Changes may cause incorrect behavior and will be lost if the code
14+
# is regenerated.
15+
# ----------------------------------------------------------------------------------
16+
17+
<#
18+
.Synopsis
19+
Gets details for a specific support ticket.
20+
Support ticket data is available for 18 months after ticket creation.
21+
If a ticket was created more than 18 months ago, a request for data might cause an error.
22+
If no parameters are specified, then this command will retrieve all tickets created in the last week by default.
23+
.Description
24+
Gets details for a specific support ticket.
25+
Support ticket data is available for 18 months after ticket creation.
26+
If a ticket was created more than 18 months ago, a request for data might cause an error.
27+
If no parameters are specified, then this command will retrieve all tickets created in the last week by default.
28+
.Example
29+
{{ Add code here }}
30+
.Example
31+
{{ Add code here }}
32+
33+
.Outputs
34+
Microsoft.Azure.PowerShell.Cmdlets.Support.Models.IFileDetails
35+
.Link
36+
https://learn.microsoft.com/powershell/module/az.support/get-azsupportticketsnosubscription
37+
#>
38+
function Get-AzSupportTicketsNoSubscription {
39+
[OutputType([Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportTicketDetails])]
40+
[CmdletBinding(DefaultParameterSetName='List', PositionalBinding=$false)]
41+
param(
42+
[Parameter(ParameterSetName='Get', Mandatory)]
43+
[Alias('Name')]
44+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')]
45+
[System.String]
46+
# Support ticket name.
47+
${SupportTicketName},
48+
49+
[Parameter(ParameterSetName='GetViaIdentity', Mandatory, ValueFromPipeline)]
50+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Path')]
51+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Models.ISupportIdentity]
52+
# Identity Parameter
53+
# To construct, see NOTES section for INPUTOBJECT properties and create a hash table.
54+
${InputObject},
55+
56+
[Parameter(ParameterSetName='List')]
57+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Query')]
58+
[System.String]
59+
# The filter to apply on the operation.
60+
# We support 'odata v4.0' filter semantics.
61+
# <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.
62+
# For <i>CreatedDate</i> filter, the supported operators are 'gt' and 'ge'.
63+
# When using both filters, combine them using the logical 'AND'.
64+
${Filter},
65+
66+
[Parameter(ParameterSetName='List')]
67+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Query')]
68+
[System.Int32]
69+
# The number of values to return in the collection.
70+
# Default is 25 and max is 100.
71+
${Top},
72+
73+
[Parameter()]
74+
[Alias('AzureRMContext', 'AzureCredential')]
75+
[ValidateNotNull()]
76+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Azure')]
77+
[System.Management.Automation.PSObject]
78+
# The DefaultProfile parameter is not functional.
79+
# Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.
80+
${DefaultProfile},
81+
82+
[Parameter(DontShow)]
83+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
84+
[System.Management.Automation.SwitchParameter]
85+
# Wait for .NET debugger to attach
86+
${Break},
87+
88+
[Parameter(DontShow)]
89+
[ValidateNotNull()]
90+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
91+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.SendAsyncStep[]]
92+
# SendAsync Pipeline Steps to be appended to the front of the pipeline
93+
${HttpPipelineAppend},
94+
95+
[Parameter(DontShow)]
96+
[ValidateNotNull()]
97+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
98+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Runtime.SendAsyncStep[]]
99+
# SendAsync Pipeline Steps to be prepended to the front of the pipeline
100+
${HttpPipelinePrepend},
101+
102+
[Parameter(DontShow)]
103+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
104+
[System.Uri]
105+
# The URI for the proxy server to use
106+
${Proxy},
107+
108+
[Parameter(DontShow)]
109+
[ValidateNotNull()]
110+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
111+
[System.Management.Automation.PSCredential]
112+
# Credentials for a proxy server to use for the remote call
113+
${ProxyCredential},
114+
115+
[Parameter(DontShow)]
116+
[Microsoft.Azure.PowerShell.Cmdlets.Support.Category('Runtime')]
117+
[System.Management.Automation.SwitchParameter]
118+
# Use the default credentials for the proxy
119+
${ProxyUseDefaultCredentials}
120+
)
121+
122+
process {
123+
If($PSCmdlet.ParameterSetName -eq 'List' -and !$PSBoundParameters.ContainsKey('Top') -and !$PSBoundParameters.ContainsKey('Filter')){
124+
$OneWeekAgo = (Get-Date).AddDays(-7).ToString("yyyy-MM-ddTHH:mm:ssZ")
125+
$Filter = "CreatedDate ge $($OneWeekAgo)"
126+
$PSBoundParameters.Add('Filter', $Filter)
127+
}
128+
Az.Support.internal\Get-AzSupportTicketsNoSubscription @PSBoundParameters
129+
}
130+
}

src/Support/Support.Autorest/docs/Az.Support.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,13 @@ Gets a specific Azure service for support ticket creation.
4848
Get ticket details for an Azure subscription.
4949
Support ticket data is available for 18 months after ticket creation.
5050
If a ticket was created more than 18 months ago, a request for data might cause an error.
51+
If no parameters are specified, then this command will retrieve all tickets created in the last week by default.
5152

5253
### [Get-AzSupportTicketsNoSubscription](Get-AzSupportTicketsNoSubscription.md)
5354
Gets details for a specific support ticket.
5455
Support ticket data is available for 18 months after ticket creation.
5556
If a ticket was created more than 18 months ago, a request for data might cause an error.
57+
If no parameters are specified, then this command will retrieve all tickets created in the last week by default.
5658

5759
### [New-AzSupportCommunication](New-AzSupportCommunication.md)
5860
Adds a new customer communication to an Azure support ticket.

src/Support/Support.Autorest/docs/Get-AzSupportTicket.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ schema: 2.0.0
1111
Get ticket details for an Azure subscription.
1212
Support ticket data is available for 18 months after ticket creation.
1313
If a ticket was created more than 18 months ago, a request for data might cause an error.
14+
If no parameters are specified, then this command will retrieve all tickets created in the last week by default.
1415

1516
## SYNTAX
1617

@@ -35,6 +36,7 @@ Get-AzSupportTicket -InputObject <ISupportIdentity> [-DefaultProfile <PSObject>]
3536
Get ticket details for an Azure subscription.
3637
Support ticket data is available for 18 months after ticket creation.
3738
If a ticket was created more than 18 months ago, a request for data might cause an error.
39+
If no parameters are specified, then this command will retrieve all tickets created in the last week by default.
3840

3941
## EXAMPLES
4042

@@ -49,7 +51,8 @@ Name Title
4951
517f2da6-9bc71cda-278fc71b-7b86-4289-baec-922e8be1a04a test 2403080040012292 Minimal Billing 3/8/2024 9:03:26 PM
5052
test1-5dda17d0-a60d-4f4c-82e3-0fe3604c0ed4 test ticket - please ignore and close 2403060040007460 Minimal Billing 3/6/2024 3:09:28 PM
5153
52-
Lists all the support tickets for an Azure subscription
54+
Lists all the support tickets for an Azure subscription.
55+
If no parameters are specified, then this command will retrieve all tickets created in the last week by default.
5356
5457
### Example 2: Get a support ticket at subscription level
5558
```powershell

0 commit comments

Comments
 (0)