Search in sources :

Example 1 with ListFunctionsResponse

use of com.aliyuncs.fc.response.ListFunctionsResponse in project fc-java-sdk by aliyun.

the class CreateUpdateFunctionTest method cleanUpFunctions.

private void cleanUpFunctions(String serviceName) {
    ListFunctionsRequest listFReq = new ListFunctionsRequest(serviceName);
    ListFunctionsResponse listFResp = client.listFunctions(listFReq);
    FunctionMetadata[] functions = listFResp.getFunctions();
    for (FunctionMetadata function : functions) {
        DeleteFunctionRequest deleteFReq = new DeleteFunctionRequest(serviceName, function.getFunctionName());
        client.deleteFunction(deleteFReq);
        System.out.println("Function " + serviceName + "/" + function.getFunctionName() + " is deleted");
    }
}
Also used : ListFunctionsResponse(com.aliyuncs.fc.response.ListFunctionsResponse)

Example 2 with ListFunctionsResponse

use of com.aliyuncs.fc.response.ListFunctionsResponse in project fc-java-sdk by aliyun.

the class FunctionComputeClientTest method testListFunctions.

@Test
public void testListFunctions() {
    final int numServices = 10;
    final int limit = 3;
    // Create service
    createService(SERVICE_NAME);
    // Create multiple functions under the test service
    for (int i = 0; i < numServices; i++) {
        CreateFunctionResponse createFResp = createFunction(FUNCTION_NAME + i);
        assertFalse(Strings.isNullOrEmpty(createFResp.getRequestId()));
    }
    ListFunctionsRequest listRequest = new ListFunctionsRequest(SERVICE_NAME);
    listRequest.setLimit(limit);
    listRequest.setPrefix(FUNCTION_NAME);
    ListFunctionsResponse listResponse = client.listFunctions(listRequest);
    int numCalled = 1;
    String nextToken = listResponse.getNextToken();
    while (nextToken != null) {
        listRequest.setNextToken(nextToken);
        listResponse = client.listFunctions(listRequest);
        nextToken = listResponse.getNextToken();
        numCalled++;
    }
    assertEquals(numServices / limit + 1, numCalled);
}
Also used : CreateFunctionResponse(com.aliyuncs.fc.response.CreateFunctionResponse) ListFunctionsResponse(com.aliyuncs.fc.response.ListFunctionsResponse) ListFunctionsRequest(com.aliyuncs.fc.request.ListFunctionsRequest) Test(org.junit.Test)

Aggregations

ListFunctionsResponse (com.aliyuncs.fc.response.ListFunctionsResponse)2 ListFunctionsRequest (com.aliyuncs.fc.request.ListFunctionsRequest)1 CreateFunctionResponse (com.aliyuncs.fc.response.CreateFunctionResponse)1 Test (org.junit.Test)1