Java Code Examples for com.google.api.server.spi.config.ApiMethod.HttpMethod#GET

The following examples show how to use com.google.api.server.spi.config.ApiMethod.HttpMethod#GET . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: BlobEndpoint.java    From solutions-mobile-backend-starter-java with Apache License 2.0 6 votes vote down vote up
/**
 * Gets a signed URL that can be used to upload a blob.
 *
 * @param bucketName Google Cloud Storage bucket to use for upload.
 * @param objectPath path to the object in the bucket.
 * @param accessMode controls how the uploaded blob can be accessed.
 * @param contentType the MIME type of the object of be uploaded. Can be null.
 * @param user the user making the request.
 * @throws UnauthorizedException if the user is not authorized.
 * @throws BadRequestException if the bucketName or objectPath are not valid.
 */
@ApiMethod(httpMethod = HttpMethod.GET, path = "blobs/uploads/{bucketName}/{objectPath}")
public BlobAccess getUploadUrl(@Named("bucketName") String bucketName,
    @Named("objectPath") String objectPath, @Named("accessMode") BlobAccessMode accessMode,
    @Nullable @Named("contentType") String contentType, User user)
    throws UnauthorizedException, BadRequestException {
  validateUser(user);

  validateBucketAndObjectPath(bucketName, objectPath);

  if (!reserveNameIfAvailable(bucketName, objectPath, accessMode, user)) {
    throw new UnauthorizedException("You don't have permissions to upload this object");
  }

  return getBlobUrlForUpload(
      bucketName, objectPath, accessMode, contentType != null ? contentType : "");
}
 
Example 2
Source File: Endpoint1.java    From endpoints-java with Apache License 2.0 6 votes vote down vote up
@ApiMethod(
    name = "foos.list",
    path = "foos",
    httpMethod = HttpMethod.GET,
    cacheControl = @ApiMethodCacheControl(
        noCache = true,
        maxAge = 1
    ),
    scopes = {"s0", "s1 s2"},
    audiences = {"a0", "a1"},
    clientIds = {"c0", "c1"},
    authenticators = { FailAuthenticator.class },
    peerAuthenticators = { FailPeerAuthenticator.class }
)
public List<Foo> listFoos() {
  return null;
}
 
Example 3
Source File: ConferenceApi.java    From ud859 with GNU General Public License v3.0 5 votes vote down vote up
@ApiMethod(
        name = "getAnnouncement",
        path = "announcement",
        httpMethod = HttpMethod.GET
)
public Announcement getAnnouncement() {
    MemcacheService memcacheService = MemcacheServiceFactory.getMemcacheService();
    Object message = memcacheService.get(Constants.MEMCACHE_ANNOUNCEMENTS_KEY);
    if (message != null) {
        return new Announcement(message.toString());
    }
    return null;
}
 
Example 4
Source File: ConferenceApi.java    From ud859 with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns a Profile object associated with the given user object. The cloud
 * endpoints system automatically inject the User object.
 *
 * @param user
 *            A User object injected by the cloud endpoints.
 * @return Profile object.
 * @throws UnauthorizedException
 *             when the User object is null.
 */
@ApiMethod(name = "getProfile", path = "profile", httpMethod = HttpMethod.GET)
public Profile getProfile(final User user) throws UnauthorizedException {
    if (user == null) {
        throw new UnauthorizedException("Authorization required");
    }

    // TODO
    // load the Profile Entity
    String userId = user.getUserId();
    Key key = Key.create(Profile.class, userId);

    Profile profile = (Profile) ofy().load().key(key).now();
    return profile;
}
 
Example 5
Source File: ConferenceApi.java    From ud859 with GNU General Public License v3.0 5 votes vote down vote up
@ApiMethod(
        name = "getAnnouncement",
        path = "announcement",
        httpMethod = HttpMethod.GET
)
public Announcement getAnnouncement() {
    MemcacheService memcacheService = MemcacheServiceFactory.getMemcacheService();
    Object message = memcacheService.get(Constants.MEMCACHE_ANNOUNCEMENTS_KEY);
    if (message != null) {
        return new Announcement(message.toString());
    }
    return null;
}
 
Example 6
Source File: BlobEndpoint.java    From io2014-codelabs with Apache License 2.0 5 votes vote down vote up
/**
 * Gets a signed URL that can be used to download a blob.
 *
 * @param bucketName Google Cloud Storage bucket where the object was uploaded.
 * @param objectPath path to the object in the bucket.
 * @param user       the user making the request.
 * @throws com.google.api.server.spi.response.UnauthorizedException if the user is not authorized.
 * @throws com.google.api.server.spi.response.BadRequestException   if the bucketName or objectPath are not valid.
 * @throws com.google.api.server.spi.response.NotFoundException     if the object doesn't exist.
 */
