org.jclouds.http.HttpRequest.toBuilder()方法的使用及代码示例

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

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

HttpRequest.toBuilder介绍

暂无

代码示例

代码示例来源:origin: jclouds/legacy-jclouds

private HttpRequest replaceAuthorizationHeader(HttpRequest request, String signature) {
 request = request
    .toBuilder()
    .replaceHeader("X-Amzn-Authorization",
       "AWS3-HTTPS AWSAccessKeyId=" + creds.get().identity + ",Algorithm=HmacSHA256,Signature=" + signature)
    .build();
 return request;
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
 if (input != null) {
   checkArgument(input instanceof String, "this binder is only valid for String!");
   return (R) request.toBuilder().replaceFormParam(param, String.class.cast(input)).build();
 }
 return request;
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
  public HttpRequest filter(HttpRequest request) throws HttpException {
   String token = vcloudTokenProvider.get();
   return request
        .toBuilder()
        .replaceHeaders(
            ImmutableMultimap.of("x-vcloud-authorization", token, HttpHeaders.COOKIE, "vcloud-token="
                 + token)).build();
  }
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
  @Override
  public <R extends HttpRequest> R bindToRequest(R request, Object input) {
   checkArgument(checkNotNull(input, "input") instanceof Iterable<?>, "this binder is only valid for Iterable!");
   checkNotNull(request, "request");

   Iterable<String> emails = (Iterable<String>) input;
   String emailCSV = Joiner.on(", ").join((List<String>) emails);
   ImmutableMultimap<String, String> headers = 
       ImmutableMultimap.<String, String> of(CloudFilesHeaders.CDN_CONTAINER_PURGE_OBJECT_EMAIL, emailCSV);
   
   return (R) request.toBuilder().replaceHeaders(headers).build();
  }
}

代码示例来源:origin: jclouds/legacy-jclouds

HttpRequest replaceAuthorizationHeader(HttpRequest request, String signature) {
 request = request.toBuilder()
    .replaceHeader(HttpHeaders.AUTHORIZATION, authTag + " " + creds.get().identity + ":" + signature).build();
 return request;
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
 Iterable<String> alarmNames = (Iterable<String>) checkNotNull(input, "alarm names must be set");
 ImmutableMultimap.Builder<String, String> formParameters = ImmutableMultimap.builder();
 int alarmNameIndex = 1;
 for (String alarmName : alarmNames) {
   formParameters.put("AlarmNames.member." + alarmNameIndex, alarmName);
   alarmNameIndex++;
 }
 return (R) request.toBuilder().replaceFormParams(formParameters.build()).build();
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
  @Override
  public <R extends HttpRequest> R bindToRequest(R request, Object input) {
   checkArgument(input instanceof Iterable<?>, "this binder is only valid for Iterables!");
   Iterable<String> cidrs = (Iterable<String>) checkNotNull(input, "cidr list");
   checkArgument(Iterables.size(cidrs) > 0, "you must specify at least one cidr range");
   return (R) request.toBuilder().replaceQueryParam("cidrlist", Joiner.on(',').join(cidrs)).build();
  }
}

代码示例来源:origin: jclouds/legacy-jclouds

HttpRequest replaceAuthorizationHeader(HttpRequest request, String signature) {
 return request.toBuilder()
    .replaceHeader(HttpHeaders.AUTHORIZATION, "SharedKeyLite " + creds.get().identity + ":" + signature)
    .build();
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
  @Override
  public <R extends HttpRequest> R bindToRequest(R request, Object input) {
   checkArgument(input instanceof Iterable<?>, "this binder is only valid for Iterables!");
   Iterable<Long> numbers = (Iterable<Long>) checkNotNull(input, "list of Longs");
   checkArgument(Iterables.size(numbers) > 0, "you must specify at least one element");
   return (R) request.toBuilder().replaceQueryParam("ids", Joiner.on(',').join(numbers)).build();
  }
}

代码示例来源:origin: jclouds/legacy-jclouds

public static <R extends HttpRequest> R indexStringArrayToFormValuesWithStringFormat(R request, String format,
   Object input) {
 checkArgument(checkNotNull(input, "input") instanceof String[], "this binder is only valid for String[] : "
    + input.getClass());
 String[] values = (String[]) input;
 Builder<String, String> builder = ImmutableMultimap.builder();
 for (int i = 0; i < values.length; i++) {
   builder.put(String.format(format, i + 1), checkNotNull(values[i], format.toLowerCase() + "s[" + i + "]"));
 }
 ImmutableMultimap<String, String> forms = builder.build();
 return forms.size() == 0 ? request : (R) request.toBuilder().replaceFormParams(forms).build();
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
 String encodedJson = base64().encode(checkNotNull(input, "json").toString().getBytes(UTF_8));
 Builder<String, String> builder = ImmutableMultimap.builder();
 builder.put("Storage.S3.UploadPolicy", encodedJson);
 String signature = signer.sign(encodedJson);
 builder.put("Storage.S3.UploadPolicySignature", signature);
 return (R) request.toBuilder().replaceFormParams(builder.build()).build();
}

