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

Consistent naming for DateTime properties and methods #2884

Merged
merged 2 commits into from
Oct 17, 2022
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
34 changes: 33 additions & 1 deletion SDK v2 migration guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ but users are still encouraged to migrate to version 2 when they have the chance
| `Message` | `IncomingMessage`, `OutgoingMessage` |
| `SetRetryPolicy(...)` | `IoTHubClientOptions.RetryPolicy` |
| `ExponentialBackOff` | `ExponentialBackOffRetryPolicy` |
| `Message.CreationTimeUtc` | `OutgoingMessage.CreatedOnUtc` and `IncomingMessage.CreatedOnUtc` |
drwill-ms marked this conversation as resolved.
Show resolved Hide resolved
| `Message.EnqueuedTimeUtc` | `OutgoingMessage.EnqueuedtimeUtc` and `IncomingMessage.EnqueuedTimeUtc` |
| `Message.ExpiryTimeUtc` | `OutgoingMessage.ExpiresOnUtc` and `IncomingMessage.ExpiresOnUtc` |

#### Other notable breaking changes

Expand Down Expand Up @@ -97,9 +100,20 @@ but users are still encouraged to migrate to version 2 when they have the chance
| `RegistryManager.AddDeviceAsync(Device, ...)` | `IotHubServiceClient.Devices.CreateAsync(Device, ...)` |
| `RegistryManager.AddDevices2Async(...)` | `IotHubServiceClient.Devices.CreateAsync(IEnumerable<Device>,...)` |
| `RegistryManager.RemoveDeviceAsync(...)` | `IotHubServiceClient.Devices.DeleteAsync(...)` |
| `Device.ConnectionStateUpdatedTime` | `Device.ConnectionStateUpdatedOnUtc` |
| `Device.StatusUpdatedTime` | `Device.StatusUpdatedOnUtc` |
| `Device.LastActivityTime` | `Device.LastActiveOnUtc` |
| `Device.Capabilities.IotEdge` | `Device.Capabilities.IsIotEdge` |
| `Module.ConnectionStateUpdatedTime` | `Module.ConnectionStateUpdatedOnUtc` |
| `Module.LastActivityTime` | `Module.LastActiveOnUtc` |
| `RegistryManager.GetTwinAsync(...)` | `IotHubServiceClient.Twins.GetAsync(...)` |
| `RegistryManager.UpdateTwinAsync(...)` | `IotHubServiceClient.Twins.UpdateAsync(...)` |
| `Twin.StatusUpdatedOn` | `Twin.StatusUpdatedOnUtc` |
| `Twin.LastActivityOn` | `Twin.LastActiveOnUtc` |
| `TwinCollection.GetLastUpdatedOn()` | `TwinCollection.GetLastUpdatedOnUtc()` |
| `TwinCollectionArray.GetLastUpdatedOn()` | `TwinCollectionArray.GetLastUpdatedOnUtc()` |
| `TwinCollectionValue.GetLastUpdatedOn()` | `TwinCollectionValue.GetLastUpdatedOnUtc()` |
| `Metadata.LastUpdatedOn` | `TwinMetadata.LastUpdatedOnUtc` |
| `RegistryManager.CreateQuery(...)` | `IotHubServiceClient.Query.CreateAsync<T>(...)` |
| `RegistryManager.AddConfigurationAsync(...)` | `IotHubServiceClient.Configurations.CreateAsync(...)` |
| `RegistryManager.GetConfigurationsAsync(int maxCount)`| `IotHubServiceClient.Configurations.GetAsync(int maxCount)` |
Expand Down Expand Up @@ -129,11 +143,14 @@ but users are still encouraged to migrate to version 2 when they have the chance
|:---|:---|
| `ServiceClient` | `IotHubServiceClient`, subclients `Messages`, `MessageFeedback`, `FileUploadNotifications` |
| `ServiceClient.SendAsync(...)` | `IotHubServiceClient.Messages.SendAsync(...)` |
| `Message.ExpiryTimeUtc` | `Message.ExpiresOnUtc` |
| `Message.CreationTimeUtc` | `Message.CreatedOnUtc` |
| `ServiceClient.InvokeDeviceMethodAsync(...)` | `IotHubServiceClient.DirectMethods.InvokeAsync(...)` |
| `CloudToDeviceMethod` | `DirectMethodRequest` |
| `CloudToDeviceMethodResult` | `DirectMethodResponse` |
| `ServiceClient.GetFeedbackReceiver(...)` | `IotHubServiceClient.MessageFeedback.MessageFeedbackProcessor` |
| `ServiceClient.GetFileNotificationReceiver()` | `IotHubServiceClient.FileUploadNotifications.FileUploadNotificationProcessor`
| `ServiceClient.GetFileNotificationReceiver()` | `IotHubServiceClient.FileUploadNotifications.FileUploadNotificationProcessor` |


