/
ContainerResponse.cs
81 lines (68 loc) · 2.69 KB
/
ContainerResponse.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
81
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace Microsoft.Azure.Cosmos
{
using System.Net;
/// <summary>
/// The cosmos container response
/// </summary>
public class ContainerResponse : Response<ContainerProperties>
{
/// <summary>
/// Create a <see cref="ContainerResponse"/> as a no-op for mock testing
/// </summary>
protected ContainerResponse()
: base()
{
}
/// <summary>
/// A private constructor to ensure the factory is used to create the object.
/// This will prevent memory leaks when handling the HttpResponseMessage
/// </summary>
internal ContainerResponse(
HttpStatusCode httpStatusCode,
Headers headers,
ContainerProperties containerProperties,
Container container,
CosmosDiagnostics diagnostics,
RequestMessage requestMessage)
{
this.StatusCode = httpStatusCode;
this.Headers = headers;
this.Resource = containerProperties;
this.Container = container;
this.Diagnostics = diagnostics;
this.RequestMessage = requestMessage;
}
/// <summary>
/// The reference to the cosmos container. This allows additional operations on the container
/// or for easy access to other references like Items, StoredProcedures, etc..
/// </summary>
public virtual Container Container { get; private set; }
/// <inheritdoc/>
public override Headers Headers { get; }
/// <inheritdoc/>
public override ContainerProperties Resource { get; }
/// <inheritdoc/>
public override HttpStatusCode StatusCode { get; }
/// <inheritdoc/>
public override CosmosDiagnostics Diagnostics { get; }
/// <inheritdoc/>
public override double RequestCharge => this.Headers?.RequestCharge ?? 0;
/// <inheritdoc/>
public override string ActivityId => this.Headers?.ActivityId;
/// <inheritdoc/>
public override string ETag => this.Headers?.ETag;
/// <inheritdoc/>
internal override RequestMessage RequestMessage { get; }
/// <summary>
/// Get <see cref="Cosmos.Container"/> implicitly from <see cref="ContainerResponse"/>
/// </summary>
/// <param name="response">ContainerResponse</param>
public static implicit operator Container(ContainerResponse response)
{
return response.Container;
}
}
}