com.amazonaws.Request.getParameters()方法的使用及代码示例

x33g5p2x  于2022-01-28 转载在 其他  
字(9.8k)|赞(0)|评价(0)|浏览(183)

本文整理了Java中com.amazonaws.Request.getParameters方法的一些代码示例,展示了Request.getParameters的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getParameters方法的具体详情如下:
包路径:com.amazonaws.Request
类名称:Request
方法名:getParameters

Request.getParameters介绍

[英]Returns a map of all parameters in this request.
[中]返回此请求中所有参数的映射。

代码示例

代码示例来源:origin: stackoverflow.com

private Request createRequest(Session session) {
  Request request = Request.newGraphPathRequest(session, "me/friends", null);

  Set<String> fields = new HashSet<String>();
  String[] requiredFields = new String[] { "id", "name", "picture",
      "installed" };
  fields.addAll(Arrays.asList(requiredFields));

  Bundle parameters = request.getParameters();
  parameters.putString("fields", TextUtils.join(",", fields));
  request.setParameters(parameters);

  return request;
}

代码示例来源:origin: aws/aws-sdk-java

/**
 * Merge query parameters into the given request.
 */
private void mergeQueryParameters(Map<String, List<String>> params) {
  Map<String, List<String>> existingParams = request.getParameters();
  for (Entry<String, List<String>> param : params.entrySet()) {
    String pName = param.getKey();
    List<String> pValues = param.getValue();
    existingParams.put(pName, CollectionUtils.mergeLists(existingParams.get(pName), pValues));
  }
}

代码示例来源:origin: stackoverflow.com

Request photoRequest = Request.newUploadPhotoRequest(...);
Bundle params = photoRequest.getParameters();
params.putString("message", "description  goes here");
photoRequest.executeAsync();

代码示例来源:origin: aws/aws-sdk-java

public void beforeRequest(Request<?> request) {

    final Map<String, List<String>> requestParams = request.getParameters();
    final List<String> queueURLParam = requestParams.get(QUEUE_URL_PARAMETER);
    if (queueURLParam != null && !queueURLParam.isEmpty() ) {
      List<String> queueURLParameter = requestParams.remove(QUEUE_URL_PARAMETER);
      String queueUrl = queueURLParameter.iterator().next();

      try {
        URI uri = new URI(queueUrl);
        request.setResourcePath(uri.getPath());

        if (uri.getHost() != null) {
          // If the URI has a host specified, set the request's endpoint to the queue URLs
          // endpoint, so that queue URLs from different regions will send the request to
          // the correct endpoint.
          URI uriWithoutPath = new URI(uri.toString().replace(uri.getPath(), ""));
          request.setEndpoint(uriWithoutPath);
        }
      } catch (URISyntaxException e) {
        throw new AmazonClientException("Unable to parse SQS queue URL '" + queueUrl + "'", e);
      }
    }
  }
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public void beforeRequest(Request<?> request) {
  AmazonWebServiceRequest original = request.getOriginalRequest();
  if (original instanceof DescribeSpotFleetRequestHistoryRequest) {
    Map<String, List<String>> params = request.getParameters();
    List<String> startTime = params.get(START_TIME);
    if (startTime != null && !startTime.isEmpty()) {
      params.put(START_TIME,
          Arrays.asList(sanitize(startTime.get(0))));
    }
  } else if (original instanceof RequestSpotFleetRequest) {
    Map<String, List<String>> params = request.getParameters();
    List<String> validFrom = params.get(VALID_FROM);
    List<String> validUntil = params.get(VALID_UNTIL);
    if (validFrom != null && !validFrom.isEmpty()) {
      params.put(VALID_FROM,
          Arrays.asList(sanitize(validFrom.get(0))));
    }
    if (validUntil != null && !validUntil.isEmpty()) {
      params.put(VALID_UNTIL,
          Arrays.asList(sanitize(validUntil.get(0))));
    }
  }
}

代码示例来源:origin: aws/aws-sdk-java

@Override
  public void beforeRequest(Request<?> request) {
    if (request.getOriginalRequest() instanceof SearchRequest && request.getHttpMethod() == HttpMethodName.GET) {
      request.setHttpMethod(HttpMethodName.POST);
      final byte[] content = SdkHttpUtils.encodeParameters(request).getBytes();
      request.setContent(new ByteArrayInputStream(content));
      request.addHeader("Content-Type", "application/x-www-form-urlencoded");
      request.addHeader("Content-Length", Integer.toString(content.length));
      request.getParameters().clear();
    }
  }
}

代码示例来源:origin: aws/aws-sdk-java

private static String uriFrom(Request<?> sdkRequest) {
  StringBuilder uriBuilder = new StringBuilder(sdkRequest.getEndpoint().toString());
  if (!StringUtils.isNullOrEmpty(sdkRequest.getResourcePath())) {
    uriBuilder.append(sdkRequest.getResourcePath());
  }
  QueryStringEncoder encoder = new QueryStringEncoder(uriBuilder.toString());
  for (Map.Entry<String, List<String>> param : sdkRequest.getParameters().entrySet()) {
    for (String value : param.getValue()) {
      encoder.addParam(param.getKey(), value);
    }
  }
  return encoder.toString();
}

代码示例来源:origin: aws/aws-sdk-java