#### Other notable breaking changes

Expand Down Expand Up @@ -167,6 +184,7 @@ but users are still encouraged to migrate to version 2 when they have the chance
| `DigitalTwinClient` | `IotHubServiceClient.DigitalTwins` |
| `DigitalTwinClient.GetDigitalTwinAsync(...)` | `IotHubServiceClient.DigitalTwins.GetAsync(...)` |
| `DigitalTwinClient.UpdateDigitalTwinAsync(...)` | `IotHubServiceClient.DigitalTwins.UpdateAsync(...)` |
| `WritableProperty.LastUpdatedOn` | `WritableProperty.LastUpdatedOnUtc` |
| `UpdateOperationsUtility` | Removed. `Azure.JsonPatchDocument` from Azure.Core package is recommended. |

#### Other notable breaking changes
Expand All @@ -183,6 +201,8 @@ but users are still encouraged to migrate to version 2 when they have the chance
| `ProvisioningDeviceClient.Create(...)` | `new ProvisioningDeviceClient(...)` |
| `ProvisioningDeviceClient` initializer parameter `transportHandler` replaced | `ProvisioningClientOptions` parameter added |
| `ProvisioningRegistrationAdditionalData` | `RegistrationRequestPayload`|
| `DeviceRegistrationResult.CreatedDateTimeUtc` | `DeviceRegistrationResult.CreatedOnUtc` |
| `DeviceRegistrationResult.LastUpdatedDateTimeUtc` | `DeviceRegistrationResult.LastUpdatedOnUtc` |

#### Other notable breaking changes

Expand Down Expand Up @@ -216,6 +236,18 @@ but users are still encouraged to migrate to version 2 when they have the chance
| `ProvisioningServiceClient.GetDeviceRegistrationStateAsync(...)` | `ProvisioningServiceClient.DeviceRegistrationStates.GetAsync(...)` |
| `ProvisioningServiceClient.DeleteDeviceRegistrationStateAsync(...)` | `ProvisioningServiceClient.DeviceRegistrationStates.DeleteAsync(...)` |
| `ProvisioningServiceClient.CreateEnrollmentGroupRegistrationStateQuery(...)` | `ProvisioningServiceClient.DeviceRegistrationStates.CreateEnrollmentGroupQuery(...)` |
| `DeviceRegistrationState.CreatedDateTimeUtc` | `DeviceRegistrationState.CreatedOnUtc` |
| `DeviceRegistrationState.LastUpdatedDateTimeUtc` | `DeviceRegistrationState.LastUpdatedOnUtc` |
| `EnrollmentGroup.CreatedDateTimeUtc` | `EnrollmentGroup.CreatedOnUtc` |
| `EnrollmentGroup.LastUpdatedDateTimeUtc` | `EnrollmentGroup.LastUpdatedOnUtc` |
| `IndividualEnrollment.CreatedDateTimeUtc` | `IndividualEnrollment.CreatedOnUtc` |
| `IndividualEnrollment.LastUpdatedDateTimeUtc` | `IndividualEnrollment.LastUpdatedOnUtc` |
| `Twin.StatusUpdatedOn` | `Twin.StatusUpdatedOnUtc` |
| `Twin.LastActivityOn` | `Twin.LastActiveOnUtc` |
| `TwinCollection.GetLastUpdatedOn()` | `TwinCollection.GetLastUpdatedOnUtc()` |
| `TwinCollectionArray.GetLastUpdatedOn()` | `TwinCollectionArray.GetLastUpdatedOnUtc()` |
| `TwinCollectionValue.GetLastUpdatedOn()` | `TwinCollectionValue.GetLastUpdatedOnUtc()` |
| `Metadata.LastUpdatedOn` | `TwinMetadata.LastUpdatedOnUtc` |

#### Other notable breaking changes

