Search in sources :

Example 6 with ServiceCall

use of com.microsoft.rest.ServiceCall in project azure-sdk-for-java by Azure.

the class ComputeNodesImpl method addUserAsync.

/**
     * Adds a user account to the specified compute node.
     *
     * @param poolId The id of the pool that contains the compute node.
     * @param nodeId The id of the machine on which you want to create a user account.
     * @param user The user account to be created.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall addUserAsync(String poolId, String nodeId, ComputeNodeUser user, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (poolId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolId is required and cannot be null."));
        return null;
    }
    if (nodeId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter nodeId is required and cannot be null."));
        return null;
    }
    if (user == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter user is required and cannot be null."));
        return null;
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    Validator.validate(user, serviceCallback);
    final ComputeNodeAddUserOptions computeNodeAddUserOptions = null;
    Integer timeout = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.addUser(poolId, nodeId, user, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(addUserDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) ComputeNodeAddUserOptions(com.microsoft.azure.batch.protocol.models.ComputeNodeAddUserOptions) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Example 7 with ServiceCall

use of com.microsoft.rest.ServiceCall in project azure-sdk-for-java by Azure.

the class ComputeNodesImpl method updateUserAsync.

/**
     * Updates the password or expiration time of a user account on the specified compute node.
     *
     * @param poolId The id of the pool that contains the compute node.
     * @param nodeId The id of the machine on which you want to update a user account.
     * @param userName The name of the user account to update.
     * @param nodeUpdateUserParameter The parameters for the request.
     * @param computeNodeUpdateUserOptions Additional parameters for the operation
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall updateUserAsync(String poolId, String nodeId, String userName, NodeUpdateUserParameter nodeUpdateUserParameter, ComputeNodeUpdateUserOptions computeNodeUpdateUserOptions, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (poolId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolId is required and cannot be null."));
        return null;
    }
    if (nodeId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter nodeId is required and cannot be null."));
        return null;
    }
    if (userName == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter userName is required and cannot be null."));
        return null;
    }
    if (nodeUpdateUserParameter == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter nodeUpdateUserParameter is required and cannot be null."));
        return null;
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    Validator.validate(nodeUpdateUserParameter, serviceCallback);
    Validator.validate(computeNodeUpdateUserOptions, serviceCallback);
    Integer timeout = null;
    if (computeNodeUpdateUserOptions != null) {
        timeout = computeNodeUpdateUserOptions.timeout();
    }
    String clientRequestId = null;
    if (computeNodeUpdateUserOptions != null) {
        clientRequestId = computeNodeUpdateUserOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (computeNodeUpdateUserOptions != null) {
        returnClientRequestId = computeNodeUpdateUserOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (computeNodeUpdateUserOptions != null) {
        ocpDate = computeNodeUpdateUserOptions.ocpDate();
    }
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.updateUser(poolId, nodeId, userName, nodeUpdateUserParameter, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(updateUserDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Example 8 with ServiceCall

use of com.microsoft.rest.ServiceCall in project azure-sdk-for-java by Azure.

the class CertificatesImpl method getAsync.

/**
     * Gets information about the specified certificate.
     *
     * @param thumbprintAlgorithm The algorithm used to derive the thumbprint parameter. This must be sha1.
     * @param thumbprint The thumbprint of the certificate to get.
     * @param certificateGetOptions Additional parameters for the operation
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall getAsync(String thumbprintAlgorithm, String thumbprint, CertificateGetOptions certificateGetOptions, final ServiceCallback<Certificate> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (thumbprintAlgorithm == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter thumbprintAlgorithm is required and cannot be null."));
        return null;
    }
    if (thumbprint == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter thumbprint is required and cannot be null."));
        return null;
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    Validator.validate(certificateGetOptions, serviceCallback);
    String select = null;
    if (certificateGetOptions != null) {
        select = certificateGetOptions.select();
    }
    Integer timeout = null;
    if (certificateGetOptions != null) {
        timeout = certificateGetOptions.timeout();
    }
    String clientRequestId = null;
    if (certificateGetOptions != null) {
        clientRequestId = certificateGetOptions.clientRequestId();
    }
    Boolean returnClientRequestId = null;
    if (certificateGetOptions != null) {
        returnClientRequestId = certificateGetOptions.returnClientRequestId();
    }
    DateTime ocpDate = null;
    if (certificateGetOptions != null) {
        ocpDate = certificateGetOptions.ocpDate();
    }
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.get(thumbprintAlgorithm, thumbprint, this.client.apiVersion(), this.client.acceptLanguage(), select, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<Certificate>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(getDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) Certificate(com.microsoft.azure.batch.protocol.models.Certificate)

Example 9 with ServiceCall

use of com.microsoft.rest.ServiceCall in project azure-sdk-for-java by Azure.

the class CertificatesImpl method listAsync.

/**
     * Lists all of the certificates that have been added to the specified account.
     *
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall listAsync(final ListOperationCallback<Certificate> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    final CertificateListOptions certificateListOptions = null;
    String filter = null;
    String select = null;
    Integer maxResults = null;
    Integer timeout = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.list(this.client.apiVersion(), this.client.acceptLanguage(), filter, select, maxResults, timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<List<Certificate>>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                ServiceResponseWithHeaders<PageImpl<Certificate>, CertificateListHeaders> result = listDelegate(response);
                serviceCallback.load(result.getBody().getItems());
                if (result.getBody().getNextPageLink() != null && serviceCallback.progress(result.getBody().getItems()) == ListOperationCallback.PagingBahavior.CONTINUE) {
                    listNextAsync(result.getBody().getNextPageLink(), null, serviceCall, serviceCallback);
                } else {
                    serviceCallback.success(new ServiceResponseWithHeaders<>(serviceCallback.get(), result.getHeaders(), result.getResponse()));
                }
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) DateTime(org.joda.time.DateTime) ServiceResponseWithHeaders(com.microsoft.rest.ServiceResponseWithHeaders) ResponseBody(okhttp3.ResponseBody) CertificateListOptions(com.microsoft.azure.batch.protocol.models.CertificateListOptions) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123) PagedList(com.microsoft.azure.PagedList) List(java.util.List) Certificate(com.microsoft.azure.batch.protocol.models.Certificate)

Example 10 with ServiceCall

use of com.microsoft.rest.ServiceCall in project azure-sdk-for-java by Azure.

the class ComputeNodesImpl method enableSchedulingAsync.

/**
     * Enables task scheduling on the specified compute node.
     *
     * @param poolId The id of the pool that contains the compute node.
     * @param nodeId The id of the compute node on which you want to enable task scheduling.
     * @param serviceCallback the async ServiceCallback to handle successful and failed responses.
     * @throws IllegalArgumentException thrown if callback is null
     * @return the {@link Call} object
     */
