public CreateServiceResponse AddServiceSetting(CreateServiceRequest request)
        {
            var response = new CreateServiceResponse {
                ResponseStatus = ResponseStatus.Success
            };

            var settingsProvider = new SettingsProvider();

            try
            {
                if (request.ActionType == ActionType.Insert)
                {
                    response.isSuccessful = settingsProvider.AddService(request);
                }
                else
                {
                    response.ResponseStatus      = ResponseStatus.Failure;
                    response.ResponseDescription = "Not update action";
                }
            }
            catch (Exception ex)
            {
                response.ResponseStatus      = ResponseStatus.Failure;
                response.ResponseDescription = ex.Message;
            }
            return(response);
        }
Пример #2
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateServiceResponse response = new CreateServiceResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("OperationId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.OperationId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Service", targetDepth))
                {
                    var unmarshaller = ServiceUnmarshaller.Instance;
                    response.Service = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
Пример #3
0
        public void TestServiceCRUD()
        {
            string name = "test-csharp-" + TestConfig.RandomString(8);

            this.ServiceNames.Add(name);
            string desc = "create by c# sdk";

            CreateServiceResponse response = tf.Client.CreateService(
                new CreateServiceRequest(
                    name, desc,
                    tf.ServiceRole, tf.LogConfig, true, tf.VpcConfig, tf.NasConfig
                    )
                );

            Console.WriteLine(response.Content);
            Console.WriteLine(response.Headers);
            Assert.Equal(name, response.Data.ServiceName);
            Assert.Equal(desc, response.Data.Description);
            Assert.Equal(tf.ServiceRole, response.Data.Role);
            Assert.True(response.Data.InternetAccess);
            Assert.Equal(tf.LogConfig, response.Data.LogConfig);
            Assert.Equal(tf.VpcConfig, response.Data.VpcConfig);
            Assert.Equal(tf.NasConfig, response.Data.NasConfig);

            string newDesc = "create by c# sdk new update";
            UpdateServiceResponse response2 = tf.Client.UpdateService(
                new UpdateServiceRequest(
                    name, newDesc)
                );

            Assert.Equal(name, response2.Data.ServiceName);
            Assert.Equal(newDesc, response2.Data.Description);
            Assert.Equal(tf.ServiceRole, response2.Data.Role);
            Assert.True(response2.Data.InternetAccess);
            Assert.Equal(tf.LogConfig, response2.Data.LogConfig);
            Assert.Equal(tf.VpcConfig, response2.Data.VpcConfig);
            Assert.Equal(tf.NasConfig, response2.Data.NasConfig);


            GetServiceResponse response3 = tf.Client.GetService(
                new GetServiceRequest(name)
                );

            Assert.Equal(name, response3.Data.ServiceName);
            Assert.Equal(newDesc, response3.Data.Description);
            Assert.Equal(tf.ServiceRole, response3.Data.Role);
            Assert.True(response3.Data.InternetAccess);
            Assert.Equal(tf.LogConfig, response3.Data.LogConfig);
            Assert.Equal(tf.VpcConfig, response3.Data.VpcConfig);
            Assert.Equal(tf.NasConfig, response3.Data.NasConfig);

            var response4 = tf.Client.DeleteService(new DeleteServiceRequest(name));

            this.ServiceNames.Remove(name);
            Assert.Equal(204, response4.StatusCode);
        }
        public static CreateServiceResponse Unmarshall(UnmarshallerContext context)
        {
            CreateServiceResponse createServiceResponse = new CreateServiceResponse();

            createServiceResponse.HttpResponse = context.HttpResponse;
            createServiceResponse.Code         = context.IntegerValue("CreateService.Code");
            createServiceResponse.Message      = context.StringValue("CreateService.Message");
            createServiceResponse.RequestId    = context.StringValue("CreateService.RequestId");

            CreateServiceResponse.CreateService_Data data = new CreateServiceResponse.CreateService_Data();
            data.Id = context.LongValue("CreateService.Data.Id");
            createServiceResponse.Data = data;

            return(createServiceResponse);
        }
Пример #5
0
        public static CreateServiceResponse Unmarshall(UnmarshallerContext _ctx)
        {
            CreateServiceResponse createServiceResponse = new CreateServiceResponse();

            createServiceResponse.HttpResponse = _ctx.HttpResponse;
            createServiceResponse.Code         = _ctx.IntegerValue("CreateService.Code");
            createServiceResponse.ErrMsg       = _ctx.StringValue("CreateService.ErrMsg");
            createServiceResponse.RequestId    = _ctx.StringValue("CreateService.RequestId");
            createServiceResponse.Success      = _ctx.BooleanValue("CreateService.Success");

            CreateServiceResponse.CreateService_Result result = new CreateServiceResponse.CreateService_Result();
            result.ServiceId             = _ctx.LongValue("CreateService.Result.ServiceId");
            createServiceResponse.Result = result;

            return(createServiceResponse);
        }
Пример #6
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateServiceResponse response = new CreateServiceResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("ApplicationId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ApplicationId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Arn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Arn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("CreatedByAccountId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.CreatedByAccountId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("CreatedTime", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.CreatedTime = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Description", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Description = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("EndpointType", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.EndpointType = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("EnvironmentId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.EnvironmentId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LambdaEndpoint", targetDepth))
                {
                    var unmarshaller = LambdaEndpointInputUnmarshaller.Instance;
                    response.LambdaEndpoint = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastUpdatedTime", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.LastUpdatedTime = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Name", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Name = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("OwnerAccountId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.OwnerAccountId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ServiceId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ServiceId = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("State", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.State = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Tags", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.Tags = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("UrlEndpoint", targetDepth))
                {
                    var unmarshaller = UrlEndpointInputUnmarshaller.Instance;
                    response.UrlEndpoint = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("VpcId", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.VpcId = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }