public void RegisterUserChangeRequestHandler(Type credentialsType, UserChangeRequestUserType changeType, Func <IHDInsightSubscriptionAbstractionContext, string, string, Uri> uriBuilder, Func <UserChangeRequestOperationType, string, string, DateTimeOffset, string> payloadConverter) { this.userChangeRequestHandlers[changeType] = new Tuple <Func <IHDInsightSubscriptionAbstractionContext, string, string, Uri>, Func <UserChangeRequestOperationType, string, string, DateTimeOffset, string> >(uriBuilder, payloadConverter); }
public void RegisterUserChangeRequestHandler(Type credentialsType, UserChangeRequestUserType changeType, Func<IHDInsightSubscriptionAbstractionContext, string, string, Uri> uriBuilder, Func<UserChangeRequestOperationType, string, string, DateTimeOffset, string> payloadConverter) { this.userChangeRequestHandlers[changeType] = new Tuple<Func<IHDInsightSubscriptionAbstractionContext, string, string, Uri>, Func<UserChangeRequestOperationType, string, string, DateTimeOffset, string>>(uriBuilder, payloadConverter); }
// This method is used by the NonPublic SDK. Be aware of braking changes to that project when you alter it. internal static void RegisterUserChangeRequestHandler(Type credentialsType, UserChangeRequestUserType changeType, Func <IHDInsightSubscriptionAbstractionContext, string, string, Uri> uriBuilder, Func <UserChangeRequestOperationType, string, string, DateTimeOffset, string> payloadConverter) { var manager = ServiceLocator.Instance.Locate <IUserChangeRequestManager>(); manager.RegisterUserChangeRequestHandler(credentialsType, changeType, uriBuilder, payloadConverter); }
/// <inheritdoc /> public PayloadResponse <UserChangeRequestStatus> DeserializeConnectivityStatus(string payload) { XmlDocument doc = new XmlDocument(); using (var stream = payload.ToUtf8Stream()) using (var reader = XmlReader.Create(stream)) { doc.Load(reader); } var manager = new DynaXmlNamespaceTable(doc); PayloadResponse <UserChangeRequestStatus> result = new PayloadResponse <UserChangeRequestStatus>(); var node = doc.SelectSingleNode("/def:PassthroughResponse/def:Data", manager.NamespaceManager); if (node.IsNotNull()) { result.Data = new UserChangeRequestStatus(); var data = node; node = data.SelectSingleNode("def:State", manager.NamespaceManager); UserChangeRequestOperationStatus status; if (node.IsNull() || !UserChangeRequestOperationStatus.TryParse(node.InnerText, out status)) { throw new SerializationException("Unable to deserialize the server response."); } result.Data.State = status; node = data.SelectSingleNode("def:UserType", manager.NamespaceManager); UserChangeRequestUserType userType; if (node.IsNull() || !UserChangeRequestUserType.TryParse(node.InnerText, out userType)) { throw new SerializationException("Unable to deserialize the server response."); } result.Data.UserType = userType; node = data.SelectSingleNode("def:OperationType", manager.NamespaceManager); UserChangeRequestOperationType operationType; if (node.IsNull() || !UserChangeRequestOperationType.TryParse(node.InnerText, out operationType)) { throw new SerializationException("Unable to deserialize the server response."); } result.Data.OperationType = operationType; node = data.SelectSingleNode("def:RequestIssueDate", manager.NamespaceManager); DateTime requestTime; if (node.IsNull() || !DateTime.TryParse(node.InnerText, out requestTime)) { throw new SerializationException("Unable to deserialize the server response."); } result.Data.RequestIssueDate = requestTime.ToUniversalTime(); node = data.SelectSingleNode("def:Error", manager.NamespaceManager); result.Data.ErrorDetails = this.GetErrorDetails(node, manager.NamespaceManager); } node = doc.SelectSingleNode("/def:PassthroughResponse/def:Error", manager.NamespaceManager); result.ErrorDetails = this.GetErrorDetails(node, manager.NamespaceManager); return(result); }
public Task <Guid> EnableDisableProtocol( UserChangeRequestUserType protocol, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { return(underlying.EnableDisableProtocol(protocol, operation, dnsName, location, userName, password, expiration)); }
public Task <Guid> EnableDisableProtocol( UserChangeRequestUserType protocol, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { throw new NotImplementedException(); }
// This method is used by the NonPublic SDK. Be aware of braking changes to that project when you alter it. private static async Task <Guid> EnableDisableUserPocoCall(IHDInsightSubscriptionAbstractionContext context, UserChangeRequestUserType requestType, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { var client = ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>().Create(context.Credentials, context, false); var operationId = await client.EnableDisableProtocol(requestType, operation, dnsName, location, userName, password, expiration); return(operationId); }
// This method is used by the NonPublic SDK. Be aware of breaking changes to that project when you alter it. internal static async Task EnableDisableUser(IHDInsightSubscriptionAbstractionContext context, UserChangeRequestUserType requestType, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { var client = ServiceLocator.Instance.Locate <IHDInsightManagementPocoClientFactory>().Create(context.Credentials, context, false); Guid operationId = await EnableDisableUserPocoCall(context, requestType, operation, dnsName, location, userName, password, expiration); await client.WaitForOperationCompleteOrError(dnsName, location, operationId, TimeSpan.FromHours(1), context.CancellationToken); }
public async Task <Guid> EnableDisableProtocol(UserChangeRequestUserType requestType, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { var overrideHandlers = ServiceLocator.Instance.Locate <IHDInsightClusterOverrideManager>().GetHandlers(this.credentials, this.Context, this.ignoreSslErrors); var manager = ServiceLocator.Instance.Locate <IUserChangeRequestManager>(); var handler = manager.LocateUserChangeRequestHandler(this.credentials.GetType(), requestType); var payload = handler.Item2(operation, userName, password, expiration); var client = ServiceLocator.Instance.Locate <IHDInsightManagementRestClientFactory>().Create(this.credentials, this.Context, this.ignoreSslErrors); var response = await client.EnableDisableUserChangeRequest(dnsName, location, requestType, payload); var resultId = overrideHandlers.PayloadConverter.DeserializeConnectivityResponse(response.Content); var pocoHelper = new HDInsightManagementPocoHelper(); pocoHelper.ValidateResponse(resultId); return(resultId.Data); }
// Method = "POST", UriTemplate = "{subscriptionId}/cloudservices/{cloudServiceName}/resources/hdinsight/~/containers/{containerName}/services/http" public async Task <IHttpResponseMessageAbstraction> EnableDisableUserChangeRequest(string dnsName, string location, UserChangeRequestUserType requestType, string payload) { var manager = ServiceLocator.Instance.Locate <IUserChangeRequestManager>(); var handler = manager.LocateUserChangeRequestHandler(this.credentials.GetType(), requestType); // Creates an HTTP client if (handler.IsNull()) { throw new NotSupportedException("Request to submit a UserChangeRequest that is not supported by this client"); } using (IHttpClientAbstraction client = ServiceLocator.Instance.Locate <IHDInsightHttpClientAbstractionFactory>().Create(this.credentials, this.context, this.ignoreSslErrors)) { var hadoopContext = new HDInsightSubscriptionAbstractionContext(this.credentials, this.context); client.RequestUri = handler.Item1(hadoopContext, dnsName, location); client.Method = HttpMethod.Post; client.RequestHeaders.Add(HDInsightRestConstants.XMsVersion); client.RequestHeaders.Add(HDInsightRestConstants.SchemaVersion2); client.RequestHeaders.Add(HDInsightRestConstants.Accept); client.Content = new StringContent(payload); IHttpResponseMessageAbstraction httpResponse = await client.SendAsync(); if (httpResponse.StatusCode != HttpStatusCode.Accepted) { throw new HttpLayerException(httpResponse.StatusCode, httpResponse.Content) { HelpLink = HelpLinkForException }; } return(httpResponse); } }
// Method = "POST", UriTemplate = "{subscriptionId}/cloudservices/{cloudServiceName}/resources/hdinsight/~/containers/{containerName}/services/http" public async Task<IHttpResponseMessageAbstraction> EnableDisableUserChangeRequest(string dnsName, string location, UserChangeRequestUserType requestType, string payload) { var manager = ServiceLocator.Instance.Locate<IUserChangeRequestManager>(); var handler = manager.LocateUserChangeRequestHandler(this.credentials.GetType(), requestType); // Creates an HTTP client if (handler.IsNull()) { throw new NotSupportedException("Request to submit a UserChangeRequest that is not supported by this client"); } using (IHttpClientAbstraction client = ServiceLocator.Instance.Locate<IHDInsightHttpClientAbstractionFactory>().Create(this.credentials, this.context, this.ignoreSslErrors)) { var hadoopContext = new HDInsightSubscriptionAbstractionContext(this.credentials, this.context); client.RequestUri = handler.Item1(hadoopContext, dnsName, location); client.Method = HttpMethod.Post; client.RequestHeaders.Add(HDInsightRestConstants.XMsVersion); client.RequestHeaders.Add(HDInsightRestConstants.SchemaVersion2); client.RequestHeaders.Add(HDInsightRestConstants.Accept); client.Content = new StringContent(payload); IHttpResponseMessageAbstraction httpResponse = await client.SendAsync(); if (httpResponse.StatusCode != HttpStatusCode.Accepted) { throw new HttpLayerException(httpResponse.StatusCode, httpResponse.Content) { HelpLink = HelpLinkForException }; } return httpResponse; } }
public Task<IHttpResponseMessageAbstraction> EnableDisableUserChangeRequest(string dnsName, string location, UserChangeRequestUserType requestType, string payload) { if (requestType == UserChangeRequestUserType.Http) { return this.EnableDisableUserChangeRequest(dnsName, location, payload); } if (requestType == UserChangeRequestUserType.Rdp) { return this.EnableDisableRdp(dnsName, location, payload); } throw new NotSupportedException("The change operation is not supported."); }
public Task<Guid> EnableDisableProtocol( UserChangeRequestUserType protocol, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { return underlying.EnableDisableProtocol(protocol, operation, dnsName, location, userName, password, expiration); }
public Task<IHttpResponseMessageAbstraction> EnableDisableUserChangeRequest(string dnsName, string location, UserChangeRequestUserType requestType, string payload) { throw new NotImplementedException(); }
public Task <IHttpResponseMessageAbstraction> EnableDisableUserChangeRequest(string dnsName, string location, UserChangeRequestUserType requestType, string payload) { throw new NotImplementedException(); }
/// <inheritdoc /> public async Task <Guid> EnableDisableProtocol(UserChangeRequestUserType protocol, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { throw new NotSupportedException(UnSupportedOperationMessage); }
public async Task<Guid> EnableDisableProtocol(UserChangeRequestUserType requestType, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { var overrideHandlers = ServiceLocator.Instance.Locate<IHDInsightClusterOverrideManager>().GetHandlers(this.credentials, this.Context, this.ignoreSslErrors); var manager = ServiceLocator.Instance.Locate<IUserChangeRequestManager>(); var handler = manager.LocateUserChangeRequestHandler(this.credentials.GetType(), requestType); var payload = handler.Item2(operation, userName, password, expiration); var client = ServiceLocator.Instance.Locate<IHDInsightManagementRestClientFactory>().Create(this.credentials, this.Context, this.ignoreSslErrors); var response = await client.EnableDisableUserChangeRequest(dnsName, location, requestType, payload); var resultId = overrideHandlers.PayloadConverter.DeserializeConnectivityResponse(response.Content); var pocoHelper = new HDInsightManagementPocoHelper(); pocoHelper.ValidateResponse(resultId); return resultId.Data; }
Func<UserChangeRequestOperationType, string, string, DateTimeOffset, string>> LocateUserChangeRequestHandler(Type credentialsType, UserChangeRequestUserType changeType) { return this.userChangeRequestHandlers[changeType]; }
Func <UserChangeRequestOperationType, string, string, DateTimeOffset, string> > LocateUserChangeRequestHandler(Type credentialsType, UserChangeRequestUserType changeType) { return(this.userChangeRequestHandlers[changeType]); }
// This method is used by the NonPublic SDK. Be aware of breaking changes to that project when you alter it. internal static async Task EnableDisableUser(IHDInsightSubscriptionAbstractionContext context, UserChangeRequestUserType requestType, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { var client = ServiceLocator.Instance.Locate<IHDInsightManagementPocoClientFactory>().Create(context.Credentials, context, false); Guid operationId = await EnableDisableUserPocoCall(context, requestType, operation, dnsName, location, userName, password, expiration); await client.WaitForOperationCompleteOrError(dnsName, location, operationId, TimeSpan.FromHours(1), context.CancellationToken); }
// This method is used by the NonPublic SDK. Be aware of braking changes to that project when you alter it. internal static void RegisterUserChangeRequestHandler(Type credentialsType, UserChangeRequestUserType changeType, Func<IHDInsightSubscriptionAbstractionContext, string, string, Uri> uriBuilder, Func<UserChangeRequestOperationType, string, string, DateTimeOffset, string> payloadConverter) { var manager = ServiceLocator.Instance.Locate<IUserChangeRequestManager>(); manager.RegisterUserChangeRequestHandler(credentialsType, changeType, uriBuilder, payloadConverter); }
// This method is used by the NonPublic SDK. Be aware of braking changes to that project when you alter it. private static async Task<Guid> EnableDisableUserPocoCall(IHDInsightSubscriptionAbstractionContext context, UserChangeRequestUserType requestType, UserChangeRequestOperationType operation, string dnsName, string location, string userName, string password, DateTimeOffset expiration) { var client = ServiceLocator.Instance.Locate<IHDInsightManagementPocoClientFactory>().Create(context.Credentials, context, false); var operationId = await client.EnableDisableProtocol(requestType, operation, dnsName, location, userName, password, expiration); return operationId; }