use of com.arm.mbed.cloud.sdk.certificates.model.CertificateListOptions in project mbed-cloud-sdk-java by ARMmbed.
the class Certificates method listCertificates.
/**
* Lists all certificates according to filter options.
* <p>
* Note: This method returns only partially complete certificate objects.
* <p>
* In order to see the full information about a particular certificate, use {@link #getCertificate(String)} instead.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* CertificateListOptions options = new CertificateListOptions();
* String ownerId = "015f4ac587f500000000000100100249";
* options.setOwnerIdFilter(ownerId);
* options.setTypeFilter(CertificateType.DEVELOPER);
*
* ListResponse<Certificate> certificates = certificateApi.listCertificates(options);
* for (Certificate certificate : certificates) {
* System.out.println("Certificate name: " + certificate.getName());
* System.out.println("Certificate server URI: " + certificate.getServerUri());
* }
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param options
* filter options.
* @return The list of certificates corresponding to filter options (One page).
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public ListResponse<Certificate> listCertificates(@Nullable CertificateListOptions options) throws MbedCloudException {
final CertificateListOptions finalOptions = (options == null) ? new CertificateListOptions() : options;
final String serviceEq = finalOptions.getTypeFilter() == CertificateType.DEVELOPER ? CertificateType.BOOTSTRAP.toString() : finalOptions.encodeSingleEqualFilter(CertificateListOptions.TYPE_FILTER);
return CloudCaller.call(this, "listCertificates()", CertificateAdapter.getListMapper(), new CloudCall<TrustedCertificateRespList>() {
@Override
public Call<TrustedCertificateRespList> call() {
return endpoint.getAccountDeveloper().getAllCertificates(finalOptions.getLimit(), finalOptions.getAfter(), finalOptions.getOrder().toString(), finalOptions.encodeInclude(), finalOptions.encodeSingleEqualFilter(CertificateListOptions.NAME_FILTER), serviceEq, TranslationUtils.convertToInteger(finalOptions.encodeSingleEqualFilter(CertificateListOptions.EXPIRES_FILTER), null), finalOptions.getExecutionModeFilter(), finalOptions.getExecutionModeNotEqualFilter(), finalOptions.encodeSingleEqualFilter(CertificateListOptions.OWNER_ID_FILTER), finalOptions.getEnrollmentFilter(), finalOptions.encodeSingleLikeFilter(CertificateListOptions.ISSUER_FILTER), finalOptions.encodeSingleLikeFilter(CertificateListOptions.SUBJECT_FILTER));
}
});
}
use of com.arm.mbed.cloud.sdk.certificates.model.CertificateListOptions in project mbed-cloud-sdk-java by ARMmbed.
the class CertificatesExamples method listCertificates.
/**
* Lists the first 5 certificates.
*/
@SuppressWarnings("boxing")
@Example
public void listCertificates() {
ConnectionOptions config = Configuration.get();
Certificates api = new Certificates(config);
try {
// Defining query options.
CertificateListOptions options = new CertificateListOptions();
options.setLimit(5);
// Listing certificates.
Paginator<Certificate> certificates = api.listAllCertificates(options);
for (Certificate certificate : certificates) {
log("Certificate", certificate);
}
} catch (Exception e) {
logError("last API Metadata", api.getLastApiMetadata());
fail(e.getMessage());
}
}
use of com.arm.mbed.cloud.sdk.certificates.model.CertificateListOptions in project mbed-cloud-sdk-java by ARMmbed.
the class TestAllListOptions method testCertificateListOptionsClone.
@Test
public void testCertificateListOptionsClone() {
CertificateListOptions opt1 = new CertificateListOptions();
opt1.addEqualFilter("field1", Integer.valueOf(3));
opt1.includeTotalCount();
opt1.setLimit(Integer.valueOf(2));
CertificateListOptions opt2 = new CertificateListOptions();
assertNotEquals(opt2, opt1);
assertNotSame(opt2, opt1);
opt2 = opt1.clone();
assertEquals(opt2, opt1);
assertNotSame(opt2, opt1);
}
Aggregations