/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateDeploymentResponse response = new CreateDeploymentResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("DeploymentArn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.DeploymentArn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("DeploymentId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.DeploymentId = unmarshaller.Unmarshall(context); continue; } } return(response); }
public async Task <HttpResponseMessage> Deploy(DeployInputs inputs) { CreateDeploymentResponse responseObj = new CreateDeploymentResponse(); HttpResponseMessage response = null; try { using (var client = GetRMClient(inputs.subscriptionId)) { // For now we just default to East US for the resource group location. var resourceResult = await client.ResourceGroups.CreateOrUpdateAsync( inputs.resourceGroup.name, new ResourceGroup { Location = inputs.resourceGroup.location }); var templateParams = inputs.parameters.ToString(); Deployment basicDeployment = await this.GetDeploymentPayload(inputs); var deploymentResult = await client.Deployments.CreateOrUpdateAsync( inputs.resourceGroup.name, inputs.resourceGroup.name, basicDeployment); response = Request.CreateResponse(HttpStatusCode.OK, responseObj); } } catch (CloudException ex) { responseObj.Error = ex.ErrorMessage; responseObj.ErrorCode = ex.ErrorCode; response = Request.CreateResponse(HttpStatusCode.BadRequest, responseObj); } return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateDeploymentResponse response = new CreateDeploymentResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("fileUploadUrls", targetDepth)) { var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance); response.FileUploadUrls = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("jobId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.JobId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("zipUploadUrl", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.ZipUploadUrl = unmarshaller.Unmarshall(context); continue; } } return(response); }
public async Task <HttpResponseMessage> Deploy([FromBody] JObject parameters, string subscriptionId, string templateUrl) { CreateDeploymentResponse responseObj = new CreateDeploymentResponse(); HttpResponseMessage response = null; try { var resourceGroupName = GetParamOrDefault(parameters, "siteName", "mySite"); using (var client = GetRMClient(subscriptionId)) { // For now we just default to East US for the resource group location. var resourceResult = await client.ResourceGroups.CreateOrUpdateAsync(resourceGroupName, new BasicResourceGroup { Location = "East US" }); var templateParams = parameters.ToString(); var basicDeployment = new BasicDeployment { Parameters = templateParams, TemplateLink = new TemplateLink(new Uri(templateUrl)) }; var deploymentResult = await client.Deployments.CreateOrUpdateAsync(resourceGroupName, resourceGroupName, basicDeployment); response = Request.CreateResponse(HttpStatusCode.OK, responseObj); } } catch (CloudException ex) { responseObj.Error = ex.ErrorMessage; responseObj.ErrorCode = ex.ErrorCode; response = Request.CreateResponse(HttpStatusCode.BadRequest, responseObj); } return(response); }
public static CreateDeploymentResponse Unmarshall(UnmarshallerContext context) { CreateDeploymentResponse createDeploymentResponse = new CreateDeploymentResponse(); createDeploymentResponse.HttpResponse = context.HttpResponse; createDeploymentResponse.RequestId = context.StringValue("CreateDeployment.RequestId"); return(createDeploymentResponse); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateDeploymentResponse response = new CreateDeploymentResponse(); context.Read(); UnmarshallResult(context, response); return(response); }
public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateDeploymentResponse response = new CreateDeploymentResponse(); context.Read(); response.CreateDeploymentResult = CreateDeploymentResultUnmarshaller.GetInstance().Unmarshall(context); return(response); }
/// <summary> /// Deploys an application revision through the specified deployment group. /// </summary> /// <param name="applicationName">The name of an AWS CodeDeploy application associated with the applicable IAM user or AWS account.</param> /// <param name="deploymentGroup">The name of the deployment group.</param> /// <param name="settings">The <see cref="DeploySettings"/> used during the request to AWS.</param> /// <param name="cancellationToken">A cancellation token that can be used by other objects or threads to receive notice of cancellation.</param> public async Task <bool> CreateDeployment(string applicationName, string deploymentGroup, DeploySettings settings, CancellationToken cancellationToken = default(CancellationToken)) { if (String.IsNullOrEmpty(applicationName)) { throw new ArgumentNullException("applicationName"); } if (String.IsNullOrEmpty(deploymentGroup)) { throw new ArgumentNullException("deploymentGroup"); } // Create Request AmazonCodeDeployClient client = this.CreateClient(settings); CreateDeploymentRequest request = new CreateDeploymentRequest(); request.ApplicationName = applicationName; request.DeploymentGroupName = deploymentGroup; request.Revision = new RevisionLocation() { RevisionType = RevisionLocationType.S3, S3Location = new S3Location() { BundleType = BundleType.Zip, Bucket = settings.S3Bucket, Key = settings.S3Key, Version = settings.S3Version } }; // Check Response CreateDeploymentResponse response = await client.CreateDeploymentAsync(request, cancellationToken); if (response.HttpStatusCode == HttpStatusCode.OK) { _Log.Verbose("Successfully deployed application '{0}'", applicationName); return(true); } else { _Log.Error("Failed to deploy application '{0}'", applicationName); return(false); } }
public async Task <HttpResponseMessage> Deploy(DeployInputs inputs) { CreateDeploymentResponse responseObj = new CreateDeploymentResponse(); HttpResponseMessage response = null; var requestHost = HttpContext.Current.Request.UrlReferrer != null ? HttpContext.Current.Request.UrlReferrer.Host : null; if (requestHost != null) { // For Azure scenarios we do extra checks for cross domains if (!string.IsNullOrEmpty(Environment.GetEnvironmentVariable("WEBSITE_HOSTNAME"))) { if (!string.Equals(requestHost, "deploy.azure.com", StringComparison.OrdinalIgnoreCase) && !string.Equals(requestHost, "deploy-staging.azure.com", StringComparison.OrdinalIgnoreCase)) { return(Request.CreateResponse(HttpStatusCode.BadRequest, "Invalid request domain")); } } } try { using (var client = GetRMClient(inputs.subscriptionId)) { // For now we just default to East US for the resource group location. var resourceResult = await client.ResourceGroups.CreateOrUpdateAsync( inputs.resourceGroup.name, new ResourceGroup { Location = inputs.resourceGroup.location }); var templateParams = inputs.parameters.ToString(); Deployment basicDeployment = await this.GetDeploymentPayload(inputs); var deploymentResult = await client.Deployments.CreateOrUpdateAsync( inputs.resourceGroup.name, inputs.resourceGroup.name, basicDeployment); response = Request.CreateResponse(HttpStatusCode.OK, responseObj); } } catch (CloudException ex) { responseObj.Error = ex.ErrorMessage; responseObj.ErrorCode = ex.ErrorCode; response = Request.CreateResponse(HttpStatusCode.BadRequest, responseObj); } return(response); }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateDeploymentResponse response = new CreateDeploymentResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("autoDeployed", targetDepth)) { var unmarshaller = BoolUnmarshaller.Instance; response.AutoDeployed = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("createdDate", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.CreatedDate = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("deploymentId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.DeploymentId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("deploymentStatus", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.DeploymentStatus = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("deploymentStatusMessage", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.DeploymentStatusMessage = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("description", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Description = unmarshaller.Unmarshall(context); continue; } } return(response); }
private static void UnmarshallResult(JsonUnmarshallerContext context, CreateDeploymentResponse response) { int originalDepth = context.CurrentDepth; int targetDepth = originalDepth + 1; while (context.Read()) { if (context.TestExpression("DeploymentId", targetDepth)) { context.Read(); response.DeploymentId = StringUnmarshaller.GetInstance().Unmarshall(context); continue; } if (context.CurrentDepth <= originalDepth) { return; } } return; }
/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { CreateDeploymentResponse response = new CreateDeploymentResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("apiSummary", targetDepth)) { var unmarshaller = new DictionaryUnmarshaller <string, Dictionary <string, MethodSnapshot>, StringUnmarshaller, DictionaryUnmarshaller <string, MethodSnapshot, StringUnmarshaller, MethodSnapshotUnmarshaller> >(StringUnmarshaller.Instance, new DictionaryUnmarshaller <string, MethodSnapshot, StringUnmarshaller, MethodSnapshotUnmarshaller>(StringUnmarshaller.Instance, MethodSnapshotUnmarshaller.Instance)); response.ApiSummary = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("createdDate", targetDepth)) { var unmarshaller = DateTimeUnmarshaller.Instance; response.CreatedDate = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("description", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Description = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("id", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.Id = unmarshaller.Unmarshall(context); continue; } } return(response); }