function nonce = getNonce(clusterID)
% This function requests from Cloud Center a nonce string for a specified
% cluster ID. The nonce is then to be used in conjunction with the Authorize
% API to perform a handshake with the Cloud Center web service and grant
% the caller permission to call other APIs related to the specified cluster.

%   Copyright 2019-2020 The MathWorks, Inc.

cloudCenterClient = parallel.internal.cloud.currentCloudCenterClient();
getNonceFcn = @() cloudCenterClient.getNonce(clusterID);
responseWithMessages = parallel.internal.mwa.invokeWithLogin(getNonceFcn);
parallel.internal.cloud.checkAndIssueWebServiceWarnings(responseWithMessages);

nonce = responseWithMessages.data.Nonce;
end
