use of com.arm.mbed.cloud.sdk.internal.updateservice.model.UpdateCampaign in project mbed-cloud-sdk-java by ARMmbed.
the class Update method modifyCampaign.
/**
* Modifies an update campaign.
*
* @param campaign
* campaign to modify.
* @param actionName
* name of the modification action.
* @return modified campaign.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@Internal
private Campaign modifyCampaign(Campaign campaign, String actionName) throws MbedCloudException {
checkNotNull(campaign, TAG_CAMPAIGN);
checkNotNull(campaign.getId(), TAG_CAMPAIGN_ID);
checkModelValidity(campaign, TAG_CAMPAIGN);
final Campaign finalCampaign = campaign;
return CloudCaller.call(this, actionName, CampaignAdapter.getMapper(), new CloudCall<UpdateCampaign>() {
@Override
public Call<UpdateCampaign> call() {
return endpoint.getUpdate().updateCampaignUpdate(finalCampaign.getId(), CampaignAdapter.reverseMapUpdate(finalCampaign));
}
});
}
use of com.arm.mbed.cloud.sdk.internal.updateservice.model.UpdateCampaign in project mbed-cloud-sdk-java by ARMmbed.
the class Update method addCampaign.
/**
* Adds an update campaign.
* <p>
* Example:
*
* <pre>
* {@code
* try {
* Campaign campaign = new Campaign();
* campaign.setName("QuickstartCampaign");
* campaign.setDescription("Quick start campaign");
* campaign.setState(CampaignState.DRAFT);
*
* Filters deviceFilter = new Filters();
* deviceFilter.add(new Filter("state", FilterOperator.EQUAL, "registered"));
* campaign.setDeviceFilter(deviceFilter);
*
* String firmwareManifestId = "015f4ac587f500000000000100100249";
* campaign.setManifestId(firmwareManifestId);
*
* Campaign newCampaign = updateApi.addCampaign(campaign);
* System.out.println("Campaign state: " + newCampaign.getState());
* System.out.println("Campaign ID: " + newCampaign.getId());
*
* } catch (MbedCloudException e) {
* e.printStackTrace();
* }
* }
* </pre>
*
* @param campaign
* The campaign to add.
* @return added update campaign.
* @throws MbedCloudException
* if a problem occurred during request processing.
*/
@API
@Nullable
public Campaign addCampaign(@NonNull Campaign campaign) throws MbedCloudException {
checkNotNull(campaign, TAG_CAMPAIGN);
checkModelValidity(campaign, TAG_CAMPAIGN);
final Campaign finalCampaign = campaign;
return CloudCaller.call(this, "addCampaign()", CampaignAdapter.getMapper(), new CloudCall<UpdateCampaign>() {
@Override
public Call<UpdateCampaign> call() {
return endpoint.getUpdate().updateCampaignCreate(CampaignAdapter.reverseMapAdd(finalCampaign));
}
});
}
use of com.arm.mbed.cloud.sdk.internal.updateservice.model.UpdateCampaign in project mbed-cloud-sdk-java by ARMmbed.
the class CampaignAdapter method map.
/**
* Maps campaign.
*
* @param campaign
* campaign result
* @return campaign
*/
public static Campaign map(UpdateCampaign campaign) {
if (campaign == null) {
return null;
}
final Campaign updateCampaign = new Campaign(campaign.getId(), TranslationUtils.toUrl(campaign.getRootManifestUrl()), TranslationUtils.toDate(campaign.getCreatedAt()), TranslationUtils.toDate(campaign.getStartedAt()), TranslationUtils.toDate(campaign.getFinished()), TranslationUtils.toDate(campaign.getUpdatedAt()));
updateCampaign.setDescription(campaign.getDescription());
updateCampaign.setManifestId(campaign.getRootManifestId());
updateCampaign.setName(campaign.getName());
updateCampaign.setScheduledAt(TranslationUtils.toDate(campaign.getWhen()));
updateCampaign.setState(toState(campaign.getState()));
updateCampaign.setDeviceFilters(decodeFilters(campaign.getDeviceFilter()));
return updateCampaign;
}
use of com.arm.mbed.cloud.sdk.internal.updateservice.model.UpdateCampaign in project mbed-cloud-sdk-java by ARMmbed.
the class CampaignAdapter method mapList.
/**
* Maps a list of campaigns.
*
* @param list
* campaign page.
* @return a list of campaigns
*/
public static ListResponse<Campaign> mapList(UpdateCampaignPage list) {
final UpdateCampaignPage campaignList = list;
final RespList<UpdateCampaign> respList = new RespList<UpdateCampaign>() {
@Override
public Boolean getHasMore() {
return (campaignList == null) ? null : campaignList.isHasMore();
}
@Override
public Integer getTotalCount() {
return (campaignList == null) ? null : campaignList.getTotalCount();
}
@Override
public String getAfter() {
return (campaignList == null) ? null : campaignList.getAfter();
}
@Override
public Integer getLimit() {
return (campaignList == null) ? null : campaignList.getLimit();
}
@Override
public String getOrder() {
return (campaignList == null) ? null : campaignList.getOrder().toString();
}
@Override
public List<UpdateCampaign> getData() {
return (campaignList == null) ? null : campaignList.getData();
}
};
return GenericAdapter.mapList(respList, getMapper());
}
Aggregations