public ServiceCall enableSchedulingAsync(String poolId, String nodeId, final ServiceCallback<Void> serviceCallback) throws IllegalArgumentException {
    if (serviceCallback == null) {
        throw new IllegalArgumentException("ServiceCallback is required for async calls.");
    }
    if (poolId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter poolId is required and cannot be null."));
        return null;
    }
    if (nodeId == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter nodeId is required and cannot be null."));
        return null;
    }
    if (this.client.apiVersion() == null) {
        serviceCallback.failure(new IllegalArgumentException("Parameter this.client.apiVersion() is required and cannot be null."));
        return null;
    }
    final ComputeNodeEnableSchedulingOptions computeNodeEnableSchedulingOptions = null;
    Integer timeout = null;
    String clientRequestId = null;
    Boolean returnClientRequestId = null;
    DateTime ocpDate = null;
    DateTimeRfc1123 ocpDateConverted = null;
    if (ocpDate != null) {
        ocpDateConverted = new DateTimeRfc1123(ocpDate);
    }
    Call<ResponseBody> call = service.enableScheduling(poolId, nodeId, this.client.apiVersion(), this.client.acceptLanguage(), timeout, clientRequestId, returnClientRequestId, ocpDateConverted, this.client.userAgent());
    final ServiceCall serviceCall = new ServiceCall(call);
    call.enqueue(new ServiceResponseCallback<Void>(serviceCallback) {

        @Override
        public void onResponse(Call<ResponseBody> call, Response<ResponseBody> response) {
            try {
                serviceCallback.success(enableSchedulingDelegate(response));
            } catch (BatchErrorException | IOException exception) {
                serviceCallback.failure(exception);
            }
        }
    });
    return serviceCall;
}
Also used : ServiceCall(com.microsoft.rest.ServiceCall) ComputeNodeEnableSchedulingOptions(com.microsoft.azure.batch.protocol.models.ComputeNodeEnableSchedulingOptions) DateTime(org.joda.time.DateTime) ResponseBody(okhttp3.ResponseBody) DateTimeRfc1123(com.microsoft.rest.DateTimeRfc1123)

Aggregations

DateTimeRfc1123 (com.microsoft.rest.DateTimeRfc1123)148 ServiceCall (com.microsoft.rest.ServiceCall)148 DateTime (org.joda.time.DateTime)148 ResponseBody (okhttp3.ResponseBody)140 PagedList (com.microsoft.azure.PagedList)26 ServiceResponseWithHeaders (com.microsoft.rest.ServiceResponseWithHeaders)26 List (java.util.List)26 CloudJob (com.microsoft.azure.batch.protocol.models.CloudJob)6 InputStream (java.io.InputStream)6 ApplicationSummary (com.microsoft.azure.batch.protocol.models.ApplicationSummary)4 Certificate (com.microsoft.azure.batch.protocol.models.Certificate)4 CloudJobSchedule (com.microsoft.azure.batch.protocol.models.CloudJobSchedule)4 CloudPool (com.microsoft.azure.batch.protocol.models.CloudPool)4 CloudTask (com.microsoft.azure.batch.protocol.models.CloudTask)4 ComputeNode (com.microsoft.azure.batch.protocol.models.ComputeNode)4 NodeFile (com.microsoft.azure.batch.protocol.models.NodeFile)3 AutoScaleRun (com.microsoft.azure.batch.protocol.models.AutoScaleRun)2 CloudTaskListSubtasksResult (com.microsoft.azure.batch.protocol.models.CloudTaskListSubtasksResult)2 ComputeNodeGetRemoteLoginSettingsResult (com.microsoft.azure.batch.protocol.models.ComputeNodeGetRemoteLoginSettingsResult)2 JobDisableParameter (com.microsoft.azure.batch.protocol.models.JobDisableParameter)2