internal DescribeTasksResponse DescribeTasks(DescribeTasksRequest request) { var marshaller = new DescribeTasksRequestMarshaller(); var unmarshaller = DescribeTasksResponseUnmarshaller.Instance; return(Invoke <DescribeTasksRequest, DescribeTasksResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// Initiates the asynchronous execution of the DescribeTasks operation. /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the DescribeTasks operation.</param> /// <param name="cancellationToken"> /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. /// </param> /// <returns>The task object representing the asynchronous operation.</returns> public Task <DescribeTasksResponse> DescribeTasksAsync(DescribeTasksRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new DescribeTasksRequestMarshaller(); var unmarshaller = DescribeTasksResponseUnmarshaller.Instance; return(InvokeAsync <DescribeTasksRequest, DescribeTasksResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// 该接口(DescribleTasks)用于查询任务列表 /// </summary> /// <param name="req"><see cref="DescribeTasksRequest"/></param> /// <returns><see cref="DescribeTasksResponse"/></returns> public DescribeTasksResponse DescribeTasksSync(DescribeTasksRequest req) { JsonResponseModel <DescribeTasksResponse> rsp = null; try { var strResp = this.InternalRequestSync(req, "DescribeTasks"); rsp = JsonConvert.DeserializeObject <JsonResponseModel <DescribeTasksResponse> >(strResp); } catch (JsonSerializationException e) { throw new TencentCloudSDKException(e.Message); } return(rsp.Response); }
public static async Task <string> GetContainerHostUrlAsync(IConfiguration configuration, string scheme = "http") { try { // This implementation is for local. var gatewayUrl = configuration["GATEWAY_URL"]; if (!string.IsNullOrWhiteSpace(gatewayUrl)) { return(gatewayUrl); } // Following implementation is for AWS-ECS. var uri = configuration["ECS_CONTAINER_METADATA_URI"]; if (string.IsNullOrWhiteSpace(uri)) { throw new InvalidOperationException("ECS_CONTAINER_METADATA_URI does not exist."); } using (var client = new HttpClient()) { var response = await client.GetAsync(uri); var content = await response.Content.ReadAsStringAsync(); var json = JObject.Parse(content); var cluster = json["Labels"]["com.amazonaws.ecs.cluster"].ToString(); var taskArn = json["Labels"]["com.amazonaws.ecs.task-arn"].ToString(); var ecs = new AmazonECSClient(); var request = new DescribeTasksRequest { Cluster = cluster, Tasks = new List <string> { taskArn } }; var tasks = await ecs.DescribeTasksAsync(request); var container = tasks.Tasks[0].Containers[0]; var address = container.NetworkInterfaces[0].PrivateIpv4Address; if (container.NetworkBindings.Any()) { var port = container.NetworkBindings[0].HostPort; return($"{scheme}://{address}:{port}/"); } else { var taskDef = await ecs.DescribeTaskDefinitionAsync( new DescribeTaskDefinitionRequest { TaskDefinition = tasks.Tasks[0].TaskDefinitionArn }); var port = taskDef.TaskDefinition.ContainerDefinitions[0].PortMappings[0].HostPort; return($"{scheme}://{address}:{port}/"); } } } catch (Exception e) { Console.WriteLine(e.ToString()); throw; } }
/// <summary> /// 云拔测-可用性agent任务查询接口 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public async Task <DescribeTasksResponse> DescribeTasks(DescribeTasksRequest request) { return(await new DescribeTasksExecutor().Client(this).Execute <DescribeTasksResponse, DescribeTasksResult, DescribeTasksRequest>(request).ConfigureAwait(false)); }
/// <summary> /// 云拔测-可用性agent任务查询接口 /// </summary> /// <param name="request">请求参数信息</param> /// <returns>请求结果信息</returns> public DescribeTasksResponse DescribeTasks(DescribeTasksRequest request) { return(new DescribeTasksExecutor().Client(this).Execute <DescribeTasksResponse, DescribeTasksResult, DescribeTasksRequest>(request)); }