@ApiMethod(httpMethod = HttpMethod.GET, path = "blobs/downloads/{bucketName}/{objectPath}")
public BlobAccess getDownloadUrl(
  @Named("bucketName") String bucketName, @Named("objectPath") String objectPath, User user)
  throws UnauthorizedException, BadRequestException, NotFoundException {
  validateUser(user);

  validateBucketAndObjectPath(bucketName, objectPath);

  checkReadObjectPermissions(bucketName, objectPath, user);

  return getBlobUrlForDownload(bucketName, objectPath);
}
 
Example 7
Source File: Endpoint1.java    From endpoints-java with Apache License 2.0 5 votes vote down vote up
@ApiMethod(
    name = "foos.get",
    path = "foos/{id}",
    httpMethod = HttpMethod.GET,
    cacheControl = @ApiMethodCacheControl(
        noCache = false,
        maxAge = 2
    )
)
public Foo getFoo(@Named("id") String id) {
  return null;
}
 
Example 8
Source File: DuplicateMethodEndpoint.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(name = "api.foos.fn1", path = "fn1", httpMethod = HttpMethod.GET)
public Foo foo(@Named("id") String id) {
  return null;
}
 
Example 9
Source File: TestEndpoint.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(httpMethod = HttpMethod.GET, path = "test")
public StringValue test() throws Exception {
  return new StringValue("x");
}
 
Example 10
Source File: TestEndpoint.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(httpMethod = HttpMethod.GET, path = "collidingpath/{id}")
public StringValue getCollidingPath(@Named("id") String id) {
  return new StringValue(id);
}
 
Example 11
Source File: RestServletRequestParamReaderTest.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(
    name = "testArrayPathParam",
    httpMethod = HttpMethod.GET,
    path = "testArrayPathParam/{values}")
public void testArrayPathParam(@Named("values") ArrayList<String> values) {
}
 
Example 12
Source File: AdSearchEndpoints.java    From AdSearch_Endpoints with Apache License 2.0 4 votes vote down vote up
@ApiMethod(name = "showIndex", path = "showIndex",
        httpMethod = HttpMethod.GET)
public Map<String, List<Long>> showIndex() {
    return ADS_INDEX.ShowInvertedIndex();
}
 
Example 13
Source File: SimpleOverrideEndpoint.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(name = "api.foos.base", path = "base", httpMethod = HttpMethod.GET)
public Object foo(@Named("id") String id) {
  return null;
}
 
Example 14
Source File: SimpleContravarianceEndpoint.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(name = "api.foos.fn", path = "fn", httpMethod = HttpMethod.GET)
public Foo foo(Object id) {
  return null;
}
 
Example 15
Source File: SimpleContravarianceEndpoint.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(name = "api.foos.base", path = "base", httpMethod = HttpMethod.GET)
public Foo foo(Number id) {
  return null;
}
 
Example 16
Source File: CollectionCovarianceEndpoint.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(name = "api.foos.fn", path = "fn", httpMethod = HttpMethod.GET)
public Foo foo(@Named("id") List<Integer> id) {
  return null;
}
 
Example 17
Source File: HelloWorldEndpoints.java    From ud859 with GNU General Public License v3.0 4 votes vote down vote up
@ApiMethod(name = "sayHello", path = "sayHello",
        httpMethod = HttpMethod.GET)

public HelloClass sayHello() {
    return new HelloClass();
}
 
Example 18
Source File: SimpleOverloadEndpoint.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(name = "api.foos.base", path = "base", httpMethod = HttpMethod.GET)
public Foo foo(@Named("id") String id) {
  return null;
}
 
Example 19
Source File: NonDiscoverableEndpoint.java    From endpoints-java with Apache License 2.0 4 votes vote down vote up
@ApiMethod(name = "foo.get", description = "get desc", path = "foos/{id}",
    httpMethod = HttpMethod.GET)
public Foo getFoo(@Named("id") @Description("id desc") String id) {
  return null;
}
 
Example 20
Source File: EndpointV1.java    From io2014-codelabs with Apache License 2.0 3 votes vote down vote up
/**
 * Finds the CloudEntity specified by its Id.
 *
 * @param kindName
 *          Name of the kind for the CloudEntity to get.
 * @param id
 *          Id of the CloudEntity to find.
 * @return {@link com.google.cloud.backend.beans.EntityDto} of the found CloudEntity.
 * @throws com.google.api.server.spi.response.UnauthorizedException
 *           if the requesting {@link com.google.appengine.api.users.User} has no sufficient permission for
 *           the operation.
 * @throws com.google.api.server.spi.response.NotFoundException
 *           if the requested CloudEntity has not found
 */
@ApiMethod(path = "CloudEntities/{kind}/{id}", httpMethod = HttpMethod.GET)
public EntityDto get(@Named("kind") String kindName, @Named("id") String id, User user)
    throws UnauthorizedException, NotFoundException {

  SecurityChecker.getInstance().checkIfUserIsAvailable(user);
  return CrudOperations.getInstance().getEntity(kindName, id, user);
}