代码示例来源:origin: jclouds/legacy-jclouds

public static <R extends HttpRequest> R indexIterableToFormValuesWithPrefix(R request, String prefix, Object input) {
 checkArgument(checkNotNull(input, "input") instanceof Iterable<?>, "this binder is only valid for Iterable<?>: "
    + input.getClass());
 Iterable<?> values = (Iterable<?>) input;
 Builder<String, String> builder = ImmutableMultimap.builder();
 int i = 0;
 for (Object o : values) {
   builder.put(prefix + "." + (i++ + 1), checkNotNull(o.toString(), prefix.toLowerCase() + "s[" + i + "]"));
 }
 ImmutableMultimap<String, String> forms = builder.build();
 return forms.size() == 0 ? request : (R) request.toBuilder().replaceFormParams(forms).build();
}

代码示例来源:origin: jclouds/legacy-jclouds

public static <R extends HttpRequest> R indexStringArrayToFormValuesWithPrefix(R request, String prefix, Object input) {
 checkArgument(checkNotNull(input, "input") instanceof String[], "this binder is only valid for String[] : "
    + input.getClass());
 String[] values = (String[]) input;
 Builder<String, String> builder = ImmutableMultimap.builder();
 for (int i = 0; i < values.length; i++) {
   builder.put(prefix + "." + (i + 1), checkNotNull(values[i], prefix.toLowerCase() + "s[" + i + "]"));
 }
 ImmutableMultimap<String, String> forms = builder.build();
 return forms.size() == 0 ? request : (R) request.toBuilder().replaceFormParams(forms).build();
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
 DirectionalPoolRecord record = DirectionalPoolRecord.class.cast(postParams.get("record"));
 DirectionalGroup group = DirectionalGroup.class.cast(postParams.get("group"));
 String xml = toXML(postParams.get("poolId"), record, group, postParams.get("dirPoolRecordId"),
    postParams.get("groupId"));
 return (R) request.toBuilder().payload(xml).build();
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
 Iterable<?> values = Iterable.class.cast(checkNotNull(input, "attributeNames"));
 Builder<String, String> builder = ImmutableMultimap.builder();
 int i = 0;
 for (Object o : values) {
   builder.put("AttributeName." + (i++ + 1), o.toString());
 }
 ImmutableMultimap<String, String> forms = builder.build();
 return (R) (forms.size() == 0 ? request : request.toBuilder().replaceFormParams(forms).build());
}

代码示例来源:origin: jclouds/legacy-jclouds

HttpRequest replaceDateHeader(HttpRequest request) {
 Builder<String, String> builder = ImmutableMap.builder();
 String date = timeStampProvider.get();
 builder.put(HttpHeaders.DATE, date);
 request = request.toBuilder().replaceHeaders(Multimaps.forMap(builder.build())).build();
 return request;
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
 DirectionalGroup group = DirectionalGroup.class.cast(postParams.get("group"));
 String xml = toXML(postParams.get("dirPoolRecordId"), group);
 return (R) request.toBuilder().payload(xml).build();
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Map<String, Object> postParams) {
 String zoneName = postParams.get("zoneName").toString();
 ResourceRecord record = ResourceRecord.class.cast(postParams.get("resourceRecord"));
 String xml = toXML(zoneName, record);
 Optional<?> guid = Optional.fromNullable(postParams.get("guid"));
 if (guid.isPresent()) {
   xml = update(guid.get(), xml);
 }
 return (R) request.toBuilder().payload(xml).build();
}

代码示例来源:origin: jclouds/legacy-jclouds

@SuppressWarnings("unchecked")
@Override
public <R extends HttpRequest> R bindToRequest(R request, Object input) {
 checkArgument(checkNotNull(input, "input") instanceof IpPermission, "this binder is only valid for IpPermission");
 IpPermission perm = (IpPermission) input;
 return (R) request.toBuilder().replaceFormParams(IpPermissions.buildFormParametersForIndex(0, perm)).build();
}

代码示例来源:origin: jclouds/legacy-jclouds

@Override
  public HttpRequest filter(HttpRequest request) throws HttpException {
   Credentials currentCreds = checkNotNull(creds.get(), "credential supplier returned null");
   return request.toBuilder().replaceHeader(AUTHORIZATION, basic(currentCreds.identity, currentCreds.credential))
      .build();
  }
}

相关文章