예제 #1
0
        public void TestAsyncConfigCRUD()
        {
            var resp = tf.Client.CreateService(new CreateServiceRequest(Service));

            Console.WriteLine(resp.Content);
            Assert.Equal(200, resp.StatusCode);

            byte[] contents = File.ReadAllBytes(Directory.GetCurrentDirectory() + "/hello.zip");
            var    code     = new Code(Convert.ToBase64String(contents));
            var    response = tf.Client.CreateFunction(new CreateFunctionRequest(Service, Function, "python3", "index.handler", code, "desc"));

            Console.WriteLine(response.Content);
            Assert.NotEmpty(response.GetRequestID());
            var pReq = new PutFunctionAsyncConfigRequest(Service, "", Function)
            {
                AsyncConfig = new FunctionAsyncConfigMeta
                {
                    // Avoid being set to zero values by default, please set MaxAsyncEventAgeInSeconds and MaxAsyncRetryAttempts manually.
                    MaxAsyncEventAgeInSeconds = 100,
                    MaxAsyncRetryAttempts     = 1
                }
            };
            var response2 = tf.Client.PutFunctionAsyncConfig(pReq);

            Assert.Equal(200, response2.StatusCode);
            Assert.NotEmpty(response2.Data.CreatedTime);
            Assert.NotEmpty(response2.Data.LastModifiedTime);
            Assert.Equal(1, response2.Data.MaxAsyncRetryAttempts);
            Assert.Equal("LATEST", response2.Data.Qualifier);


            var response3 = tf.Client.GetFunctionAsyncConfig(new GetFunctionAsyncConfigRequest(Service, "", Function));

            Assert.Equal(response2.Data.MaxAsyncEventAgeInSeconds, response3.Data.MaxAsyncEventAgeInSeconds);

            var resp1 = tf.Client.ListFunctionAsyncConfigs(new ListFunctionAsyncConfigsRequest(Service, Function));

            Assert.Equal(200, resp1.StatusCode);
            Assert.Empty(resp1.Data.NextToken);
            Assert.Single(resp1.Data.AsyncConfigs);
            Assert.Equal(response2.Data.MaxAsyncEventAgeInSeconds, resp1.Data.AsyncConfigs[0].MaxAsyncEventAgeInSeconds);

            var resp2 = tf.Client.DeleteFunctionAsyncConfig(new DeleteFunctionAsyncConfigRequest(Service, "", Function));

            Assert.Equal(204, resp2.StatusCode);

            var response4 = tf.Client.GetFunctionAsyncConfig(new GetFunctionAsyncConfigRequest(Service, "", Function));

            Assert.Equal(404, response4.StatusCode);
        }
예제 #2
0
 /// <summary>
 /// put function async config.
 /// </summary>
 /// <returns>dict</returns>
 /// <param name="putFunctionAsyncConfigRequest">Put function async config request.</param>
 public PutFunctionAsyncConfigResponse PutFunctionAsyncConfig(PutFunctionAsyncConfigRequest putFunctionAsyncConfigRequest)
 {
     return(this.DoRequestCommon <PutFunctionAsyncConfigResponse>(putFunctionAsyncConfigRequest.GenHttpRequest(Config)));
 }