/// <summary>
 /// Create or update a Traffic Manager endpoint.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.TrafficManager.IEndpointOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group containing the Traffic
 /// Manager endpoint to be created or updated.
 /// </param>
 /// <param name='profileName'>
 /// Required. The name of the Traffic Manager endpoint to be created or
 /// updated.
 /// </param>
 /// <param name='endpointType'>
 /// Required. The type of the Traffic Manager endpoint to be created or
 /// updated.
 /// </param>
 /// <param name='endpointName'>
 /// Required. The name of the Traffic Manager endpoint to be created or
 /// updated.
 /// </param>
 /// <param name='parameters'>
 /// Required. The Traffic Manager endpoint parameters supplied to the
 /// Update operation.
 /// </param>
 /// <returns>
 /// The response to a Traffic Manager endpoint 'CreateOrUpdate'
 /// operation.
 /// </returns>
 public static Task<EndpointUpdateResponse> UpdateAsync(this IEndpointOperations operations, string resourceGroupName, string profileName, string endpointType, string endpointName, EndpointUpdateParameters parameters)
 {
     return operations.UpdateAsync(resourceGroupName, profileName, endpointType, endpointName, parameters, CancellationToken.None);
 }
        public bool EnableDisableTrafficManagerEndpoint(TrafficManagerEndpoint endpoint, bool shouldEnableEndpointStatus)
        {
            endpoint.EndpointStatus = shouldEnableEndpointStatus ? Constants.StatusEnabled : Constants.StatusDisabled;

            Endpoint sdkEndpoint = endpoint.ToSDKEndpoint();
            sdkEndpoint.Properties.EndpointLocation = null;
            sdkEndpoint.Properties.EndpointMonitorStatus = null;
            sdkEndpoint.Properties.Priority = null;
            sdkEndpoint.Properties.Weight = null;
            sdkEndpoint.Properties.Target = null;
            sdkEndpoint.Properties.TargetResourceId = null;

            var parameters = new EndpointUpdateParameters
            {
                Endpoint = sdkEndpoint
            };

            AzureOperationResponse response = this.TrafficManagerManagementClient.Endpoints.Update(
                endpoint.ResourceGroupName,
                endpoint.ProfileName,
                endpoint.Type,
                endpoint.Name,
                parameters);

            return response.StatusCode.Equals(HttpStatusCode.Created);
        }
 /// <summary>
 /// Create or update a Traffic Manager endpoint.
 /// </summary>
 /// <param name='operations'>
 /// Reference to the
 /// Microsoft.Azure.Management.TrafficManager.IEndpointOperations.
 /// </param>
 /// <param name='resourceGroupName'>
 /// Required. The name of the resource group containing the Traffic
 /// Manager endpoint to be created or updated.
 /// </param>
 /// <param name='profileName'>
 /// Required. The name of the Traffic Manager endpoint to be created or
 /// updated.
 /// </param>
 /// <param name='endpointType'>
 /// Required. The type of the Traffic Manager endpoint to be created or
 /// updated.
 /// </param>
 /// <param name='endpointName'>
 /// Required. The name of the Traffic Manager endpoint to be created or
 /// updated.
 /// </param>
 /// <param name='parameters'>
 /// Required. The Traffic Manager endpoint parameters supplied to the
 /// Update operation.
 /// </param>
 /// <returns>
 /// The response to a Traffic Manager endpoint 'CreateOrUpdate'
 /// operation.
 /// </returns>
 public static EndpointUpdateResponse Update(this IEndpointOperations operations, string resourceGroupName, string profileName, string endpointType, string endpointName, EndpointUpdateParameters parameters)
 {
     return Task.Factory.StartNew((object s) => 
     {
         return ((IEndpointOperations)s).UpdateAsync(resourceGroupName, profileName, endpointType, endpointName, parameters);
     }
     , operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult();
 }