internal CreateHealthCheckResponse CreateHealthCheck(CreateHealthCheckRequest request) { var marshaller = new CreateHealthCheckRequestMarshaller(); var unmarshaller = CreateHealthCheckResponseUnmarshaller.Instance; return(Invoke <CreateHealthCheckRequest, CreateHealthCheckResponse>(request, marshaller, unmarshaller)); }
/// <summary> /// Initiates the asynchronous execution of the CreateHealthCheck operation. /// <seealso cref="Amazon.Route53.IAmazonRoute53.CreateHealthCheck"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateHealthCheck 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 <CreateHealthCheckResponse> CreateHealthCheckAsync(CreateHealthCheckRequest request, CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateHealthCheckRequestMarshaller(); var unmarshaller = CreateHealthCheckResponseUnmarshaller.GetInstance(); return(Invoke <IRequest, CreateHealthCheckRequest, CreateHealthCheckResponse>(request, marshaller, unmarshaller, signer, cancellationToken)); }
public void HealthCheckTests() { var createRequest = new CreateHealthCheckRequest() { CallerReference = Guid.NewGuid().ToString(), HealthCheckConfig = new HealthCheckConfig() { Type = "TCP", Port = 22, IPAddress = "12.12.12.12", RequestInterval = 10, FailureThreshold = 5 } }; var createResponse = Client.CreateHealthCheck(createRequest); Assert.IsNotNull(createResponse.HealthCheck.Id); Assert.AreEqual(10, createResponse.HealthCheck.HealthCheckConfig.RequestInterval); Assert.AreEqual(5, createResponse.HealthCheck.HealthCheckConfig.FailureThreshold); var listResponse = Client.ListHealthChecks(); Assert.IsNotNull(listResponse.HealthChecks.FirstOrDefault(x => x.Id == createResponse.HealthCheck.Id)); Client.DeleteHealthCheck(new DeleteHealthCheckRequest() { HealthCheckId = createResponse.HealthCheck.Id }); listResponse = Client.ListHealthChecks(); Assert.IsNull(listResponse.HealthChecks.FirstOrDefault(x => x.Id == createResponse.HealthCheck.Id)); }
/// <summary> /// Initiates the asynchronous execution of the CreateHealthCheck operation. /// <seealso cref="Amazon.Route53.IAmazonRoute53"/> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateHealthCheck 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 <CreateHealthCheckResponse> CreateHealthCheckAsync(CreateHealthCheckRequest request, System.Threading.CancellationToken cancellationToken = default(CancellationToken)) { var marshaller = new CreateHealthCheckRequestMarshaller(); var unmarshaller = CreateHealthCheckResponseUnmarshaller.Instance; return(InvokeAsync <CreateHealthCheckRequest, CreateHealthCheckResponse>(request, marshaller, unmarshaller, cancellationToken)); }
/// <summary> /// <para> This action creates a new health check.</para> <para> To create a new health check, send a <c>POST</c> request to the /// <c>2013-04-01/healthcheck</c> resource. The request body must include an XML document with a <c>CreateHealthCheckRequest</c> element. The /// response returns the <c>CreateHealthCheckResponse</c> element that contains metadata about the health check.</para> /// </summary> /// /// <param name="request">Container for the necessary parameters to execute the CreateHealthCheck service method on /// AmazonRoute53.</param> /// /// <returns>The response from the CreateHealthCheck service method, as returned by AmazonRoute53.</returns> /// /// <exception cref="T:Amazon.Route53.Model.HealthCheckAlreadyExistsException" /> /// <exception cref="T:Amazon.Route53.Model.InvalidInputException" /> /// <exception cref="T:Amazon.Route53.Model.TooManyHealthChecksException" /> public CreateHealthCheckResponse CreateHealthCheck(CreateHealthCheckRequest request) { var task = CreateHealthCheckAsync(request); try { return(task.Result); } catch (AggregateException e) { ExceptionDispatchInfo.Capture(e.InnerException).Throw(); return(null); } }
public void HealthCheckTests() { var createRequest = new CreateHealthCheckRequest() { CallerReference = Guid.NewGuid().ToString(), HealthCheckConfig = new HealthCheckConfig() { Type = "TCP", Port = 22, IPAddress = "12.12.12.12", RequestInterval = 10, FailureThreshold = 5 } }; var createResponse = Client.CreateHealthCheck(createRequest); Assert.IsNotNull(createResponse.HealthCheck.Id); Assert.AreEqual(10, createResponse.HealthCheck.HealthCheckConfig.RequestInterval); Assert.AreEqual(5, createResponse.HealthCheck.HealthCheckConfig.FailureThreshold); string healthCheckId = createResponse.HealthCheck.Id; var listResponse = Client.ListHealthChecks(); Assert.IsNotNull(listResponse.HealthChecks.FirstOrDefault(x => x.Id == healthCheckId)); GetHealthCheckStatusResponse status = null; var stopTime = DateTime.Now + maxWaitTime; while (DateTime.Now < stopTime) { try { status = Client.GetHealthCheckStatus(new GetHealthCheckStatusRequest { HealthCheckId = healthCheckId }); break; } catch (NoSuchHealthCheckException) { Thread.Sleep(TimeSpan.FromSeconds(10)); } } Assert.IsNotNull(status); Assert.IsNotNull(status.HealthCheckObservations); var healthCheck = Client.GetHealthCheck(new GetHealthCheckRequest { HealthCheckId = healthCheckId }).HealthCheck; Assert.IsNotNull(healthCheck); Assert.IsNotNull(healthCheck.Id); Assert.IsNotNull(healthCheck.HealthCheckConfig); var tagSet = Client.ListTagsForResource(new ListTagsForResourceRequest { ResourceType = TagResourceType.Healthcheck, ResourceId = healthCheckId }).ResourceTagSet; Assert.IsNotNull(tagSet); Assert.IsNotNull(tagSet.ResourceId); Assert.IsNotNull(tagSet.ResourceType); Assert.IsNotNull(tagSet.Tags); Assert.AreEqual(0, tagSet.Tags.Count); Client.ChangeTagsForResource(new ChangeTagsForResourceRequest { ResourceType = TagResourceType.Healthcheck, ResourceId = healthCheckId, AddTags = new List <Tag> { new Tag { Key = "Test", Value = "true" } } }); tagSet = Client.ListTagsForResource(new ListTagsForResourceRequest { ResourceType = TagResourceType.Healthcheck, ResourceId = healthCheckId }).ResourceTagSet; Assert.IsNotNull(tagSet); Assert.IsNotNull(tagSet.ResourceId); Assert.IsNotNull(tagSet.ResourceType); Assert.IsNotNull(tagSet.Tags); Assert.AreEqual(1, tagSet.Tags.Count); Assert.AreEqual("Test", tagSet.Tags[0].Key); Assert.AreEqual("true", tagSet.Tags[0].Value); Client.DeleteHealthCheck(new DeleteHealthCheckRequest() { HealthCheckId = healthCheckId }); listResponse = Client.ListHealthChecks(); Assert.IsNull(listResponse.HealthChecks.FirstOrDefault(x => x.Id == healthCheckId)); }
public virtual Task <CreateHealthCheckResponse> CreateHealthCheckAsync(CreateHealthCheckRequest request, CancellationToken cancellationToken = default(CancellationToken)) { throw new NotImplementedException(); }
public async Task HandleInitR53(Instance inst, Dictionary <string, string> tags, string ec2State) { _logger.LogInformation("Handling CREATING R53 records"); var r53Spec = ResolveR53RecordSpec(inst, tags); var r53Routing = ResolveR53RoutingSpec(inst, tags); var r53Health = await ResolveR53HealthCheckSpec(inst, tags); HealthCheck existingHealth = await FindExistingHealthCheck(r53Health); // We apply the Health Check if any, first because // the subsequent Route policy may depend on it string healthCheckId = null; if (r53Health != null) { if (existingHealth == null) { var createRequ = new CreateHealthCheckRequest { CallerReference = r53Health.RefName, HealthCheckConfig = r53Health.Config, }; var createResp = await _r53.CreateHealthCheckAsync(createRequ); _logger.LogInformation("CREATE Health Check request completed, response:"); _logger.LogInformation(JsonSerializer.Serialize(createResp)); if (createResp.HealthCheck == null) { throw new Exception("failed to create Health Check"); } healthCheckId = createResp.HealthCheck.Id; var tagRequ = new ChangeTagsForResourceRequest { ResourceType = TagResourceType.Healthcheck, ResourceId = healthCheckId, AddTags = new List <Amazon.Route53.Model.Tag> { new Amazon.Route53.Model.Tag { Key = "Name", Value = r53Health.RefName, }, new Amazon.Route53.Model.Tag { Key = "vmbot:memo", Value = $"Managed by VMBot {nameof(R53Trigger)}", }, }, }; var tagResp = await _r53.ChangeTagsForResourceAsync(tagRequ); _logger.LogInformation("CHANGED TAGS for Health Check:"); _logger.LogInformation(JsonSerializer.Serialize(tagResp)); } else { var updateRequ = new UpdateHealthCheckRequest { HealthCheckId = existingHealth.Id, HealthCheckVersion = existingHealth.HealthCheckVersion, }; CopyOrReset(existingHealth.HealthCheckConfig, r53Health.Config, updateRequ); _logger.LogInformation("Resolved Health Check delta:"); _logger.LogInformation(JsonSerializer.Serialize(updateRequ)); var updateResp = await _r53.UpdateHealthCheckAsync(updateRequ); _logger.LogInformation("UPDATE Health Check request completed, response:"); _logger.LogInformation(JsonSerializer.Serialize(updateResp)); healthCheckId = updateResp.HealthCheck.Id; } } if (r53Spec != null) { var rrset = new ResourceRecordSet { Name = r53Spec.Name, Type = RRType.FindValue(r53Spec.Type), TTL = r53Spec.TTL, ResourceRecords = new List <ResourceRecord> { new ResourceRecord(r53Spec.Value), }, }; if (healthCheckId != null) { rrset.HealthCheckId = healthCheckId; } // Optional routing policy configuration r53Routing?.Apply(rrset); var changeRequ = new ChangeResourceRecordSetsRequest { HostedZoneId = r53Spec.Zone, ChangeBatch = new ChangeBatch { Changes = new List <Change> { new Change { Action = ChangeAction.UPSERT, ResourceRecordSet = rrset, } }, Comment = "change request applied by VMBot", } }; var changeResp = await _r53.ChangeResourceRecordSetsAsync(changeRequ); _logger.LogInformation("UPSERT Resource Record request completed, response:"); _logger.LogInformation(JsonSerializer.Serialize(changeResp)); } }