本文整理汇总了Java中org.scribe.model.Verb.POST属性的典型用法代码示例。如果您正苦于以下问题:Java Verb.POST属性的具体用法?Java Verb.POST怎么用?Java Verb.POST使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.scribe.model.Verb
的用法示例。
在下文中一共展示了Verb.POST属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: launchServer
/**
* 创建虚机
*
* @param clusterId
* 虚机所在的集群
* @param clusterRoleId
* 虚机所在的虚机组
* @param launchConfigurationId
* 创建虚机所使用的模板
* @return 创建后的虚机信息
* @throws Fit2CloudException
*/
public Server launchServer(long clusterId, long clusterRoleId, long launchConfigurationId)
throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/launchserver/cluster/" + clusterId
+ "/clusterrole/" + clusterRoleId + "?launchConfigurationId=" + launchConfigurationId);
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return new GsonBuilder().create().fromJson(responseString, Server.class);
} else {
throw new Fit2CloudException(responseString);
}
}
示例2: launchServerAsync
/**
* 创建虚机. 此接口将立刻返回虚机ID,而后台将异步创建虚机. 之后通过返回的虚机信息中的ID来查询完整的虚机信息
*
* @param clusterId
* 虚机所在的集群
* @param clusterRoleId
* 虚机所在的虚机组
* @param launchConfigurationId
* 创建虚机所使用的模板
* @return
* @throws Fit2CloudException
*/
public Server launchServerAsync(long clusterId, long clusterRoleId, long launchConfigurationId)
throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/launchserver/async/cluster/" + clusterId
+ "/clusterrole/" + clusterRoleId + "?launchConfigurationId=" + launchConfigurationId);
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return new GsonBuilder().create().fromJson(responseString, Server.class);
} else {
throw new Fit2CloudException(responseString);
}
}
示例3: editScript
/**
* 编辑指定脚本
*
* @param scriptId
* 脚本ID
* @param description
* 脚本描述
* @param scriptText
* 脚本内容
* @return
* @throws Fit2CloudException
*/
public boolean editScript(long scriptId, String description, String scriptText) throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/script/" + scriptId + "/update");
request.addBodyParameter("description", description);
request.addBodyParameter("scriptText", scriptText);
request.setCharset("UTF-8");
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return "true".equals(responseString);
} else {
throw new Fit2CloudException(response.getBody());
}
}
示例4: saveTag
/**
* 给指定虚机设置标签. 若无则新增标签; 若有则替换
*
* @param serverId
* 虚机ID
* @param tagName
* 标签名称
* @param tagValue
* 标签值
* @return
* @throws Fit2CloudException
*/
public Tag saveTag(Long serverId, String tagName, String tagValue) throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/tags/save");
if (serverId != null && serverId.intValue() > 0) {
request.addBodyParameter("serverId", String.valueOf(serverId));
}
if (tagName != null && tagName.trim().length() > 0) {
request.addBodyParameter("tagName", tagName.trim());
}
if (tagValue != null && tagValue.trim().length() > 0) {
request.addBodyParameter("tagValue", tagValue.trim());
}
request.setCharset("UTF-8");
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return new GsonBuilder().create().fromJson(responseString, Tag.class);
} else {
throw new Fit2CloudException(response.getBody());
}
}
示例5: deleteTag
/**
* 删除指定虚机的标签
*
* @param serverId
* 虚机ID
* @param tagName
* 标签名称
* @return
* @throws Fit2CloudException
*/
public boolean deleteTag(Long serverId, String tagName) throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/tags/delete");
if (serverId != null && serverId.intValue() > 0) {
request.addBodyParameter("serverId", String.valueOf(serverId));
}
if (tagName != null && tagName.trim().length() > 0) {
request.addBodyParameter("tagName", tagName.trim());
}
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return "true".equals(responseString);
} else {
throw new Fit2CloudException(response.getBody());
}
}
示例6: addApplicationRevision
/**
* 添加应用版本
*
* @param name
* 应用版本名称
* @param description
* 应用版本描述
* @param applicationName
* 所属应用名称
* @param repositoryName
* 所属仓库名称
* @param location
* 应用版本文件的下载路径
* @param md5
* 应用版本文件的md5值
* @return
* @throws Fit2CloudException
*/
public ApplicationRevision addApplicationRevision(String name, String description, String applicationName,
String repositoryName, String location, String md5) throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/deploy/app/revision/add.json");
request.addBodyParameter("revName", name);
request.addBodyParameter("revDescription", description);
request.addBodyParameter("appName", applicationName);
if (repositoryName != null) {
request.addBodyParameter("repoName", repositoryName);
}
request.addBodyParameter("location", location);
if (md5 != null && md5.trim().length() > 0) {
request.addBodyParameter("md5", md5);
}
request.setCharset("UTF-8");
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return new GsonBuilder().create().fromJson(responseString, ApplicationRevision.class);
} else {
throw new Fit2CloudException(response.getBody());
}
}
示例7: getAccessTokenByAuthCode
/**
* Receive oauth2 token from authentication server and store it in the session context
*
* @param authorizationCode from authentication server
* @return oauth2 token
* @throws IOException
*/
@Override
public OAuth2AccessToken getAccessTokenByAuthCode(String authorizationCode) throws ParseException {
LOGGER.info("get oauth2 access token", TokenServiceImpl.class);
OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, ACCESS_TOKEN_URI);
oAuthRequest.addHeader("Content-Type", HEADER_CONTENT_TYPE);
oAuthRequest.addHeader("Authorization", HEADER_AUTHORIZATION_TYPE + Base64.encodeBase64String(new String(CLIENT_ID + ":" + CLIENT_SECRET).getBytes()));
oAuthRequest.setCharset(HEADER_CHAR_SET_TYPE);
oAuthRequest.addBodyParameter("grant_type", AUTHORIZATION_CODE_GRANT_TYPE);
oAuthRequest.addBodyParameter("code", authorizationCode);
LOGGER.info("send request for access token", TokenServiceImpl.class);
String accessTokenResponse = oAuthRequest.send().getBody();
if (accessTokenResponse != null) {
LOGGER.info("successfully received authorization token");
// store accessToken in session context
this.accessToken = new DefaultOAuth2AccessToken(new JSONObject(accessTokenResponse).get("access_token").toString());
((DefaultOAuth2AccessToken) this.accessToken).setRefreshToken(new DefaultOAuth2RefreshToken(new JSONObject(accessTokenResponse).get("refresh_token").toString()));
((DefaultOAuth2AccessToken) this.accessToken).setExpiration((new Date(System.currentTimeMillis() + (Long
.valueOf(new JSONObject(accessTokenResponse).get("expires_in").toString()) * 60000))));
String idToken = new JSONObject(accessTokenResponse).get("id_token").toString();
this.jwtDTO = parseJWTToken(idToken);
this.userId = this.jwtDTO.getUserId();
} else {
LOGGER.warn("failed to get authorization token", TokenServiceImpl.class);
}
return accessToken;
}
示例8: refreshToken
/**
* Obtain a new token by refresh token
*/
@Override
public void refreshToken() {
if (this.accessToken.getRefreshToken() != null) {
OAuthRequest oAuthRequest = new OAuthRequest(Verb.POST, ACCESS_TOKEN_URI);
oAuthRequest.addHeader("Content-Type", HEADER_CONTENT_TYPE);
oAuthRequest.addHeader("Authorization", HEADER_AUTHORIZATION_TYPE + Base64.encodeBase64String(new String(CLIENT_ID + ":" + CLIENT_SECRET).getBytes()));
oAuthRequest.setCharset(HEADER_CHAR_SET_TYPE);
oAuthRequest.addBodyParameter("grant_type", REFRESH_TOKEN_GRANT_TYPE);
oAuthRequest.addBodyParameter("refresh_token", getAccessTokenFromContext().getRefreshToken().getValue().toString());
oAuthRequest.addBodyParameter("scope", CLIENT_ID + "." + propertySources.getTradeshiftAppVersion());
LOGGER.info("send request for access token by refresh token", TokenServiceImpl.class);
String accessTokenResponse = oAuthRequest.send().getBody();
if (accessTokenResponse != null) {
LOGGER.info("successfully received authorization token by refresh token");
// store accessToken in session context
this.accessToken = new DefaultOAuth2AccessToken(new JSONObject(accessTokenResponse).get("access_token").toString());
((DefaultOAuth2AccessToken) this.accessToken).setExpiration((new Date(System.currentTimeMillis() + Long.valueOf(new JSONObject(accessTokenResponse).get("expires_in").toString()))));
} else {
LOGGER.warn("failed to get authorization token by refresh token", TokenServiceImpl.class);
}
} else {
LOGGER.error("Refresh token doesn't exist", TokenServiceImpl.class);
}
}
示例9: doInBackground
protected Boolean doInBackground(String... urls) {
try {
Request request = new Request(Verb.POST, this.url);
return true;
} catch (Exception exception) {
Log.d("CordovaPostcard", exception.getMessage());
return null;
}
/*
try {
HttpRequest request = HttpRequest.post(this.url);
request.form(this.params);
Log.d("Postcard", "response -> " + request.body());
if (request.ok()) {
//file = File.createTempFile("download", ".tmp");
//request.receive(file);
//publishProgress(file.length());
return true;
} else {
return null;
}
} catch (HttpRequestException exception) {
return null;
}
*/
}
示例10: getTokenByAuthorizationCode
public DeepinToken getTokenByAuthorizationCode(String code) {
Request request = new Request(Verb.POST, OAUTH2_API + "token");
request.addBodyParameter("grant_type", "authorization_code");
request.addBodyParameter("code", code);
request.addBodyParameter("redirect_uri", oauthCallback);
request.addBodyParameter("client_id", clientID);
request.addBodyParameter("client_secret", clientSecret);
Response response = request.send();
String json = response.getBody();
Gson gson = new Gson();
DeepinToken tokenResponse = gson.fromJson(json, DeepinToken.class);
return tokenResponse;
}
示例11: registerCmdbServer
public CmdbVm registerCmdbServer(String sfServerId, Long cmdbServerId, boolean installAgent, String user,
String password, String key, Long port) throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/cmdbserver/register");
request.addBodyParameter("sfServerId", sfServerId);
request.addBodyParameter("cmdbServerId", String.valueOf(cmdbServerId));
request.addBodyParameter("installAgent", String.valueOf(installAgent));
if (user != null && user.trim().length() > 0) {
request.addBodyParameter("user", user);
}
if (password != null && password.trim().length() > 0) {
request.addBodyParameter("password", password);
}
if (key != null && key.trim().length() > 0) {
request.addBodyParameter("key", key);
}
if (port == null || port <= 0) {
port = 22l;
}
request.addBodyParameter("port", String.valueOf(port));
request.setCharset("UTF-8");
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return new GsonBuilder().create().fromJson(responseString, CmdbVm.class);
} else {
throw new Fit2CloudException(response.getBody());
}
}
示例12: registerServer
/**
* 将服务器注册到devops平台
*
* @param server
* server对象
* @param installAgent
* 是否自动安装agent
* @param user
* 系统的登录用户名
* @param password
* 系统的登录密码
* @param key
* 系统的登录秘钥
* @param port
* 系统的登录端口
* @return
* @throws Fit2CloudException
*/
public Server registerServer(Server server, boolean installAgent, String user,
String password, String key, Long port) throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/server/import");
request.addBodyParameter("server", new Gson().toJson(server));
request.addBodyParameter("installAgent", String.valueOf(installAgent));
if (user != null && user.trim().length() > 0) {
request.addBodyParameter("user", user);
}
if (password != null && password.trim().length() > 0) {
request.addBodyParameter("password", password);
}
if (key != null && key.trim().length() > 0) {
request.addBodyParameter("key", key);
}
if (port == null || port <= 0) {
port = 22l;
}
request.addBodyParameter("port", String.valueOf(port));
request.setCharset("UTF-8");
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return new GsonBuilder().create().fromJson(responseString, Server.class);
} else {
throw new Fit2CloudException(response.getBody());
}
}
示例13: deleteClusterParam
/**
* 删除指定集群的集群参数
*
* @param clusterId
* 集群ID
* @param name
* 集群参数名称
* @return
* @throws Fit2CloudException
*/
public boolean deleteClusterParam(long clusterId, String name) throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST,
restApiEndpoint + "/cluster/" + clusterId + "/param/delete?name=" + name);
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return "true".equals(responseString);
} else {
throw new Fit2CloudException(response.getBody());
}
}
示例14: post
@Override
public String post(String url, byte[] payload, Map.Entry<String, String>... params) {
OAuthRequest request = new OAuthRequest(Verb.POST, url);
if (params != null) {
this.addBodyParams(request, params);
}
request.addPayload(payload);
request.addHeader("Content-Type", "application/json");
this.service.signRequest(this.accesToken, request);
Response r = request.send();
return r.getBody();
}
示例15: deleteScript
/**
* 删除指定脚本
*
* @param scriptId
* 脚本ID
* @return
* @throws Fit2CloudException
*/
public boolean deleteScript(long scriptId) throws Fit2CloudException {
OAuthRequest request = new OAuthRequest(Verb.POST, restApiEndpoint + "/script/" + scriptId + "/delete");
Token accessToken = new Token("", "");
service.signRequest(accessToken, request);
Response response = request.send();
int code = response.getCode();
String responseString = response.getBody();
if (code == 200) {
return "true".equals(responseString);
} else {
throw new Fit2CloudException(response.getBody());
}
}