本文整理汇总了Java中org.springframework.web.client.RestTemplate.put方法的典型用法代码示例。如果您正苦于以下问题:Java RestTemplate.put方法的具体用法?Java RestTemplate.put怎么用?Java RestTemplate.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.springframework.web.client.RestTemplate
的用法示例。
在下文中一共展示了RestTemplate.put方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: followChannel
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
/**
* Endpoint: Follow Channel
* Adds a specified user to the followers of a specified channel.
* Requires Scope: user_follows_edit
*
* @param credential Credential
* @param channelId Channel to follow
* @param notifications Send's email notifications on true.
* @return Optional Follow, if user is following.
*/
public Boolean followChannel(OAuthCredential credential, Long channelId, Optional<Boolean> notifications) {
// Endpoint
String requestUrl = String.format("%s/users/%s/follows/channels/%s", Endpoints.API.getURL(), credential.getUserId(), channelId);
RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(credential);
// REST Request
try {
Logger.trace(this, "Rest Request to [%s]", requestUrl);
restTemplate.put(requestUrl, Follow.class, new HashMap<String, String>());
return true;
} catch (RestException restException) {
Logger.error(this, "RestException: " + restException.getRestError().toString());
} catch (Exception ex) {
Logger.error(this, "Request failed: " + ex.getMessage());
Logger.trace(this, ExceptionUtils.getStackTrace(ex));
}
return false;
}
示例2: addBlock
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
/**
* Endpoint: Block User
* Blocks a user; that is, adds a specified target user to the blocks list of a specified source user.
* Requires Scope: user_blocks_edit
*
* @param credential Credential
* @param targetUserId UserID of the Target
* @return todo
*/
public Boolean addBlock(OAuthCredential credential, Long targetUserId) {
// Endpoint
String requestUrl = String.format("%s/users/%s/blocks/%s", Endpoints.API.getURL(), credential.getUserId(), targetUserId);
RestTemplate restTemplate = getTwitchClient().getRestClient().getPrivilegedRestTemplate(credential);
// REST Request
try {
Logger.trace(this, "Rest Request to [%s]", requestUrl);
restTemplate.put(requestUrl, Follow.class, new HashMap<String, String>());
return true;
} catch (RestException restException) {
Logger.error(this, "RestException: " + restException.getRestError().toString());
} catch (Exception ex) {
Logger.error(this, "Request failed: " + ex.getMessage());
Logger.trace(this, ExceptionUtils.getStackTrace(ex));
}
return false;
}
示例3: setTestPolicy
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
public String setTestPolicy(final RestTemplate acs, final HttpHeaders headers, final String endpoint,
final String policyFile) throws JsonParseException, JsonMappingException, IOException {
PolicySet policySet = new ObjectMapper().readValue(new File(policyFile), PolicySet.class);
String policyName = policySet.getName();
acs.put(endpoint + ACS_POLICY_SET_API_PATH + policyName, new HttpEntity<>(policySet, headers));
return policyName;
}
示例4: publishTransaction
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
private static void publishTransaction(URL node, Path privateKey, String text, byte[] senderHash) throws Exception {
RestTemplate restTemplate = new RestTemplate();
byte[] signature = SignatureUtils.sign(text.getBytes(), Files.readAllBytes(privateKey));
Transaction transaction = new Transaction(text, senderHash, signature);
restTemplate.put(node.toString() + "/transaction?publish=true", transaction);
System.out.println("Hash of new transaction: " + Base64.encodeBase64String(transaction.getHash()));
}
示例5: testCreateConnectorDeniedWithoutOauthToken
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
@Test(dataProvider = "requestUrlProvider")
public void testCreateConnectorDeniedWithoutOauthToken(final String endpointUrl) throws Exception {
RestTemplate acs = new RestTemplate();
try {
acs.put(this.acsUrl + V1 + endpointUrl,
new HttpEntity<>(new AttributeConnector(), this.zone1Headers));
Assert.fail("No exception thrown when configuring connector without a token.");
} catch (HttpClientErrorException e) {
Assert.assertEquals(e.getStatusCode(), HttpStatus.UNAUTHORIZED);
}
}
示例6: createContainer
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
@Override
public JsonContainer[] createContainer(final String containerName) {
// JsonEndpoint jsonEndpoint = openstackApp.getPublicEndPoints(region, projectId, this);
String url = jsonEndpoint.getUrl() + "/" + containerName;
RestTemplate rt = getRestTemplate(jsonEndpoint.getProjectId());
rt.put(url, null);
return getJsonResources();
}
示例7: addObject
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
/**
* Adds an object to this container.
*
* @param jsonContainer Container to add to
* @param item String item to add
*/
public void addObject(final JsonContainer jsonContainer, final String item) {
// JsonEndpoint jsonEndpoint = openstackApp.getPublicEndPoints(region, projectId, this);
String url = jsonEndpoint.getUrl() + "/" + jsonContainer.getName() + "/" + item;
RestTemplate rt = getRestTemplate(jsonEndpoint.getProjectId());
rt.put(url, item);
}
示例8: testPut
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
private static void testPut(RestTemplate template, String cseUrlPrefix) {
template.put(cseUrlPrefix + "/compute/sayhi/{name}", null, "world");
}
示例9: publishAddress
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
private static void publishAddress(URL node, Path publicKey, String name) throws IOException {
RestTemplate restTemplate = new RestTemplate();
Address address = new Address(name, Files.readAllBytes(publicKey));
restTemplate.put(node.toString() + "/address?publish=true", address);
System.out.println("Hash of new address: " + Base64.encodeBase64String(address.getHash()));
}
示例10: attemptToUpdateServiceParameter
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
private void attemptToUpdateServiceParameter(String parameterName, Object parameter, RestTemplate restTemplate,
String updateServiceUrl) {
Map<String, Object> serviceRequest = createUpdateServiceRequest(parameterName, parameter);
restTemplate.put(updateServiceUrl, serviceRequest);
}
示例11: createTestZone
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
/**
* Creates desired Zone. Makes a call to the zone API and creates a zone in order to execute your set of test
* against it.
*
* @param restTemplate
* @param zoneId
* @param trustedIssuerIds
* @return Zone
* @throws IOException
*/
public Zone createTestZone(final RestTemplate restTemplate, final String zoneId,
final List<String> trustedIssuerIds) throws IOException {
Zone zone = new Zone(zoneId, zoneId, "Zone for integration testing.");
restTemplate.put(this.acsBaseUrl + ACS_ZONE_API_PATH + zoneId, zone);
return zone;
}
示例12: main
import org.springframework.web.client.RestTemplate; //导入方法依赖的package包/类
public static void main(String[] args) {
// TODO Auto-generated method stub
RestTemplate template = new RestTemplate();
Map<String,Long> request_parms=new HashMap<>();
request_parms.put("ISBN",13l);
Book book=new Book();
book.setPrice(200);
template.put("http://localhost:8081/Ch09_Spring_Rest_JDBC/books/13",book,request_parms);
}