Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CRUD backup pricings #288

Merged
merged 2 commits into from
May 3, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

public final class ApiVersion
{
public static final long V20190503 = 20190503;
public static final long V20181220 = 20181220;
public static final long V20181126 = 20181126;
public static final long V20181016 = 20181016;
Expand All @@ -13,7 +14,7 @@ public final class ApiVersion
public static final long V20180101 = 20180101;
public static final long NO_VERSION = 0;

public static final Long LATEST_API_VERSION = V20181220;
public static final Long LATEST_API_VERSION = V20190503;

private ApiVersion()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
package com.cloudesire.platform.apiclient.dto.model.dto;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import java.math.BigDecimal;

@ApiModel( description = "Defines pricing of a backup of a VM" )
public class BackupPricingDTO extends BaseEntityDTO
{
@NotNull
@Valid
private UrlEntityDTO cloudProvider;

@ApiModelProperty( "Chosen price" )
@NotNull
private BigDecimal price;

public BackupPricingDTO( @NotNull UrlEntityDTO cloudProvider, @NotNull BigDecimal price )
{
this.cloudProvider = cloudProvider;
this.price = price;
}

public BackupPricingDTO()
{
}

public UrlEntityDTO getCloudProvider()
{
return cloudProvider;
}

public void setCloudProvider( UrlEntityDTO cloudProvider )
{
this.cloudProvider = cloudProvider;
}

public BigDecimal getPrice()
{
return price;
}

public void setPrice( BigDecimal price )
{
this.price = price;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -419,6 +419,11 @@ public EnumApi getEnumApi()
return retrofit.create( EnumApi.class );
}

public BackupPricingApi getBackupPricingApi()
{
return retrofit.create( BackupPricingApi.class );
}

public BandwidthPricingApi getBandwidthPricingApi()
{
return retrofit.create( BandwidthPricingApi.class );
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
package com.cloudesire.platform.apiclient.api;

import com.cloudesire.platform.apiclient.dto.model.dto.BackupPricingDTO;
import retrofit2.Call;
import retrofit2.http.Body;
import retrofit2.http.DELETE;
import retrofit2.http.GET;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;

import java.util.List;

public interface BackupPricingApi
{
@POST( "backupPricing" )
Call<BackupPricingDTO> create( @Body BackupPricingDTO resource );

@GET( "backupPricing" )
Call<List<BackupPricingDTO>> getAll( @Query( "cloudProvider" ) int cloudProvider );

@GET( "backupPricing/{id}" )
Call<BackupPricingDTO> get( @Path( "id" ) int id );

@PUT( "backupPricing/{id}" )
Call<BackupPricingDTO> update( @Path( "id" ) int id, @Body BackupPricingDTO pricing );

@DELETE( "backupPricing/{id}" )
Call<Void> delete( @Path( "id" ) int id );
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public interface BandwidthPricingApi
@PUT( "bandwidthPricing/{id}" )
Call<BandwidthPricingDTO> update( @Path( "id" ) int id, @Body BandwidthPricingDTO resource );

@Deprecated
@PATCH( "bandwidthPricing/{id}" )
Call<Void> patch( @Path( "id" ) int id, @Body PricingPatchDTO input );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public interface DiskSpacePricingApi
@PUT( "diskSpacePricing/{id}" )
Call<DiskSpacePricingDTO> update( @Path( "id" ) int id, @Body DiskSpacePricingDTO pricing );

@Deprecated
@PATCH( "diskSpacePricing/{id}" )
Call<Void> patch( @Path( "id" ) int id, @Body PricingPatchDTO price );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import retrofit2.http.GET;
import retrofit2.http.PATCH;
import retrofit2.http.POST;
import retrofit2.http.PUT;
import retrofit2.http.Path;
import retrofit2.http.Query;

Expand Down Expand Up @@ -37,6 +38,10 @@ Call<List<InstancePricingDTO>> getCompatible(
@Query( "osType" ) OSType osType
);

@PUT( "instancePricing/{id}" )
Call<InstancePricingDTO> update( @Path( "id" ) int id, @Body InstancePricingDTO resource );

@Deprecated
@PATCH( "instancePricing/{id}" )
Call<Void> patch( @Path( "id" ) int id, @Body InstancePricingPatchDTO input );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@

public class CloudesireClientTest
{
private static final String USER_AGENT = "Cloudesire API Client 20181220";
private static final String USER_AGENT = "Cloudesire API Client 20190503";

private CloudesireClientCallExecutor executor;

@Before
Expand All @@ -37,7 +38,7 @@ public void userAgent() throws IOException
{
Httpbin api = getHttpbinApi();
HttpbinResponse response = api.get().execute().body();

assertThat( response ).isNotNull();
assertThat( response.getOrigin() ).isNotEmpty();
assertThat( response.getHeaders() ).containsKey( "User-Agent" );
assertThat( response.getHeaders().get( "User-Agent" ) ).isEqualTo( USER_AGENT );
Expand Down