-
Notifications
You must be signed in to change notification settings - Fork 4.5k
/
ExceptionPolicy.cs
80 lines (71 loc) · 2.58 KB
/
ExceptionPolicy.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.Json;
using Azure.Core;
namespace Azure.Communication.JobRouter
{
public partial class ExceptionPolicy : IUtf8JsonSerializable
{
/// <summary> Initializes a new instance of an exception policy. </summary>
/// <param name="exceptionPolicyId"> Id of an exception policy. </param>
/// <exception cref="ArgumentNullException"> <paramref name="exceptionPolicyId"/> is null. </exception>
public ExceptionPolicy(string exceptionPolicyId)
{
Argument.AssertNotNullOrWhiteSpace(exceptionPolicyId, nameof(exceptionPolicyId));
Id = exceptionPolicyId;
}
/// <summary> A collection of exception rules on the exception policy. </summary>
public IList<ExceptionRule> ExceptionRules { get; } = new List<ExceptionRule>();
/// <summary> Friendly name of this policy. </summary>
public string Name { get; set; }
[CodeGenMember("Etag")]
internal string _etag
{
get
{
return ETag.ToString();
}
set
{
ETag = new ETag(value);
}
}
/// <summary> The entity tag for this resource. </summary>
public ETag ETag { get; internal set; }
void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
{
writer.WriteStartObject();
if (Optional.IsDefined(Name))
{
writer.WritePropertyName("name"u8);
writer.WriteStringValue(Name);
}
if (Optional.IsCollectionDefined(ExceptionRules))
{
writer.WritePropertyName("exceptionRules"u8);
writer.WriteStartArray();
foreach (var item in ExceptionRules)
{
writer.WriteObjectValue(item);
}
writer.WriteEndArray();
}
if (Optional.IsDefined(ETag))
{
writer.WritePropertyName("etag"u8);
writer.WriteStringValue(ETag.ToString());
}
writer.WriteEndObject();
}
/// <summary> Convert into a Utf8JsonRequestContent. </summary>
internal virtual RequestContent ToRequestContent()
{
var content = new Utf8JsonRequestContent();
content.JsonWriter.WriteObjectValue(this);
return content;
}
}
}