Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Selflink is added to all public resource properties. #1038

Merged
merged 10 commits into from
Nov 21, 2019
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Microsoft.Azure.Cosmos/src/Resource/Settings/AccountProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,17 @@ internal AccountProperties()
[JsonProperty(PropertyName = Constants.Properties.ETag)]
public string ETag { get; internal 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)]
public string SelfLink { get; private set; }
j82w marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Gets or sets the Resource Id associated with the resource in the Azure Cosmos DB service.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,17 @@ public class ConflictProperties
[JsonProperty(PropertyName = Documents.Constants.Properties.OperationType)]
public OperationKind OperationKind { get; internal 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 = Documents.Constants.Properties.SelfLink)]
public string SelfLink { get; private set; }

[JsonConverter(typeof(ConflictResourceTypeJsonConverter))]
[JsonProperty(PropertyName = Documents.Constants.Properties.ResourceType)]
internal Type ResourceType { get; set; }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,17 @@ public string PartitionKeyPath
[JsonProperty(PropertyName = Constants.Properties.DefaultTimeToLive, NullValueHandling = NullValueHandling.Ignore)]
public int? DefaultTimeToLive { get; 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)]
public string SelfLink { get; private set; }

/// <summary>
/// The function selects the right partition key constant mapping for <see cref="PartitionKey.None"/>
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,17 @@ public string Id
[JsonProperty(PropertyName = Constants.Properties.LastModified)]
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)]
public string SelfLink { get; private set; }

/// <summary>
/// Gets the Resource Id associated with the resource in the Azure Cosmos DB service.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,17 @@ public PartitionKey? ResourcePartitionKey
[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)]
public string SelfLink { get; private set; }

/// <summary>
/// Gets the Resource Id associated with the resource in the Azure Cosmos DB service.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,17 @@ public string Id
[JsonProperty(PropertyName = Constants.Properties.LastModified)]
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)]
public string SelfLink { get; private set; }

/// <summary>
/// Gets the Resource Id associated with the resource in the Azure Cosmos DB service.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,17 @@ public int? Throughput
private set => this.Content = new OfferContentV2(value.Value);
}

/// <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)]
public string SelfLink { get; private set; }

/// <summary>
/// Gets the offer rid.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,5 +77,16 @@ public class TriggerProperties
/// </remarks>
[JsonProperty(PropertyName = Constants.Properties.ETag)]
public string ETag { 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)]
public string SelfLink { get; private set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,16 @@ public class UserDefinedFunctionProperties
/// </remarks>
[JsonProperty(PropertyName = Constants.Properties.ETag)]
public string ETag { 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)]
public string SelfLink { get; private set; }
}
}
22 changes: 11 additions & 11 deletions Microsoft.Azure.Cosmos/src/Resource/Settings/UserProperties.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,17 @@ public string Id
[JsonProperty(PropertyName = Constants.Properties.LastModified)]
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)]
public string SelfLink { get; private set; }

/// <summary>
/// Gets the Resource Id associated with the resource in the Azure Cosmos DB service.
/// </summary>
Expand All @@ -90,17 +101,6 @@ public string Id
[JsonProperty(PropertyName = Constants.Properties.RId)]
internal string ResourceId { get; 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)]
internal string SelfLink { get; private set; }

/// <summary>
/// Gets the permissions associated with the user for the Azure Cosmos DB service.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ public async Task PartitionedCRUDTest()
string diagnostics = containerResponse.Diagnostics.ToString();
Assert.IsFalse(string.IsNullOrEmpty(diagnostics));
Assert.IsTrue(diagnostics.Contains("StatusCode"));
Assert.IsNotNull(containerResponse.Resource.SelfLink);
j82w marked this conversation as resolved.
Show resolved Hide resolved

ContainerProperties settings = new ContainerProperties(containerName, partitionKeyPath)
{
Expand All @@ -168,6 +169,7 @@ public async Task PartitionedCRUDTest()
diagnostics = containerResponse.Diagnostics.ToString();
Assert.IsFalse(string.IsNullOrEmpty(diagnostics));
Assert.IsTrue(diagnostics.Contains("StatusCode"));
Assert.IsNotNull(containerResponse.Resource.SelfLink);

containerResponse = await container.ReadContainerAsync();
Assert.AreEqual(HttpStatusCode.OK, containerResponse.StatusCode);
Expand All @@ -180,6 +182,7 @@ public async Task PartitionedCRUDTest()
diagnostics = containerResponse.Diagnostics.ToString();
Assert.IsFalse(string.IsNullOrEmpty(diagnostics));
Assert.IsTrue(diagnostics.Contains("StatusCode"));
Assert.IsNotNull(containerResponse.Resource.SelfLink);

containerResponse = await containerResponse.Container.DeleteContainerAsync();
Assert.AreEqual(HttpStatusCode.NoContent, containerResponse.StatusCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,10 @@ public async Task ReadDatabase()
Assert.AreEqual(createResponse.Database.Id, readResponse.Database.Id);
Assert.AreEqual(createResponse.Resource.Id, readResponse.Resource.Id);
Assert.AreNotEqual(createResponse.ActivityId, readResponse.ActivityId);
Assert.IsNotNull(createResponse.Resource.SelfLink);
Assert.IsNotNull(readResponse.Resource.SelfLink);
Assert.AreEqual(createResponse.Resource.SelfLink, readResponse.Resource.SelfLink);

this.ValidateHeaders(readResponse);
await createResponse.Database.DeleteAsync(cancellationToken: this.cancellationToken);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,17 +63,20 @@ public async Task CRUDTest()
Assert.AreEqual(permissionId, permissionResponse.Resource.Id);
Assert.AreEqual(permissionProperties.PermissionMode, permissionResponse.Resource.PermissionMode);
Assert.IsNotNull(permissionResponse.Resource.Token);
Assert.IsNotNull(permissionResponse.Resource.SelfLink);

PermissionProperties newPermissionProperties = new PermissionProperties(permissionId, PermissionMode.All, containerResponse.Container);
permissionResponse = await user.GetPermission(permissionId).ReplaceAsync(newPermissionProperties);
//Backend returns Created instead of OK
Assert.AreEqual(HttpStatusCode.Created, userResponse.StatusCode);
Assert.AreEqual(permissionId, permissionResponse.Resource.Id);
Assert.AreEqual(newPermissionProperties.PermissionMode, permissionResponse.Resource.PermissionMode);
Assert.IsNotNull(permissionResponse.Resource.SelfLink);

permissionResponse = await user.GetPermission(permissionId).ReadAsync();
Assert.AreEqual(HttpStatusCode.OK, permissionResponse.StatusCode);
Assert.AreEqual(permissionId, permissionResponse.Resource.Id);
Assert.IsNotNull(permissionResponse.Resource.SelfLink);

permissionResponse = await user.GetPermission(permissionId).DeleteAsync();
Assert.AreEqual(HttpStatusCode.NoContent, permissionResponse.StatusCode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,20 @@ public async Task CRUDTest()
Assert.AreEqual(HttpStatusCode.Created, userResponse.StatusCode);
Assert.AreEqual(userId, userResponse.Resource.Id);
Assert.IsNotNull(userResponse.Resource.ResourceId);
Assert.IsNotNull(userResponse.Resource.SelfLink);

string newUserId = Guid.NewGuid().ToString();
userResponse.Resource.Id = newUserId;

userResponse = await this.cosmosDatabase.GetUser(userId).ReplaceAsync(userResponse.Resource);
Assert.AreEqual(HttpStatusCode.OK, userResponse.StatusCode);
Assert.AreEqual(newUserId, userResponse.Resource.Id);
Assert.IsNotNull(userResponse.Resource.SelfLink);

userResponse = await this.cosmosDatabase.GetUser(userResponse.Resource.Id).ReadAsync();
Assert.AreEqual(HttpStatusCode.OK, userResponse.StatusCode);
Assert.AreEqual(newUserId, userResponse.Resource.Id);
Assert.IsNotNull(userResponse.Resource.SelfLink);

userResponse = await this.cosmosDatabase.GetUser(newUserId).DeleteAsync();
Assert.AreEqual(HttpStatusCode.NoContent, userResponse.StatusCode);
Expand All @@ -75,11 +78,13 @@ public async Task CRUDTest()
Assert.AreEqual(HttpStatusCode.Created, userResponse.StatusCode);
Assert.AreEqual(userId, userResponse.Resource.Id);
Assert.IsNotNull(userResponse.Resource.ResourceId);
Assert.IsNotNull(userResponse.Resource.SelfLink);

newUserId = Guid.NewGuid().ToString();
userResponse.Resource.Id = newUserId;
userResponse = await this.cosmosDatabase.UpsertUserAsync(userResponse.Resource.Id);
Assert.AreEqual(newUserId, userResponse.Resource.Id);
Assert.IsNotNull(userResponse.Resource.SelfLink);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ public async Task ContainerMigrationTest()
// Verify v3 can add composite indexes and update the container
Container container = this.database.GetContainer(containerName);
ContainerProperties containerProperties = await container.ReadContainerAsync();
Assert.IsNotNull(containerProperties.SelfLink);
string cPath0 = "/address/city";
string cPath1 = "/address/state";
containerProperties.IndexingPolicy.CompositeIndexes.Add(new Collection<CompositePath>()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,6 +443,7 @@ private static void ValidateStoredProcedureSettings(string id, string body, Stor
"Stored Procedure id do not match");
Assert.AreEqual(body, settings.Body,
"Stored Procedure functions do not match");
Assert.IsNotNull(cosmosResponse.Resource.SelfLink);
}

private void ValidateStoredProcedureSettings(StoredProcedureProperties storedProcedureSettings, StoredProcedureResponse cosmosResponse)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ private static void ValidateTriggerSettings(TriggerProperties triggerSettings, T
Assert.IsTrue(cosmosResponse.RequestCharge > 0);
Assert.IsNotNull(cosmosResponse.Headers.GetHeaderValue<string>(Documents.HttpConstants.HttpHeaders.MaxResourceQuota));
Assert.IsNotNull(cosmosResponse.Headers.GetHeaderValue<string>(Documents.HttpConstants.HttpHeaders.CurrentResourceQuotaUsage));
Assert.IsNotNull(cosmosResponse.Resource.SelfLink);
}

private class Job
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ private static void ValidateUserDefinedFunctionSettings(UserDefinedFunctionPrope
Assert.IsTrue(cosmosResponse.RequestCharge > 0);
Assert.IsNotNull(cosmosResponse.Headers.GetHeaderValue<string>(Documents.HttpConstants.HttpHeaders.MaxResourceQuota));
Assert.IsNotNull(cosmosResponse.Headers.GetHeaderValue<string>(Documents.HttpConstants.HttpHeaders.CurrentResourceQuotaUsage));
Assert.IsNotNull(cosmosResponse.Resource.SelfLink);
}

private async Task<UserDefinedFunctionResponse> CreateRandomUdf()
Expand Down
Loading