Skip to content

Commit

Permalink
CLDIDE-2433 Moved subscription API to hosted-infrastructure project
Browse files Browse the repository at this point in the history
  • Loading branch information
Sergey Leschenko committed Jun 12, 2015
1 parent a93e65c commit b6a515b
Show file tree
Hide file tree
Showing 23 changed files with 68 additions and 2,786 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

import org.eclipse.che.api.account.shared.dto.AccountDescriptor;
import org.eclipse.che.api.account.shared.dto.MemberDescriptor;
import org.eclipse.che.api.account.shared.dto.SubscriptionDescriptor;
import org.eclipse.che.api.account.shared.dto.UpdateResourcesDescriptor;
import org.eclipse.che.ide.collections.Array;
import org.eclipse.che.ide.rest.AsyncRequestCallback;
Expand Down Expand Up @@ -44,30 +43,6 @@ public interface AccountServiceClient {
*/
void getMemberships(AsyncRequestCallback<Array<MemberDescriptor>> callback);

/**
* Get subscriptions of specified account.
*
* @param accountId
* id of account
* @param callback
* the callback to use for the response
*/
void getSubscriptions(@Nonnull String accountId, AsyncRequestCallback<Array<SubscriptionDescriptor>> callback);

/**
* Get subscription with specified id of specified account.
*
* @param accountId
* id of account
* @param serviceId
* id of service
* @param callback
* the callback to use for the response
*/
void getSubscriptionByServiceId(@Nonnull String accountId,
@Nonnull String serviceId,
AsyncRequestCallback<Array<SubscriptionDescriptor>> callback);

void redistributeResources(@Nonnull String accountId,
@Nonnull Array<UpdateResourcesDescriptor> updateResources,
AsyncRequestCallback<Void> callback);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,19 @@
*******************************************************************************/
package org.eclipse.che.api.account.gwt.client;

import com.google.inject.Inject;
import com.google.inject.Singleton;

import org.eclipse.che.api.account.shared.dto.AccountDescriptor;
import org.eclipse.che.api.account.shared.dto.MemberDescriptor;
import org.eclipse.che.api.account.shared.dto.SubscriptionDescriptor;
import org.eclipse.che.api.account.shared.dto.UpdateResourcesDescriptor;
import org.eclipse.che.ide.MimeType;
import org.eclipse.che.ide.collections.Array;
import org.eclipse.che.ide.rest.AsyncRequestCallback;
import org.eclipse.che.ide.rest.AsyncRequestFactory;
import org.eclipse.che.ide.rest.HTTPHeader;
import com.google.inject.Inject;
import com.google.inject.Singleton;

import javax.annotation.Nonnull;
import java.util.ArrayList;
import java.util.List;

/**
* Implementation of {@link AccountServiceClient} service.
Expand All @@ -40,31 +38,13 @@ public AccountServiceClientImpl(AsyncRequestFactory asyncRequestFactory) {
this.asyncRequestFactory = asyncRequestFactory;
}

/** {@inheritDoc} */
@Override
public void getSubscriptions(@Nonnull String accountId, AsyncRequestCallback<Array<SubscriptionDescriptor>> callback) {
final String requestUrl = "/api/account/" + accountId + "/subscriptions";
asyncRequestFactory.createGetRequest(requestUrl)
.header(HTTPHeader.ACCEPT, MimeType.APPLICATION_JSON)
.send(callback);
}

@Override
public void getSubscriptionByServiceId(@Nonnull String accountId,
@Nonnull String serviceId,
AsyncRequestCallback<Array<SubscriptionDescriptor>> callback) {
final String requestUrl = "/api/account/" + accountId + "/subscriptions?service=" + serviceId;
asyncRequestFactory.createGetRequest(requestUrl)
.header(HTTPHeader.ACCEPT, MimeType.APPLICATION_JSON)
.send(callback);
}

@Override
public void redistributeResources(@Nonnull String accountId, @Nonnull Array<UpdateResourcesDescriptor> updateResources, AsyncRequestCallback<Void> callback) {
public void redistributeResources(@Nonnull String accountId, @Nonnull Array<UpdateResourcesDescriptor> updateResources,
AsyncRequestCallback<Void> callback) {
final String requestUrl = "/api/account/" + accountId + "/resources";
asyncRequestFactory.createPostRequest(requestUrl, updateResources)
.header(HTTPHeader.CONTENT_TYPE, MimeType.APPLICATION_JSON)
.send(callback);
.header(HTTPHeader.CONTENT_TYPE, MimeType.APPLICATION_JSON)
.send(callback);
}

/** {@inheritDoc} */
Expand Down

0 comments on commit b6a515b

Please sign in to comment.