@Override
public void beforeRequest(Request<?> request) {
  if (!requestClassToPreSign.isInstance(request.getOriginalRequest())) return;
  if (request.getParameters().containsKey(PARAM_PRESIGNED_URL)) return;
  PresignableRequest presignableRequest = adaptRequest(requestClassToPreSign.cast(
      request.getOriginalRequest()));
  String sourceRegion = presignableRequest.getSourceRegion();
  if (sourceRegion == null) return;
  String destinationRegion = AwsHostNameUtils.parseRegion(request.getEndpoint().getHost(),
      SERVICE_NAME);
  Request<?> requestToPresign = presignableRequest.marshall();
  requestToPresign.getParameters().remove(PARAM_SOURCE_REGION);
  requestToPresign.getParameters().put(PARAM_DESTINATION_REGION, Arrays.asList(destinationRegion));
  requestToPresign.setEndpoint(createEndpoint(sourceRegion, SERVICE_NAME));
  requestToPresign.setHttpMethod(HttpMethodName.GET);
  AWSCredentials credentials = request.getHandlerContext(HandlerContextKey.AWS_CREDENTIALS);
  requestToPresign = presignRequest(requestToPresign, credentials, sourceRegion);
  final String presignedUrl = generateUrl(requestToPresign);
  presignableRequest.setPreSignedUrl(presignedUrl);
  request.addParameter(PARAM_PRESIGNED_URL, presignedUrl);
  // Remove the unmodeled params to stop them getting onto the wire
  request.getParameters().remove(PARAM_SOURCE_REGION);
}

代码示例来源:origin: aws/aws-sdk-java

Map<String, List<String>> requestParams = request.getParameters();
for (Map.Entry<String, List<String>> entry : requestParams.entrySet()) {
  for (String value : entry.getValue()) {

代码示例来源:origin: aws/aws-sdk-java

Map<String, List<String>> requestParams = request.getParameters();
for (Map.Entry<String, List<String>> entry : requestParams.entrySet()) {
  for (String value : entry.getValue()) {

代码示例来源:origin: aws/aws-sdk-java

for (String parameter : request.getParameters().keySet()) {
  if (parameter.startsWith("LaunchSpecification.GroupSet.")) keysToRemove.add(parameter);
  request.getParameters().remove(key);

代码示例来源:origin: aws-amplify/aws-sdk-android

/**
 * Returns a map of all parameters in this request.
 *
 * @return A map of all parameters in this request.
 */
public Map<String, String> getParameters() {
  return request.getParameters();
}

代码示例来源:origin: aws/aws-sdk-java

final Map<String, List<String>> originalParameters = new LinkedHashMap<String, List<String>>(request.getParameters());
final Map<String, String> originalHeaders = new HashMap<String, String>(request.getHeaders());

代码示例来源:origin: com.amazonaws/aws-java-sdk-core

/**
 * Merge query parameters into the given request.
 */
private void mergeQueryParameters(Map<String, List<String>> params) {
  Map<String, List<String>> existingParams = request.getParameters();
  for (Entry<String, List<String>> param : params.entrySet()) {
    String pName = param.getKey();
    List<String> pValues = param.getValue();
    existingParams.put(pName, CollectionUtils.mergeLists(existingParams.get(pName), pValues));
  }
}

代码示例来源:origin: stackoverflow.com

Request me = Request.newMeRequest(mCurrentSession, new GraphRequestCallback() {...});
Bundle params = me.getParameters();
params.putString("fields", "email,name");
me.setParameters(params);
me.executeAsync();

代码示例来源:origin: stackoverflow.com

Request request = Request.newUploadPhotoRequest(Session.getActiveSession(), BitmapFactory.decodeResource(_context.getResources(), R.drawable.default_image), uploadPhotoRequestCallback);
Bundle parameters = request.getParameters(); // <-- THIS IS IMPORTANT
parameters.putString(...);
// add more params here
request.setParameters(parameters);
request.executeAsync();

代码示例来源:origin: aws-amplify/aws-sdk-android

protected String getCanonicalizedQueryString(Request<?> request) {
  /*
   * If we're using POST and we don't have any request payload content,
   * then any request query parameters will be sent as the payload, and
   * not in the actual query string.
   */
  if (HttpUtils.usePayloadForQueryParameters(request)) {
    return "";
  } else {
    return this.getCanonicalizedQueryString(request.getParameters());
  }
}

代码示例来源:origin: aws-amplify/aws-sdk-android

@Test
public void testRequestResourcePath() throws Exception {
  Request<?> request = new DefaultRequest<Void>(null, "foo");
  request.setEndpoint(URI.create("http://foo.amazon.com"));
  request.addParameter("foo", "bar");
  request.setResourcePath("foo/bar");
  signer.sign(request, credentials);
  assertNotNull(request.getParameters().get("Signature"));
  assertEquals(EXPECTED_SIGNATURE, request.getParameters().get("Signature"));
}

代码示例来源:origin: aws-amplify/aws-sdk-android

@Test
public void testRequestAndEndpointResourcePath() throws Exception {
  Request<?> request = new DefaultRequest<Void>(null, "foo");
  request.setEndpoint(URI.create("http://foo.amazon.com/foo"));
  request.addParameter("foo", "bar");
  request.setResourcePath("/bar");
  signer.sign(request, credentials);
  assertNotNull(request.getParameters().get("Signature"));
  assertEquals(EXPECTED_SIGNATURE, request.getParameters().get("Signature"));
}

代码示例来源:origin: aws-amplify/aws-sdk-android

@Test
public void testAnonymous() throws Exception {
  Request<?> request = new DefaultRequest<Void>(null, "foo");
  request.setEndpoint(URI.create("http://foo.amazon.com/foo"));
  request.addParameter("foo", "bar");
  request.setResourcePath("bar");
  signer.sign(request, new AnonymousAWSCredentials());
  assertNull(request.getParameters().get("Signature"));
}

相关文章