-
Notifications
You must be signed in to change notification settings - Fork 477
/
DatabaseProperties.cs
124 lines (114 loc) · 5.33 KB
/
DatabaseProperties.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
//------------------------------------------------------------
// Copyright (c) Microsoft Corporation. All rights reserved.
//------------------------------------------------------------
namespace Microsoft.Azure.Cosmos
{
using System;
using System.Collections.Generic;
using Microsoft.Azure.Documents;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
/// <summary>
/// Represents a database in the Azure Cosmos DB account.
/// </summary>
/// <remarks>
/// Each Azure Cosmos DB database account can have zero or more databases. A database in Azure Cosmos DB is a logical container for
/// document collections and users.
/// Refer to <see>https://docs.microsoft.com/azure/cosmos-db/databases-containers-items#databases</see> for more details on databases.
/// </remarks>
/// <example>
/// The example below creates a new Database with an Id property of 'MyDatabase'.
/// <code language="c#">
/// <![CDATA[
/// using (CosmosClient client = new CosmosClient("connection string"))
/// {
/// DatabaseProperties db1 = await client.CreateDatabaseAsync("MyDatabase");
/// }
/// ]]>
/// </code>
/// </example>
public class DatabaseProperties
{
private string id;
/// <summary>
/// Initializes a new instance of the <see cref="DatabaseProperties"/> class for the Azure Cosmos DB service.
/// </summary>
public DatabaseProperties()
{
}
/// <summary>
/// Initializes a new instance of the <see cref="DatabaseProperties"/> class for the Azure Cosmos DB service.
/// </summary>
/// <param name="id">The Id of the resource in the Azure Cosmos service.</param>
public DatabaseProperties(string id)
{
this.Id = id;
}
/// <summary>
/// Gets or sets the Id of the resource in the Azure Cosmos DB service.
/// </summary>
/// <value>The Id associated with the resource.</value>
/// <remarks>
/// <para>
/// Every resource within an Azure Cosmos DB database account needs to have a unique identifier.
/// </para>
/// <para>
/// The following characters are restricted and cannot be used in the Id property:
/// '/', '\\', '?', '#'
/// </para>
/// </remarks>
[JsonProperty(PropertyName = Constants.Properties.Id)]
public string Id
{
get => this.id;
set => this.id = value ?? throw new ArgumentNullException(nameof(this.Id));
}
/// <summary>
/// Gets the entity tag associated with the resource from the Azure Cosmos DB service.
/// </summary>
/// <value>
/// The entity tag associated with the resource.
/// </value>
/// <remarks>
/// ETags are used for concurrency checking when updating resources.
/// </remarks>
[JsonProperty(PropertyName = Constants.Properties.ETag, NullValueHandling = NullValueHandling.Ignore)]
public string ETag { get; private set; }
/// <summary>
/// Gets the last modified time stamp associated with <see cref="DatabaseProperties" /> from the Azure Cosmos DB service.
/// </summary>
/// <value>The last modified time stamp associated with the resource.</value>
[JsonConverter(typeof(UnixDateTimeConverter))]
[JsonProperty(PropertyName = Constants.Properties.LastModified, NullValueHandling = NullValueHandling.Ignore)]
public DateTime? LastModified { get; private set; }
/// <summary>
/// Gets the self-link associated with the resource from the Azure Cosmos DB service.
/// </summary>
/// <value>The self-link associated with the resource.</value>
/// <remarks>
/// A self-link is a static addressable Uri for each resource within a database account and follows the Azure Cosmos DB resource model.
/// E.g. a self-link for a document could be dbs/db_resourceid/colls/coll_resourceid/documents/doc_resourceid
/// </remarks>
[JsonProperty(PropertyName = Constants.Properties.SelfLink, NullValueHandling = NullValueHandling.Ignore)]
public string SelfLink { get; private set; }
/// <summary>
/// Gets the Resource Id associated with the resource in the Azure Cosmos DB service.
/// </summary>
/// <value>
/// The Resource Id associated with the resource.
/// </value>
/// <remarks>
/// A Resource Id is the unique, immutable, identifier assigned to each Azure Cosmos DB
/// resource whether that is a database, a collection or a document.
/// These resource ids are used when building up SelfLinks, a static addressable Uri for each resource within a database account.
/// </remarks>
[JsonProperty(PropertyName = Constants.Properties.RId, NullValueHandling = NullValueHandling.Ignore)]
internal string ResourceId { get; private set; }
/// <summary>
/// This contains additional values for scenarios where the SDK is not aware of new fields.
/// This ensures that if resource is read and updated none of the fields will be lost in the process.
/// </summary>
[JsonExtensionData]
internal IDictionary<string, JToken> AdditionalProperties { get; private set; }
}
}