本文整理汇总了Java中com.google.api.server.spi.config.ApiMethod.HttpMethod类的典型用法代码示例。如果您正苦于以下问题:Java HttpMethod类的具体用法?Java HttpMethod怎么用?Java HttpMethod使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
HttpMethod类属于com.google.api.server.spi.config.ApiMethod包,在下文中一共展示了HttpMethod类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: listFoos
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
@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;
}
示例2: testEndpointWithOnlyDefaultConfiguration
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
@Test
public void testEndpointWithOnlyDefaultConfiguration() throws Exception {
String apiConfigSource = g.generateConfig(Endpoint0.class).get("myapi-v1.api");
JsonNode root = objectMapper.readValue(apiConfigSource, JsonNode.class);
verifyApi(root, "thirdParty.api", "https://myapp.appspot.com/_ah/api",
"myapi", "v1", "", "https://myapp.appspot.com/_ah/spi", false, true);
JsonNode methodGetFoo = root.path("methods").path("myapi.endpoint0.getFoo");
verifyMethod(methodGetFoo, "foo/{id}", HttpMethod.GET, Endpoint0.class.getName() + ".getFoo",
"autoTemplate(backendResponse)");
verifyMethodRequest(methodGetFoo.path("request"), "empty", 1);
verifyMethodRequestParameter(methodGetFoo.path("request"), "id", "string", true, false);
verifyEndpoint0Schema(root, Endpoint0.class.getName());
}
示例3: createSession
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
/**
* Creates a new session from {@link WaxNewSessionRequest}.
*
* @return {@link WaxNewSessionResponse} with the created session id
* @throws InternalServerErrorException if the session creation failed
* @throws BadRequestException if the requested session name is bad
*/
@ApiMethod(
name = "sessions.create",
path = "newsession",
httpMethod = HttpMethod.POST)
public WaxNewSessionResponse createSession(WaxNewSessionRequest request)
throws InternalServerErrorException, BadRequestException {
if (Strings.isNullOrEmpty(request.getSessionName())) {
throw new BadRequestException("Name must be non-empty");
}
String sessionId =
store.createSession(request.getSessionName(), request.getDurationInMillis());
if (sessionId != null) {
return new WaxNewSessionResponse(sessionId);
}
throw new InternalServerErrorException("Error while adding session");
}
示例4: testParamsPath
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
@ApiMethod(httpMethod = HttpMethod.GET, path = "testparamspath/{anint}/{along}/{afloat}/{adouble}"
+ "/{aboolean}/{astring}/{asimpledate}/{adateandtime}/{adate}/{anenum}")
public FieldContainer testParamsPath(
@Named("anint") int anInt,
@Named("along") long aLong,
@Named("afloat") float aFloat,
@Named("adouble") double aDouble,
@Named("aboolean") boolean aBoolean,
@Named("astring") String aString,
@Named("asimpledate") SimpleDate aSimpleDate,
@Named("adateandtime") DateAndTime aDateAndTime,
@Named("adate") Date aDate,
@Named("anenum") TestEnum anEnum) {
FieldContainer ret = new FieldContainer();
ret.anInt = anInt;
ret.aLong = aLong;
ret.aFloat = aFloat;
ret.aDouble = aDouble;
ret.aBoolean = aBoolean;
ret.aString = aString;
ret.aSimpleDate = aSimpleDate;
ret.aDateAndTime = aDateAndTime;
ret.aDate = aDate;
ret.anEnum = anEnum;
return ret;
}
示例5: testParamsQuery
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
@ApiMethod(httpMethod = HttpMethod.GET, path = "testparamsquery")
public FieldContainer testParamsQuery(
@Named("anint") Integer anInt,
@Named("along") Long aLong,
@Named("afloat") Float aFloat,
@Named("adouble") Double aDouble,
@Named("aboolean") Boolean aBoolean,
@Named("astring") String aString,
@Named("asimpledate") SimpleDate aSimpleDate,
@Named("adateandtime") DateAndTime aDateAndTime,
@Named("adate") Date aDate,
@Named("anenum") TestEnum anEnum) {
FieldContainer ret = new FieldContainer();
ret.anInt = anInt;
ret.aLong = aLong;
ret.aFloat = aFloat;
ret.aDouble = aDouble;
ret.aBoolean = aBoolean;
ret.aString = aString;
ret.aSimpleDate = aSimpleDate;
ret.aDateAndTime = aDateAndTime;
ret.aDate = aDate;
ret.anEnum = anEnum;
return ret;
}
示例6: getTokens
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
@ApiMethod(name = "getTokens", path = "getTokens",
httpMethod = HttpMethod.GET)
public List<String> getTokens(@Named("name") String queryString) {
// add Ads data
AdsData ads1 = new AdsData((long) 1231, (long) 66, "basketball kobe shoe nike", 0.37f, 6.0f);
ofy().save().entity(ads1).now();
AdsData ads2 = new AdsData((long) 1232, (long) 66, "soccer shoe nike", 0.23f, 4.0f);
ofy().save().entity(ads2).now();
AdsData ads3 = new AdsData((long) 1233, (long) 67, "running shoe adidas", 0.53f, 7.5f);
ofy().save().entity(ads3).now();
AdsData ads4 = new AdsData((long) 1234, (long) 67, "soccer shoe adidas", 0.19f, 3.5f);
ofy().save().entity(ads4).now();
AdsData ads5 = new AdsData((long) 1235, (long) 67, "basketball shoe adidas", 0.29f, 5.5f);
ofy().save().entity(ads5).now();
// add Campaign data
CampaignData cmp1 = new CampaignData((long) 66, 1500f);
ofy().save().entity(cmp1).now();
CampaignData cmp2 = new CampaignData((long) 67, 2800f);
ofy().save().entity(cmp2).now();
CampaignData cmp3 = new CampaignData((long) 68, 900f);
ofy().save().entity(cmp3).now();
return QUERY_PARSER.parseQuery(queryString);
}
示例7: registerGtfsTask
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
/**
* Register the gtfs creation task.
*
* @author Rodrigo Cabrera ([email protected])
* @param password a simple password to avoid excess of petitions
* @param trailIds the trail ids to be added to the GTFS
* @throws IOException
* @throws UnsupportedEncodingException
* @since 19 / feb / 2016
*/
@ApiMethod(name = "registerGtfsTask", path = "registerGtfsTask", httpMethod = HttpMethod.POST)
public void registerGtfsTask(@Named("password") String password, @Named("trailIds") String trailIds) throws TrailNotFoundException, UnsupportedEncodingException, IOException{
logger.debug("registering gtfs task");
FileInputStream inputStream = new FileInputStream(new File("WEB-INF/config.txt"));
String passConfig = CharStreams.toString(new InputStreamReader(inputStream, "UTF-8"));
if(password.equals(passConfig)){
HashMap<String, String> params = new HashMap<>();
params.put(GtfsGenerationTask.Params.trailIds.name(), trailIds);
new GtfsGenerationTask().enqueue(params);
}
logger.debug("registration finished");
}
示例8: registerGtfsFullTask
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
/**
* Register the gtfs creation task of all valid trails
*
* @author Rodrigo Cabrera ([email protected])
* @param password a simple password to avoid excess of petitions
* @throws IOException
* @throws UnsupportedEncodingException
* @since 26 / feb / 2016
*/
@ApiMethod(name = "registerGtfsFullTask", path = "registerGtfsFullTask", httpMethod = HttpMethod.POST)
public void registerGtfsFullTask(@Named("password") String password) throws TrailNotFoundException, UnsupportedEncodingException, IOException{
logger.debug("registering gtfs task");
FileInputStream inputStream = new FileInputStream(new File("WEB-INF/config.txt"));
String passConfig = CharStreams.toString(new InputStreamReader(inputStream, "UTF-8"));
if(password.equals(passConfig)){
ArrayList<Long> ids = new TrailsHandler().getAllValidGtfsTrailsIds();
HashMap<String, String> params = new HashMap<>();
String trailIds = Arrays.toString(ids.toArray()).replace("[", "").replace("]", "").replace(" ", "");
params.put(GtfsGenerationTask.Params.trailIds.name(), trailIds);
new GtfsGenerationTask().enqueue(params);
}
logger.debug("registration finished");
}
示例9: register
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
/**
* Register a user's device. Each client instance has a token that identifies it, there is usually
* one instance per device so in most cases the token represents a device. The token is stored
* against the user's ID to allow messages to be sent to all the user's devices.
*
* @param user Current user (injected by Endpoints)
* @param deviceId FCM token representing the device.
* @throws BadRequestException Thrown when there is no device ID in the request.
*/
@ApiMethod(path = "register", httpMethod = HttpMethod.POST)
public void register(User user, @Named(PARAMETER_DEVICE_ID) String deviceId)
throws BadRequestException {
// Check to see if deviceId.
if (Strings.isNullOrEmpty(deviceId)) {
// Drop request.
throw new BadRequestException("Invalid request: Request must contain " +
PARAMETER_DEVICE_ID);
}
// Check that user making requests is non null.
if (user != null && !Strings.isNullOrEmpty(user.getId())) {
DeviceStore.register(deviceId, user.getId());
} else {
// If user is null still register device so it can still get session update ping.
DeviceStore.register(deviceId, null);
}
}
示例10: queryConferences
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
/**
* Queries against the datastore with the given filters and returns the result.
*
* Normally this kind of method is supposed to get invoked by a GET HTTP method,
* but we do it with POST, in order to receive conferenceQueryForm Object via the POST body.
*
* @param conferenceQueryForm A form object representing the query.
* @return A List of Conferences that match the query.
*/
@ApiMethod(
name = "queryConferences",
path = "queryConferences",
httpMethod = HttpMethod.POST
)
public List<Conference> queryConferences(ConferenceQueryForm conferenceQueryForm) {
Iterable<Conference> conferenceIterable = conferenceQueryForm.getQuery();
List<Conference> result = new ArrayList<>(0);
List<Key<Profile>> organizersKeyList = new ArrayList<>(0);
for (Conference conference : conferenceIterable) {
organizersKeyList.add(Key.create(Profile.class, conference.getOrganizerUserId()));
result.add(conference);
}
// To avoid separate datastore gets for each Conference, pre-fetch the Profiles.
ofy().load().keys(organizersKeyList);
return result;
}
示例11: getConferencesCreated
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
/**
* Returns a list of Conferences that the user created.
* In order to receive the websafeConferenceKey via the JSON params, uses a POST method.
*
* @param user A user who invokes this method, null when the user is not signed in.
* @return a list of Conferences that the user created.
* @throws UnauthorizedException when the user is not signed in.
*/
@ApiMethod(
name = "getConferencesCreated",
path = "getConferencesCreated",
httpMethod = HttpMethod.POST
)
public List<Conference> getConferencesCreated(final User user) throws UnauthorizedException {
// If not signed in, throw a 401 error.
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
String userId = user.getUserId();
Key<Profile> userKey = Key.create(Profile.class, userId);
return ofy().load().type(Conference.class)
.ancestor(userKey)
.order("name").list();
}
示例12: getConferencesCreated
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
/**
* Returns a list of Conferences that the user created.
* In order to receive the websafeConferenceKey via the JSON params, uses a POST method.
*
* @param user An user who invokes this method, null when the user is not signed in.
* @return a list of Conferences that the user created.
* @throws UnauthorizedException when the user is not signed in.
*/
@ApiMethod(
name = "getConferencesCreated",
path = "getConferencesCreated",
httpMethod = HttpMethod.POST
)
public List<Conference> getConferencesCreated(final User user) throws UnauthorizedException {
// If not signed in, throw a 401 error.
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
String userId = getUserId(user);
return ofy().load().type(Conference.class)
.ancestor(Key.create(Profile.class, userId))
.order("name").list();
}
示例13: getConference
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
/**
* Returns a Conference object with the given conferenceId.
*
* @param websafeConferenceKey The String representation of the Conference Key.
* @return a Conference object with the given conferenceId.
* @throws NotFoundException when there is no Conference with the given conferenceId.
*/
@ApiMethod(
name = "getConference",
path = "conference/{websafeConferenceKey}",
httpMethod = HttpMethod.GET
)
public Conference getConference(
@Named("websafeConferenceKey") final String websafeConferenceKey)
throws NotFoundException {
Key<Conference> conferenceKey = Key.create(websafeConferenceKey);
Conference conference = ofy().load().key(conferenceKey).now();
if (conference == null) {
throw new NotFoundException("No Conference found with key: " + websafeConferenceKey);
}
return conference;
}
示例14: getConferencesToAttend
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
/**
* Returns a collection of Conference Object that the user is going to attend.
*
* @param user An user who invokes this method, null when the user is not signed in.
* @return a Collection of Conferences that the user is going to attend.
* @throws UnauthorizedException when the User object is null.
*/
@ApiMethod(
name = "getConferencesToAttend",
path = "getConferencesToAttend",
httpMethod = HttpMethod.GET
)
public Collection<Conference> getConferencesToAttend(final User user)
throws UnauthorizedException, NotFoundException {
// If not signed in, throw a 401 error.
if (user == null) {
throw new UnauthorizedException("Authorization required");
}
Profile profile = ofy().load().key(Key.create(Profile.class, user.getUserId())).now();
if (profile == null) {
throw new NotFoundException("Profile doesn't exist.");
}
List<String> keyStringsToAttend = profile.getConferenceKeysToAttend();
List<Key<Conference>> keysToAttend = new ArrayList<>();
for (String keyString : keyStringsToAttend) {
keysToAttend.add(Key.<Conference>create(keyString));
}
return ofy().load().keys(keysToAttend).values();
}
示例15: pollVote
import com.google.api.server.spi.config.ApiMethod.HttpMethod; //导入依赖的package包/类
@ApiMethod(
name = "meeting.pollVote",
path = "meeting/{id}/poll/vote",
httpMethod = HttpMethod.POST
)
public Meeting pollVote(@Named("id") String id, @Named("proposedStartDate") Long proposedStartDate, @Named("proposedEndDate") Long proposedEndDate, @Named("result") boolean result, com.google.appengine.api.users.User gUser) throws OAuthRequestException, MeetingPollPastException, EntityNotFoundException, UnauthorizedException {
userService.ensureEnabled(gUser);
Meeting meeting = meetingService.get(id);
if (meeting == null) throw new EntityNotFoundException(id);
if (meeting.isPast()) throw new MeetingPollPastException(id);
MeetingPollProposedDate proposedDate = new MeetingPollProposedDate();
proposedDate.setStartTimestamp(proposedStartDate);
proposedDate.setEndTimestamp(proposedEndDate);
MeetingPollVote vote = new MeetingPollVote();
vote.setUser(userService.getUser(gUser));
vote.setProposedDate(proposedDate);
vote.setResult(result);
meetingService.pollVote(meeting, vote);
return meeting;
}