/// <summary>
 /// Update device details for a device by passing the updated details themselves.
 /// </summary>
 /// <param name="updatedDetails">The new state of DeviceDetails for the device.</param>
 /// <returns></returns>
 public TaskStatusInfo UpdateDeviceDetails(DeviceDetails updatedDetails)
 {
     var request = new DeviceDetailsRequest();
     MiscUtils.CopyProperties(updatedDetails, request);
     var taskStatusInfo = this.GetStorSimpleClient().DeviceDetails.UpdateDeviceDetails(request, this.GetCustomRequestHeaders());
     return taskStatusInfo;
 }
 /// <summary>
 /// Begin task for updating device details as specified by
 /// deviceDetails. The task can then be tracked for completion using
 /// returned task information
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IDeviceDetailsOperations.
 /// </param>
 /// <param name='deviceDetails'>
 /// Required. Updated DeviceDetails. Contains the corresponding DeviceId
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// This is the Task Response for all Async Calls
 /// </returns>
 public static GuidTaskResponse BeginUpdateDeviceDetails(this IDeviceDetailsOperations operations, DeviceDetailsRequest deviceDetails, CustomRequestHeaders customRequestHeaders)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IDeviceDetailsOperations)s).BeginUpdateDeviceDetailsAsync(deviceDetails, customRequestHeaders);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }
 /// <summary>
 /// Update device details for specified device given the specified data
 /// </summary>
 /// <param name="deviceDetails">Current device details for the device.</param>
 /// <param name="newName">New friendly name for the device. Null if its not to be changed</param>
 /// <param name="timeZone">New timeZone value for the device. Null if its not to be changed</param>
 /// <param name="secondaryDnsServer">New Secondary DNS Server address for the device. Null if its not to be changed</param>
 /// <param name="networkConfigs">An array or NetworkConfig objects for different interfaces. Null if its not to be changed</param>
 /// <returns></returns>
 public TaskStatusInfo UpdateDeviceDetails(DeviceDetails deviceDetails, string newName, TimeZoneInfo timeZone, IPAddress secondaryDnsServer, NetworkConfig[] networkConfigs)
 {
     // Update the object
     this.UpdateDeviceDetailsObject(deviceDetails, newName, timeZone, secondaryDnsServer, networkConfigs);
     // Copy stuff over from the DeviceDetails object into a new DeviceDetailsRequest object.
     var request = new DeviceDetailsRequest();
     MiscUtils.CopyProperties(deviceDetails, request);
     var taskStatusInfo = this.GetStorSimpleClient().DeviceDetails.UpdateDeviceDetails(request, this.GetCustomRequestHeaders());
     return taskStatusInfo;
 }
        public void CanUpdateDeviceDetailsTest()
        {
            using (var context = UndoContext.Current)
            {
                context.Start();

                var client = GetServiceClient<StorSimpleManagementClient>();

                // Get all devices.
                var devices = client.Devices.List(GetCustomRequestHeaders());

                // Get hold of an online device.
                var onlineDevice = devices.LastOrDefault(device => device.Status == DeviceStatus.Online);
                if (onlineDevice == null)
                {
                    throw new ArgumentException("Device Config/Details can be set only on online devices. No online device found in the resource specified for testing.");
                }

                // Get current device details/config
                var deviceId = onlineDevice.DeviceId;
                var details = client.DeviceDetails.Get(deviceId, GetCustomRequestHeaders()).DeviceDetails;
                var updatedDetails = new DeviceDetailsRequest();
                Helpers.CopyProperties(details, updatedDetails);

                // Alter device details/config for update
                DataHelpers.ModifyDeviceDetails(updatedDetails);

                // Try and update device details/config
                var taskStatus = client.DeviceDetails.UpdateDeviceDetails(updatedDetails, GetCustomRequestHeaders());

                //Assert the job status
                Assert.NotNull(taskStatus);
                Assert.True(taskStatus.Status == AsyncTaskStatus.Completed);
                Assert.True(taskStatus.Result == AsyncTaskResult.Succeeded);

                // Get device details again and make sure they match to the modified ones.
                var newDetails = client.DeviceDetails.Get(deviceId, GetCustomRequestHeaders()).DeviceDetails;

                Assert.NotNull(newDetails);
                Assert.Equal(newDetails.DeviceProperties.FriendlyName, updatedDetails.DeviceProperties.FriendlyName);
                Assert.Equal(newDetails.DeviceProperties.Description, updatedDetails.DeviceProperties.Description);
                Assert.Contains(updatedDetails.AlertNotification.AlertNotificationEmailList.Last(), newDetails.AlertNotification.AlertNotificationEmailList);
            }
        }
 /// <summary>
 /// Begin task for updating device details as specified by
 /// deviceDetails. The task can then be tracked for completion using
 /// returned task information
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IDeviceDetailsOperations.
 /// </param>
 /// <param name='deviceDetails'>
 /// Required. Updated DeviceDetails. Contains the corresponding DeviceId
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// This is the Task Response for all Async Calls
 /// </returns>
 public static Task<GuidTaskResponse> BeginUpdateDeviceDetailsAsync(this IDeviceDetailsOperations operations, DeviceDetailsRequest deviceDetails, CustomRequestHeaders customRequestHeaders)
 {
     return operations.BeginUpdateDeviceDetailsAsync(deviceDetails, customRequestHeaders, CancellationToken.None);
 }
 /// <summary>
 /// Update device details as specified by deviceDetails
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.WindowsAzure.Management.StorSimple.IDeviceDetailsOperations.
 /// </param>
 /// <param name='deviceDetails'>
 /// Required. Updated DeviceDetails. Contains the corresponding DeviceId
 /// </param>
 /// <param name='customRequestHeaders'>
 /// Required. The Custom Request Headers which client must use.
 /// </param>
 /// <returns>
 /// Info about the async task
 /// </returns>
 public static Task<TaskStatusInfo> UpdateDeviceDetailsAsync(this IDeviceDetailsOperations operations, DeviceDetailsRequest deviceDetails, CustomRequestHeaders customRequestHeaders)
 {
     return operations.UpdateDeviceDetailsAsync(deviceDetails, customRequestHeaders, CancellationToken.None);
 }