Skip to content

Commit

Permalink
Implement Tim's naming idea
Browse files Browse the repository at this point in the history
  • Loading branch information
David R. Williamson committed Oct 24, 2022
1 parent 1504253 commit 6e12326
Show file tree
Hide file tree
Showing 32 changed files with 74 additions and 74 deletions.
4 changes: 2 additions & 2 deletions SDK v2 migration guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ but users are still encouraged to migrate to version 2 when they have the chance
| `Message.CreationTimeUtc` | `TelemetryMessage.CreatedOnUtc`, `IncomingMessage.CreatedOnUtc` |
| `Message.EnqueuedTimeUtc` | `TelemetryMessage.EnqueuedtimeUtc`, `IncomingMessage.EnqueuedTimeUtc` |
| `Message.ExpiryTimeUtc` | `TelemetryMessage.ExpiresOnUtc`, `IncomingMessage.ExpiresOnUtc` |
| `MethodRequest` | `DirectMethodServiceRequest` |
| `MethodRequest` | `DirectMethodRequest` |
| `MethodResponse` | `DirectMethodResponse` |

#### Other notable breaking changes
Expand Down Expand Up @@ -211,7 +211,7 @@ but users are still encouraged to migrate to version 2 when they have the chance
| `Message.ExpiryTimeUtc` | `Message.ExpiresOnUtc` |
| `Message.CreationTimeUtc` | `Message.CreatedOnUtc` |
| `ServiceClient.InvokeDeviceMethodAsync(...)` | `IotHubServiceClient.DirectMethods.InvokeAsync(...)` |
| `CloudToDeviceMethod` | `DirectMethodRequest` |
| `CloudToDeviceMethod` | `DirectMethodServiceRequest` |
| `CloudToDeviceMethodResult` | `DirectMethodClientResponse` |
| `ServiceClient.GetFeedbackReceiver(...)` | `IotHubServiceClient.MessageFeedback.MessageFeedbackProcessor` |
| `ServiceClient.GetFileNotificationReceiver()` | `IotHubServiceClient.FileUploadNotifications.FileUploadNotificationProcessor` |
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/iothub/method/MethodE2ECustomPayloadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public static async Task ServiceSendMethodAndVerifyResponseAsync(
TimeSpan methodTimeout = responseTimeout == default ? s_defaultMethodTimeoutMinutes : responseTimeout;
VerboseTestLogger.WriteLine($"{nameof(ServiceSendMethodAndVerifyResponseAsync)}: Invoke method {methodName}.");

var directMethodRequest = new DirectMethodRequest
var directMethodRequest = new DirectMethodServiceRequest
{
MethodName = methodName,
ResponseTimeout = methodTimeout,
Expand Down
12 changes: 6 additions & 6 deletions e2e/test/iothub/method/MethodE2ETests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ public async Task Method_ServiceInvokeDeviceMethodWithUnknownDeviceThrows()
{
// setup
using var serviceClient = new IotHubServiceClient(TestConfiguration.IotHub.ConnectionString);
var methodInvocation = new DirectMethodRequest
var methodInvocation = new DirectMethodServiceRequest
{
MethodName = "SetTelemetryInterval",
Payload = "10"
Expand Down Expand Up @@ -175,7 +175,7 @@ public async Task Method_ServiceInvokeDeviceMethodWithUnknownModuleThrows()
// setup
using TestDevice testDevice = await TestDevice.GetTestDeviceAsync("ModuleNotFoundTest").ConfigureAwait(false);
using var serviceClient = new IotHubServiceClient(TestConfiguration.IotHub.ConnectionString);
var directMethodRequest = new DirectMethodRequest
var directMethodRequest = new DirectMethodServiceRequest
{
MethodName = "SetTelemetryInterval",
Payload = "10",
Expand Down Expand Up @@ -219,7 +219,7 @@ await deviceClient
.ConfigureAwait(false);

using var serviceClient = new IotHubServiceClient(TestConfiguration.IotHub.ConnectionString);
var directMethodRequest = new DirectMethodRequest
var directMethodRequest = new DirectMethodServiceRequest
{
MethodName = commandName,
ConnectionTimeout = TimeSpan.FromMinutes(1),
Expand Down Expand Up @@ -271,7 +271,7 @@ public static async Task ServiceSendMethodAndVerifyNotReceivedAsync(
TimeSpan methodTimeout = responseTimeout == default ? s_defaultMethodTimeoutMinutes : responseTimeout;
VerboseTestLogger.WriteLine($"{nameof(ServiceSendMethodAndVerifyResponseAsync)}: Invoke method {methodName}.");

var directMethodRequest = new DirectMethodRequest
var directMethodRequest = new DirectMethodServiceRequest
{
MethodName = methodName,
ResponseTimeout = methodTimeout,
Expand Down Expand Up @@ -302,7 +302,7 @@ public static async Task ServiceSendMethodAndVerifyResponseAsync(
TimeSpan methodTimeout = responseTimeout == default ? s_defaultMethodTimeoutMinutes : responseTimeout;
VerboseTestLogger.WriteLine($"{nameof(ServiceSendMethodAndVerifyResponseAsync)}: Invoke method {methodName}.");

var directMethodRequest = new DirectMethodRequest
var directMethodRequest = new DirectMethodServiceRequest
{
MethodName = methodName,
ResponseTimeout = methodTimeout,
Expand Down Expand Up @@ -331,7 +331,7 @@ public static async Task ServiceSendMethodAndVerifyResponseAsync(

TimeSpan methodTimeout = responseTimeout == default ? s_defaultMethodTimeoutMinutes : responseTimeout;

var directMethodRequest = new DirectMethodRequest
var directMethodRequest = new DirectMethodServiceRequest
{
MethodName = methodName,
ResponseTimeout = methodTimeout,
Expand Down
2 changes: 1 addition & 1 deletion e2e/test/iothub/method/MethodFaultInjectionTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ private async Task ServiceSendMethodAndVerifyResponseAsync(string deviceName, st
{
using var serviceClient = new IotHubServiceClient(TestConfiguration.IotHub.ConnectionString);

var directMethodRequest = new DirectMethodRequest()
var directMethodRequest = new DirectMethodServiceRequest()
{
MethodName = methodName,
Payload = serviceRequestPayload,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ await _deviceClient.SetDirectMethodCallbackAsync(
null);
}

private async Task<DirectMethodResponse> OnDirectMethodCalledAsync(DirectMethodServiceRequest directMethodRequest)
private async Task<DirectMethodResponse> OnDirectMethodCalledAsync(DirectMethodRequest directMethodRequest)
{
switch (directMethodRequest.MethodName)
{
Expand All @@ -81,7 +81,7 @@ private void ConnectionStatusChangeHandler(ConnectionStatusInfo connectionInfo)
Console.WriteLine($"Connection status changed reason is {connectionInfo.ChangeReason}.\n");
}

private Task<DirectMethodResponse> WriteToConsoleAsync(DirectMethodServiceRequest directMethodRequest)
private Task<DirectMethodResponse> WriteToConsoleAsync(DirectMethodRequest directMethodRequest)
{
Console.WriteLine($"\t *** {directMethodRequest.MethodName} was called.");
Console.WriteLine($"\t{directMethodRequest.GetPayloadAsJsonString()}\n");
Expand All @@ -91,7 +91,7 @@ private Task<DirectMethodResponse> WriteToConsoleAsync(DirectMethodServiceReques
return Task.FromResult(directMethodResponse);
}

private Task<DirectMethodResponse> GetDeviceNameAsync(DirectMethodServiceRequest directMethodRequest)
private Task<DirectMethodResponse> GetDeviceNameAsync(DirectMethodRequest directMethodRequest)
{
Console.WriteLine($"\t *** {directMethodRequest.MethodName} was called.");

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public async Task RunSampleAsync()
}

// Handle the direct method call.
private Task<DirectMethodResponse> SetTelemetryInterval(DirectMethodServiceRequest methodRequest)
private Task<DirectMethodResponse> SetTelemetryInterval(DirectMethodRequest methodRequest)
{
// Check the payload is a single integer value.
if (methodRequest.TryGetPayload<int>(out int telemetryIntervalInSeconds))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ async void StatusChangeHandler(ConnectionStatusInfo info)
}
}

private async Task<DirectMethodResponse> OnDirectMethodAsync(DirectMethodServiceRequest request)
private async Task<DirectMethodResponse> OnDirectMethodAsync(DirectMethodRequest request)
{
return request.MethodName switch
{
Expand Down Expand Up @@ -188,7 +188,7 @@ private async Task GetWritablePropertiesAndHandleChangesAsync()
}

// The callback to handle "reboot" command. This method will send a temperature update (of 0°C) over telemetry for both associated components.
private async Task<DirectMethodResponse> HandleRebootCommandAsync(DirectMethodServiceRequest request)
private async Task<DirectMethodResponse> HandleRebootCommandAsync(DirectMethodRequest request)
{
bool delayReceived = request.TryGetPayload(out int delay);

Expand All @@ -213,7 +213,7 @@ private async Task<DirectMethodResponse> HandleRebootCommandAsync(DirectMethodSe

// The callback to handle "getMaxMinReport" command. This method will returns the max, min and average temperature from the
// specified time to the current time.
private Task<DirectMethodResponse> HandleMaxMinReportCommand(DirectMethodServiceRequest request, object userContext)
private Task<DirectMethodResponse> HandleMaxMinReportCommand(DirectMethodRequest request, object userContext)
{
string componentName = (string)userContext;
bool sinceInUtcReceived = request.TryGetPayload(out DateTime sinceInUtc);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ async void StatusChangeHandler(ConnectionStatusInfo info)
}
}

private async Task<DirectMethodResponse> OnDirectMethodAsync(DirectMethodServiceRequest request)
private async Task<DirectMethodResponse> OnDirectMethodAsync(DirectMethodRequest request)
{
return request.MethodName switch
{
Expand Down Expand Up @@ -206,7 +206,7 @@ private async Task TargetTemperatureUpdateCallbackAsync(DesiredProperties desire

// The callback to handle "getMaxMinReport" command. This method will returns the max, min and average temperature
// from the specified time to the current time.
private Task<DirectMethodResponse> HandleMaxMinReportCommandAsync(DirectMethodServiceRequest request)
private Task<DirectMethodResponse> HandleMaxMinReportCommandAsync(DirectMethodRequest request)
{
try
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ namespace Microsoft.Azure.Devices.Client
/// <remarks>
/// A direct method request can only be made by the service or a module.
/// </remarks>
public class DirectMethodServiceRequest
public class DirectMethodRequest
{
/// <summary>
/// Initialize an instance of this class.
Expand All @@ -22,7 +22,7 @@ public class DirectMethodServiceRequest
/// A direct method request can only be made by the service or a module;
/// a device client app will not need to instantiate this class.
/// </remarks>
public DirectMethodServiceRequest()
public DirectMethodRequest()
{
}

Expand Down
6 changes: 3 additions & 3 deletions iothub/device/src/IotHubBaseClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public abstract class IotHubBaseClient : IDisposable
// Method callback information
private bool _isDeviceMethodEnabled;

private volatile Func<DirectMethodServiceRequest, Task<DirectMethodResponse>> _deviceDefaultMethodCallback;
private volatile Func<DirectMethodRequest, Task<DirectMethodResponse>> _deviceDefaultMethodCallback;

// Twin property update request callback information
private bool _twinPatchSubscribedWithService;
Expand Down Expand Up @@ -249,7 +249,7 @@ public async Task SetIncomingMessageCallbackAsync(
/// <param name="cancellationToken">A cancellation token to cancel the operation.</param>
/// <exception cref="OperationCanceledException">Thrown when the operation has been canceled.</exception>
public async Task SetDirectMethodCallbackAsync(
Func<DirectMethodServiceRequest, Task<DirectMethodResponse>> directMethodCallback,
Func<DirectMethodRequest, Task<DirectMethodResponse>> directMethodCallback,
CancellationToken cancellationToken = default)
{
if (Logging.IsEnabled)
Expand Down Expand Up @@ -440,7 +440,7 @@ internal void OnConnectionStatusChanged(ConnectionStatusInfo connectionStatusInf
/// <summary>
/// The callback for handling direct methods received from service.
/// </summary>
internal async Task OnMethodCalledAsync(DirectMethodServiceRequest directMethodRequest)
internal async Task OnMethodCalledAsync(DirectMethodRequest directMethodRequest)
{
if (Logging.IsEnabled)
Logging.Enter(this, directMethodRequest?.MethodName, directMethodRequest, nameof(OnMethodCalledAsync));
Expand Down
6 changes: 3 additions & 3 deletions iothub/device/src/IotHubModuleClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public async Task SendTelemetryBatchAsync(string outputName, IEnumerable<Telemet
/// <returns>The result of the method invocation.</returns>
/// <exception cref="InvalidOperationException">Thrown if IotHubModuleClient instance is not opened already.</exception>
/// <exception cref="OperationCanceledException">Thrown when the operation has been canceled.</exception>
public Task<DirectMethodResponse> InvokeMethodAsync(string deviceId, DirectMethodServiceRequest methodRequest, CancellationToken cancellationToken = default)
public Task<DirectMethodResponse> InvokeMethodAsync(string deviceId, DirectMethodRequest methodRequest, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(methodRequest, nameof(methodRequest));
return InvokeMethodAsync(GetDeviceMethodUri(deviceId), methodRequest, cancellationToken);
Expand All @@ -219,7 +219,7 @@ public Task<DirectMethodResponse> InvokeMethodAsync(string deviceId, DirectMetho
/// <returns>The result of the method invocation.</returns>
/// <exception cref="InvalidOperationException">Thrown if IotHubModuleClient instance is not opened already.</exception>
/// <exception cref="OperationCanceledException">Thrown when the operation has been canceled.</exception>
public Task<DirectMethodResponse> InvokeMethodAsync(string deviceId, string moduleId, DirectMethodServiceRequest methodRequest, CancellationToken cancellationToken = default)
public Task<DirectMethodResponse> InvokeMethodAsync(string deviceId, string moduleId, DirectMethodRequest methodRequest, CancellationToken cancellationToken = default)
{
Argument.AssertNotNull(methodRequest, nameof(methodRequest));
return InvokeMethodAsync(GetModuleMethodUri(deviceId, moduleId), methodRequest, cancellationToken);
Expand All @@ -245,7 +245,7 @@ private void ValidateModuleTransportHandler(string apiName)
}
}

private async Task<DirectMethodResponse> InvokeMethodAsync(Uri uri, DirectMethodServiceRequest methodRequest, CancellationToken cancellationToken = default)
private async Task<DirectMethodResponse> InvokeMethodAsync(Uri uri, DirectMethodRequest methodRequest, CancellationToken cancellationToken = default)
{
HttpClientHandler httpClientHandler = null;
Func<object, X509Certificate, X509Chain, SslPolicyErrors, bool> customCertificateValidation = _certValidator.GetCustomCertificateValidation();
Expand Down
2 changes: 1 addition & 1 deletion iothub/device/src/Pipeline/PipelineContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ internal class PipelineContext

internal Action<DesiredProperties> DesiredPropertyUpdateCallback { get; set; }

internal Func<DirectMethodServiceRequest, Task> MethodCallback { get; set; }
internal Func<DirectMethodRequest, Task> MethodCallback { get; set; }

internal Func<IncomingMessage, Task<MessageAcknowledgement>> MessageEventCallback { get; set; }
}
Expand Down
2 changes: 1 addition & 1 deletion iothub/device/src/Transport/Amqp/AmqpConnectionHolder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public AmqpUnit CreateAmqpUnit(
IConnectionCredentials connectionCredentials,
AdditionalClientInformation additionalClientInformation,
IotHubClientAmqpSettings amqpSettings,
Func<DirectMethodServiceRequest, Task> onMethodCallback,
Func<DirectMethodRequest, Task> onMethodCallback,
Action<AmqpMessage, string, IotHubClientException> twinMessageListener,
Func<IncomingMessage, Task<MessageAcknowledgement>> onMessageReceivedCallback,
Action onUnitDisconnected)
Expand Down
2 changes: 1 addition & 1 deletion iothub/device/src/Transport/Amqp/AmqpConnectionPool.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public AmqpUnit CreateAmqpUnit(
IConnectionCredentials connectionCredentials,
AdditionalClientInformation additionalClientInformation,
IotHubClientAmqpSettings amqpSettings,
Func<DirectMethodServiceRequest, Task> onMethodCallback,
Func<DirectMethodRequest, Task> onMethodCallback,
Action<AmqpMessage, string, IotHubClientException> twinMessageListener,
Func<IncomingMessage, Task<MessageAcknowledgement>> onMessageReceivedCallback,
Action onUnitDisconnected)
Expand Down
6 changes: 3 additions & 3 deletions iothub/device/src/Transport/Amqp/AmqpUnit.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class AmqpUnit : IDisposable
private readonly AdditionalClientInformation _additionalClientInformation;
private readonly IotHubClientAmqpSettings _amqpSettings;

private readonly Func<DirectMethodServiceRequest, Task> _onMethodCallback;
private readonly Func<DirectMethodRequest, Task> _onMethodCallback;
private readonly Action<AmqpMessage, string, IotHubClientException> _twinMessageListener;
private readonly Func<IncomingMessage, Task<MessageAcknowledgement>> _onMessageReceivedCallback;
private readonly IAmqpConnectionHolder _amqpConnectionHolder;
Expand Down Expand Up @@ -69,7 +69,7 @@ internal AmqpUnit(
AdditionalClientInformation additionalClientInformation,
IotHubClientAmqpSettings amqpSettings,
IAmqpConnectionHolder amqpConnectionHolder,
Func<DirectMethodServiceRequest, Task> onMethodCallback,
Func<DirectMethodRequest, Task> onMethodCallback,
Action<AmqpMessage, string, IotHubClientException> twinMessageCallback,
Func<IncomingMessage, Task<MessageAcknowledgement>> onMessageReceivedCallback,
Action onUnitDisconnected)
Expand Down Expand Up @@ -788,7 +788,7 @@ private async Task OpenMethodsSenderLinkAsync(AmqpIotSession amqpIotSession, str
}
}

private void OnMethodReceived(DirectMethodServiceRequest directMethodRequest)
private void OnMethodReceived(DirectMethodRequest directMethodRequest)
{
if (Logging.IsEnabled)
Logging.Enter(this, directMethodRequest, nameof(OnMethodReceived));
Expand Down
2 changes: 1 addition & 1 deletion iothub/device/src/Transport/Amqp/AmqpUnitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public AmqpUnit CreateAmqpUnit(
IConnectionCredentials connectionCredentials,
AdditionalClientInformation additionalClientInformation,
IotHubClientAmqpSettings amqpSettings,
Func<DirectMethodServiceRequest, Task> onMethodCallback,
Func<DirectMethodRequest, Task> onMethodCallback,
Action<AmqpMessage, string, IotHubClientException> twinMessageListener,
Func<IncomingMessage, Task<MessageAcknowledgement>> onMessageReceivedCallback,
Action onUnitDisconnected)
Expand Down
2 changes: 1 addition & 1 deletion iothub/device/src/Transport/Amqp/IAmqpUnitManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ AmqpUnit CreateAmqpUnit(
IConnectionCredentials connectionCredentials,
AdditionalClientInformation additionalClientInformation,
IotHubClientAmqpSettings amqpSettings,
Func<DirectMethodServiceRequest, Task> onMethodCallback,
Func<DirectMethodRequest, Task> onMethodCallback,
Action<AmqpMessage, string, IotHubClientException> twinMessageListener,
Func<IncomingMessage, Task<MessageAcknowledgement>> onMessageReceivedCallback,
Action onUnitDisconnected);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ public static AmqpMessage ConvertDirectMethodResponseToAmqpMessage(DirectMethodR
/// <summary>
/// Copies the properties from the AMQP message to the MethodRequest instance.
/// </summary>
public static DirectMethodServiceRequest ConstructMethodRequestFromAmqpMessage(AmqpMessage amqpMessage, PayloadConvention payloadConvention)
public static DirectMethodRequest ConstructMethodRequestFromAmqpMessage(AmqpMessage amqpMessage, PayloadConvention payloadConvention)
{
Argument.AssertNotNull(amqpMessage, nameof(amqpMessage));

Expand All @@ -255,7 +255,7 @@ public static DirectMethodServiceRequest ConstructMethodRequestFromAmqpMessage(A

using var ms = new MemoryStream();
amqpMessage.BodyStream.CopyTo(ms);
return new DirectMethodServiceRequest
return new DirectMethodRequest
{
PayloadConvention = payloadConvention,
MethodName = methodName,
Expand Down
Loading

0 comments on commit 6e12326

Please sign in to comment.