/// <summary> /// Unmarshaller the response from the service to the response class. /// </summary> /// <param name="context"></param> /// <returns></returns> public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context) { SubmitJobResponse response = new SubmitJobResponse(); context.Read(); int targetDepth = context.CurrentDepth; while (context.ReadAtDepth(targetDepth)) { if (context.TestExpression("jobArn", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.JobArn = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("jobId", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.JobId = unmarshaller.Unmarshall(context); continue; } if (context.TestExpression("jobName", targetDepth)) { var unmarshaller = StringUnmarshaller.Instance; response.JobName = unmarshaller.Unmarshall(context); continue; } } return(response); }
public static SubmitJobResponse Unmarshall(UnmarshallerContext context) { SubmitJobResponse submitJobResponse = new SubmitJobResponse(); submitJobResponse.HttpResponse = context.HttpResponse; submitJobResponse.RequestId = context.StringValue("SubmitJob.RequestId"); submitJobResponse.JobId = context.StringValue("SubmitJob.JobId"); return(submitJobResponse); }
public string Post([FromBody] Models.ModeloS3 data) { AmazonBatchClient batchClient = new AmazonBatchClient(); SubmitJobResponse submitJobResponse1 = batchClient.SubmitJobAsync(new SubmitJobRequest() { ContainerOverrides = new ContainerOverrides() //opciones de contenedor { Command = new List <string>() { data.bucket, data.key } //input del contenedor }, JobDefinition = "formacionBatch", //definicion de trabajo JobName = "trabajo-webservice", //nombre del trabajo JobQueue = "formacionBatch", //cola de trabajo }).Result; string clusterEndpoint = "docdb-2021-03-31-11-44-27.cluster-cihrsqslvehp.eu-west-1.docdb.amazonaws.com:27017"; string template = "mongodb://{0}:{1}@{2}/sampledatabase?ssl=true&replicaSet=rs0&readpreference={3}"; string username = "******"; string password = "******"; string readPreference = "secondaryPreferred"; string connectionString = String.Format(template, username, password, clusterEndpoint, readPreference); string pathToCAFile = "rdscombinedcabundle_cert_out.p7b"; // ADD CA certificate to local trust store // DO this once - Maybe when your service starts X509Store localTrustStore = new X509Store(StoreName.Root); X509Certificate2Collection certificateCollection = new X509Certificate2Collection(); certificateCollection.Import(pathToCAFile); try { localTrustStore.Open(OpenFlags.ReadWrite); localTrustStore.AddRange(certificateCollection); } catch (Exception ex) { Console.WriteLine("Root certificate import failed: " + ex.Message); throw; } finally { localTrustStore.Close(); } var settings = MongoClientSettings.FromUrl(new MongoUrl(connectionString)); var client = new MongoClient(settings); var database = client.GetDatabase("sample_database"); var collection = database.GetCollection <BsonDocument>("tracking"); collection.InsertOne(new BsonDocument { { "ip", HttpContext.Connection.RemoteIpAddress.ToString() }, { "fecha", DateTime.Now }, { "bucket", data.bucket }, { "key", data.key }, }); return("Trabajo enviado"); }
static void Main(string[] args) { string accessKey = ""; string secretKey = ""; Amazon.RegionEndpoint region = Amazon.RegionEndpoint.EUWest1; string strIdCuenta = ""; //Ejecucion de tarea en Fargate AmazonECSClient ECSClient = new AmazonECSClient(accessKey, secretKey, region); RunTaskResponse runTaskResponse = ECSClient.RunTaskAsync(new RunTaskRequest() { Cluster = "practica1", //nombre del cluster Count = 1, //número de tareas LaunchType = Amazon.ECS.LaunchType.FARGATE, //tipo de ejecucion NetworkConfiguration = new Amazon.ECS.Model.NetworkConfiguration() //configuracion de red { AwsvpcConfiguration = new Amazon.ECS.Model.AwsVpcConfiguration() //tipo de red awsvpc, la usada por Fargate { Subnets = new List <string>() { "subnet-831004e5" }, //subredes AssignPublicIp = Amazon.ECS.AssignPublicIp.ENABLED //asignar IP púlica } }, Overrides = new TaskOverride() //configuracion de contenedores { ContainerOverrides = new List <ContainerOverride>() //lista de contenedores a configurar { new ContainerOverride() //opciones del contenedor { Name = "FormacionFargateTask", //nombre del contenedor Command = new List <string>() { "formacion-batch-sieca", "mifichero" } //input del contenedor } } }, TaskDefinition = "FormacionFargateTask" //tarea a ejecutar }).Result; //Ejecucion de trabajo en Batch AmazonBatchClient batchClient = new AmazonBatchClient(accessKey, secretKey, region); SubmitJobResponse submitJobResponse = batchClient.SubmitJobAsync(new SubmitJobRequest() { ContainerOverrides = new ContainerOverrides() //opciones de contenedor { Command = new List <string>() { "formacion-batch-sieca", "mifichero" } //input del contenedor }, JobDefinition = "formacionBatch", //definicion de trabajo JobName = "mi-trabajo", //nombre del trabajo JobQueue = "formacionBatch", //cola de trabajo }).Result; }