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");
}
}
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);
}
Aggregations