Search in sources :

Example 1 with EnrollmentIdentity

use of com.arm.mbed.cloud.sdk.internal.enrollment.model.EnrollmentIdentity in project mbed-cloud-sdk-java by ARMmbed.

the class EnrollmentAdapter method mapList.

/**
 * Maps a list of enrollment identities.
 *
 * @param list
 *            enrollment identities (page).
 * @return a list of enrollment identities
 */
public static ListResponse<EnrollmentClaim> mapList(EnrollmentIdentities list) {
    final EnrollmentIdentities enrollmentList = list;
    final RespList<EnrollmentIdentity> respList = new RespList<EnrollmentIdentity>() {

        @Override
        public Boolean getHasMore() {
            return (enrollmentList == null) ? null : enrollmentList.isHasMore();
        }

        @Override
        public Integer getTotalCount() {
            return (enrollmentList == null) ? null : enrollmentList.getTotalCount();
        }

        @Override
        public String getAfter() {
            return (enrollmentList == null) ? null : enrollmentList.getAfter();
        }

        @Override
        public Integer getLimit() {
            return (enrollmentList == null) ? null : enrollmentList.getLimit();
        }

        @Override
        public String getOrder() {
            return (enrollmentList == null) ? null : enrollmentList.getOrder().toString();
        }

        @Override
        public List<EnrollmentIdentity> getData() {
            return (enrollmentList == null) ? null : enrollmentList.getData();
        }
    };
    return GenericAdapter.mapList(respList, getMapper());
}
Also used : EnrollmentIdentity(com.arm.mbed.cloud.sdk.internal.enrollment.model.EnrollmentIdentity) EnrollmentIdentities(com.arm.mbed.cloud.sdk.internal.enrollment.model.EnrollmentIdentities) RespList(com.arm.mbed.cloud.sdk.common.GenericAdapter.RespList)

Example 2 with EnrollmentIdentity

use of com.arm.mbed.cloud.sdk.internal.enrollment.model.EnrollmentIdentity in project mbed-cloud-sdk-java by ARMmbed.

the class Enrollment method addEnrollmentClaim.

/**
 * Places an enrolment claim for one or several devices.
 * <p>
 * Example:
 *
 * <pre>
 * {@code
 * try {
 *     String claimId = "A-35:e7:72:8a:07:50:3b:3d:75:96:57:52:72:41:0d:78:cc:c6:e5:53:48:c6:65:58:5b:fa:af:4d:2d:73:95:c5";
 *     EnrollmentClaim claim = enrollmentApi.addEnrollmentClaim(claimId)
 *     System.out.println(claim);
 *
 * } catch (MbedCloudException e) {
 *     e.printStackTrace();
 * }
 * }
 * </pre>
 *
 * @param claimId
 *            Claim Id. Pattern: '^[A-Z]{1}-[A-Za-z0-9:]{1, 256}' e.g.
 *            A-35:e7:72:8a:07:50:3b:3d:75:96:57:52:72:41:0d:78:cc:c6:e5:53:48:c6:65:58:5b:fa:af:4d:2d:73:95:c5
 * @return enrollment claim.
 * @throws MbedCloudException
 *             if a problem occurred during request processing.
 */
@API
@Nullable
public EnrollmentClaim addEnrollmentClaim(@NonNull String claimId) throws MbedCloudException {
    checkNotNull(claimId, TAG_ENROLLMENT_ID);
    final EnrollmentId finalEnrollmentId = new EnrollmentId().enrollmentIdentity(claimId);
    return CloudCaller.call(this, "addEnrollmentClaim()", EnrollmentAdapter.getMapper(), new CloudCall<EnrollmentIdentity>() {

        @Override
        public Call<EnrollmentIdentity> call() {
            return endpoint.getEnrollment().createDeviceEnrollment(finalEnrollmentId);
        }
    });
}
Also used : CloudCall(com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall) Call(retrofit2.Call) EnrollmentIdentity(com.arm.mbed.cloud.sdk.internal.enrollment.model.EnrollmentIdentity) EnrollmentId(com.arm.mbed.cloud.sdk.internal.enrollment.model.EnrollmentId) API(com.arm.mbed.cloud.sdk.annotations.API) Nullable(com.arm.mbed.cloud.sdk.annotations.Nullable)

Aggregations

EnrollmentIdentity (com.arm.mbed.cloud.sdk.internal.enrollment.model.EnrollmentIdentity)2 API (com.arm.mbed.cloud.sdk.annotations.API)1 Nullable (com.arm.mbed.cloud.sdk.annotations.Nullable)1 CloudCall (com.arm.mbed.cloud.sdk.common.CloudCaller.CloudCall)1 RespList (com.arm.mbed.cloud.sdk.common.GenericAdapter.RespList)1 EnrollmentId (com.arm.mbed.cloud.sdk.internal.enrollment.model.EnrollmentId)1 EnrollmentIdentities (com.arm.mbed.cloud.sdk.internal.enrollment.model.EnrollmentIdentities)1 Call (retrofit2.Call)1