public UpdateServiceResponse UpdateServiceSetting(UpdateServiceRequest request) { var response = new UpdateServiceResponse { ResponseStatus = ResponseStatus.Success }; var settingsProvider = new SettingsProvider(); try { if (request.ActionType == ActionType.Update) { response.isSuccessful = settingsProvider.UpdateService(request); } else { response.ResponseStatus = ResponseStatus.Failure; response.ResponseDescription = "Not update action"; } } catch (Exception ex) { response.ResponseStatus = ResponseStatus.Failure; response.ResponseDescription = ex.Message; } 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) { UpdateServiceResponse response = new UpdateServiceResponse(); 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); }
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 UpdateServiceResponse Unmarshall(UnmarshallerContext context) { UpdateServiceResponse updateServiceResponse = new UpdateServiceResponse(); updateServiceResponse.HttpResponse = context.HttpResponse; updateServiceResponse.Code = context.IntegerValue("UpdateService.Code"); updateServiceResponse.Message = context.StringValue("UpdateService.Message"); updateServiceResponse.RequestId = context.StringValue("UpdateService.RequestId"); return(updateServiceResponse); }