Expand Down
8 changes: 4 additions & 4 deletions iothub/device/src/Messaging/IncomingMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public string UserId
/// <summary>
/// The event creation time when sending one message at a time.
/// </summary>
public DateTime CreationTimeUtc
public DateTime CreatedOnUtc
{
get => GetSystemProperty<DateTime>(MessageSystemPropertyNames.CreationTimeUtc);
protected internal set => SystemProperties[MessageSystemPropertyNames.CreationTimeUtc] = value;
Expand All @@ -85,16 +85,16 @@ public DateTime CreationTimeUtc
/// <summary>
/// Date and time when the device-to-cloud message was received by the server.
/// </summary>
public DateTime EnqueuedTimeUtc
public DateTime EnqueuedOnUtc
{
get => GetSystemProperty<DateTime>(MessageSystemPropertyNames.EnqueuedTime);
protected internal set => SystemProperties[MessageSystemPropertyNames.EnqueuedTime] = value;
}

/// <summary>
/// The time when this message is considered expired
/// The time when this message is considered expired.
/// </summary>
public DateTime ExpiryTimeUtc
public DateTime ExpiresOnUtc
{
get => GetSystemProperty<DateTime>(MessageSystemPropertyNames.ExpiryTimeUtc);
protected internal set => SystemProperties[MessageSystemPropertyNames.ExpiryTimeUtc] = value;
Expand Down
2 changes: 1 addition & 1 deletion iothub/device/src/Messaging/OutgoingMessage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public DateTime BatchCreatedOnUtc
}

/// <summary>
/// The time when this message is considered expired
/// The time when this message is considered expired.
/// </summary>
public DateTime ExpiresOnUtc
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ public static void UpdateMessageHeaderAndProperties(AmqpMessage amqpMessage, Inc

if (amqpMessage.Properties.AbsoluteExpiryTime.HasValue)
{
message.ExpiryTimeUtc = amqpMessage.Properties.AbsoluteExpiryTime.Value;
message.ExpiresOnUtc = amqpMessage.Properties.AbsoluteExpiryTime.Value;
}

message.CorrelationId = amqpMessage.Properties.CorrelationId?.ToString();
Expand Down Expand Up @@ -107,7 +107,7 @@ public static void UpdateMessageHeaderAndProperties(AmqpMessage amqpMessage, Inc

if (amqpMessage.MessageAnnotations.Map.TryGetValue(MessageSystemPropertyNames.EnqueuedTime, out DateTime enqueuedTime))
{
message.EnqueuedTimeUtc = enqueuedTime;
message.EnqueuedOnUtc = enqueuedTime;
}

if (amqpMessage.MessageAnnotations.Map.TryGetValue(InputName, out string inputName))
Expand All @@ -134,7 +134,7 @@ public static void UpdateMessageHeaderAndProperties(AmqpMessage amqpMessage, Inc
break;

case MessageSystemPropertyNames.CreationTimeUtc:
message.CreationTimeUtc = DateTime.Parse(stringObject, CultureInfo.InvariantCulture);
message.CreatedOnUtc = DateTime.Parse(stringObject, CultureInfo.InvariantCulture);
break;

default:
Expand Down
35 changes: 16 additions & 19 deletions iothub/device/src/Transport/Mqtt/IotHubWirePropertyNames.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Copyright (c) Microsoft. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
using System;
using System.Collections.Generic;
using System.Text;

namespace Microsoft.Azure.Devices.Client.Transport.Mqtt
{
Expand All @@ -11,21 +8,21 @@ namespace Microsoft.Azure.Devices.Client.Transport.Mqtt
/// </summary>
internal static class IotHubWirePropertyNames
{
public const string AbsoluteExpiryTime = "$.exp";
public const string CorrelationId = "$.cid";
public const string MessageId = "$.mid";
public const string To = "$.to";
public const string UserId = "$.uid";
public const string OutputName = "$.on";
public const string MessageSchema = "$.schema";
public const string CreationTimeUtc = "$.ctime";
public const string ContentType = "$.ct";
public const string ContentEncoding = "$.ce";
public const string ConnectionDeviceId = "$.cdid";
public const string ConnectionModuleId = "$.cmid";
public const string MqttDiagIdKey = "$.diagid";
public const string MqttDiagCorrelationContextKey = "$.diagctx";
public const string InterfaceId = "$.ifid";
public const string ComponentName = "$.sub";
internal const string AbsoluteExpiryTime = "$.exp";
internal const string CorrelationId = "$.cid";
internal const string MessageId = "$.mid";
internal const string To = "$.to";
internal const string UserId = "$.uid";
internal const string OutputName = "$.on";
internal const string MessageSchema = "$.schema";
internal const string CreationTimeUtc = "$.ctime";
internal const string ContentType = "$.ct";
internal const string ContentEncoding = "$.ce";
internal const string ConnectionDeviceId = "$.cdid";
internal const string ConnectionModuleId = "$.cmid";
internal const string MqttDiagIdKey = "$.diagid";
internal const string MqttDiagCorrelationContextKey = "$.diagctx";
internal const string InterfaceId = "$.ifid";
internal const string ComponentName = "$.sub";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ private async Task UpdateDigitalTwinComponentPropertyAsync()
double? currentComponentTargetTemperature = getDigitalTwinResponse.DigitalTwin.Thermostat1.TargetTemperature;
if (currentComponentTargetTemperature != null)
{
DateTimeOffset targetTemperatureDesiredLastUpdateTime = getDigitalTwinResponse.DigitalTwin.Thermostat1.Metadata.TargetTemperature.LastUpdatedOn;
DateTimeOffset targetTemperatureDesiredLastUpdateTime = getDigitalTwinResponse.DigitalTwin.Thermostat1.Metadata.TargetTemperature.LastUpdatedOnUtc;
_logger.LogDebug($"The property {targetTemperaturePropertyName} under component {Thermostat1Component} was last updated on `" +
$"{targetTemperatureDesiredLastUpdateTime.ToLocalTime()} `" +
$" with a value of {getDigitalTwinResponse.DigitalTwin.Thermostat1.Metadata.TargetTemperature.DesiredValue}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ internal class ThermostatMetadata : DigitalTwinMetadata
internal class ReportedPropertyMetadata
{
[JsonProperty("lastUpdateTime")]
public DateTimeOffset LastUpdatedOn { get; set; }
public DateTimeOffset LastUpdatedOnUtc { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private async Task UpdateTargetTemperaturePropertyAsync()
double? currentTargetTemperature = getDigitalTwinResponse.DigitalTwin.TargetTemperature;
if (currentTargetTemperature != null)
{
DateTimeOffset targetTemperatureDesiredLastUpdateTime = getDigitalTwinResponse.DigitalTwin.Metadata.TargetTemperature.LastUpdatedOn;
DateTimeOffset targetTemperatureDesiredLastUpdateTime = getDigitalTwinResponse.DigitalTwin.Metadata.TargetTemperature.LastUpdatedOnUtc;
_logger.LogDebug($"The property {targetTemperaturePropertyName} was last updated on " +
$"{targetTemperatureDesiredLastUpdateTime.ToLocalTime()} `" +
$" with a value of {getDigitalTwinResponse.DigitalTwin.Metadata.TargetTemperature.DesiredValue}.");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ internal class ThermostatMetadata : DigitalTwinMetadata
internal class ReportedPropertyMetadata
{
[JsonProperty("lastUpdateTime")]
public DateTimeOffset LastUpdatedOn { get; set; }
public DateTimeOffset LastUpdatedOnUtc { get; set; }
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public class WritableProperty
/// The time when this property was last updated.
/// </summary>
[JsonProperty("lastUpdateTime")]
public DateTimeOffset LastUpdatedOn { get; set; }
public DateTimeOffset LastUpdatedOnUtc { get; set; }
}
}
4 changes: 2 additions & 2 deletions iothub/service/src/Messaging/Message.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public string To
/// <summary>
/// [Optional] The time when this message is considered expired.
/// </summary>
public DateTime ExpiryTimeUtc
public DateTime ExpiresOnUtc
{
get => GetSystemProperty<DateTime>(MessageSystemPropertyNames.ExpiryTimeUtc);
set => SystemProperties[MessageSystemPropertyNames.ExpiryTimeUtc] = value;
Expand Down Expand Up @@ -121,7 +121,7 @@ public string MessageSchema
/// <summary>
/// Custom date property set by the originator of the message.
/// </summary>
public DateTime CreationTimeUtc
public DateTime CreatedOnUtc
{
get => GetSystemProperty<DateTime>(MessageSystemPropertyNames.CreationTimeUtc);
set => SystemProperties[MessageSystemPropertyNames.CreationTimeUtc] = value;
Expand Down
4 changes: 2 additions & 2 deletions iothub/service/src/Messaging/MessageConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ internal static void UpdateAmqpMessageHeadersAndProperties(AmqpMessage amqpMessa
amqpMessage.Properties.To = data.To;
}

if (!data.ExpiryTimeUtc.Equals(default))
if (!data.ExpiresOnUtc.Equals(default))
{
amqpMessage.Properties.AbsoluteExpiryTime = data.ExpiryTimeUtc;
amqpMessage.Properties.AbsoluteExpiryTime = data.ExpiresOnUtc;
}

if (data.CorrelationId != null)
Expand Down
6 changes: 3 additions & 3 deletions iothub/service/src/Registry/Models/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,19 +79,19 @@ public Device(string id)
/// Time when the connection state was last updated.
/// </summary>
[JsonProperty(PropertyName = "connectionStateUpdatedTime")]
public DateTime ConnectionStateUpdatedTime { get; internal set; }
public DateTime ConnectionStateUpdatedOnUtc { get; internal set; }
drwill-ms marked this conversation as resolved.
Show resolved Hide resolved

/// <summary>
/// Time when the status was last updated.
/// </summary>
[JsonProperty(PropertyName = "statusUpdatedTime")]
public DateTime StatusUpdatedTime { get; internal set; }
public DateTime StatusUpdatedOnUtc { get; internal set; }

/// <summary>
/// Time when the device was last active.
/// </summary>
[JsonProperty(PropertyName = "lastActivityTime")]
public DateTime LastActivityTime { get; internal set; }
public DateTime LastActiveOnUtc { get; internal set; }

/// <summary>
/// Number of messages sent to the device from the cloud.
Expand Down
4 changes: 2 additions & 2 deletions iothub/service/src/Registry/Models/Module.cs
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ public Module(string deviceId, string moduleId)
/// Time when the connection state was last updated.
/// </summary>
[JsonProperty(PropertyName = "connectionStateUpdatedTime")]
public DateTime ConnectionStateUpdatedTime { get; internal set; }
public DateTime ConnectionStateUpdatedOnUtc { get; internal set; }

/// <summary>
/// Time when the module was last active.
/// </summary>
[JsonProperty(PropertyName = "lastActivityTime")]
public DateTime LastActivityTime { get; internal set; }
public DateTime LastActiveOnUtc { get; internal set; }

/// <summary>
/// Number of messages sent to the module from the cloud.
Expand Down
4 changes: 2 additions & 2 deletions iothub/service/src/Twin/Models/Twin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ public Twin(TwinProperties twinProperties)
/// </summary>
[DefaultValue(null)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public DateTimeOffset? StatusUpdatedOn { get; internal set; }
public DateTimeOffset? StatusUpdatedOnUtc { get; internal set; }

/// <summary>
/// Corresponding device's connection state.
Expand All @@ -133,7 +133,7 @@ public Twin(TwinProperties twinProperties)
/// </summary>
[DefaultValue(null)]
[JsonProperty(DefaultValueHandling = DefaultValueHandling.IgnoreAndPopulate)]
public DateTimeOffset? LastActivityOn { get; internal set; }
public DateTimeOffset? LastActiveOnUtc { get; internal set; }

/// <summary>
/// Number of messages sent to the corresponding device from the cloud.
Expand Down
6 changes: 3 additions & 3 deletions iothub/service/src/Twin/Models/TwinCollection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public int Count
}
else if (propertyName == LastUpdatedName)
{
return GetLastUpdatedOn();
return GetLastUpdatedOnUtc();
}
else if (propertyName == LastUpdatedVersionName)
{
Expand Down Expand Up @@ -153,7 +153,7 @@ public override string ToString()
/// <returns>Metadata instance representing the metadata for this property.</returns>
public TwinMetadata GetMetadata()
{
return new TwinMetadata(GetLastUpdatedOn(), GetLastUpdatedVersion());
return new TwinMetadata(GetLastUpdatedOnUtc(), GetLastUpdatedVersion());
}

/// <summary>
Expand All @@ -162,7 +162,7 @@ public TwinMetadata GetMetadata()
/// <returns>Date-time instance representing the last updated time for this property.</returns>
/// <exception cref="System.NullReferenceException">Thrown when the metadata object is null.
/// An example would be when the this class is created with the default constructor.</exception>
public DateTimeOffset GetLastUpdatedOn()
public DateTimeOffset GetLastUpdatedOnUtc()
{
return (DateTime)_metadata[LastUpdatedName];
}
Expand Down