/** * Adds a new param to the Javadoc. * * @param paramName Name of parameter. * @param paramDocs Documentation for parameter. * @return This builder for method chaining. */ public DocumentationBuilder param(String paramName, String paramDocs) { this.params.add(Pair.of(paramName, paramDocs)); return this; }
/** * Adds a new param to the Javadoc. * * @param paramName Name of parameter. * @param paramDocs Documentation for parameter. * @return This builder for method chaining. */ public DocumentationBuilder param(String paramName, String paramDocs) { this.params.add(Pair.of(paramName, paramDocs)); return this; }
/** * Adds an arbitrary tag with values to the Javadoc. This will be added in between the throws and see sections * of the Javadoc. * * @param tagName Name of tag to add. * @param tagValues List of values associated with the same. * @return This builder for method chaining. */ public DocumentationBuilder tag(String tagName, String... tagValues) { tags.add(Pair.of(tagName, Arrays.asList(tagValues))); return this; }
/** * Adds an arbitrary tag with values to the Javadoc. This will be added in between the throws and see sections * of the Javadoc. * * @param tagName Name of tag to add. * @param tagValues List of values associated with the same. * @return This builder for method chaining. */ public DocumentationBuilder tag(String tagName, String... tagValues) { tags.add(Pair.of(tagName, Arrays.asList(tagValues))); return this; }
/** * Adds a throws tag to the Javadoc. * * @param exceptionClass Class name of thrown exception. * @param exceptionDoc Documentation for thrown exception. * @return This builder for method chaining. */ public DocumentationBuilder syncThrows(String exceptionClass, String exceptionDoc) { return syncThrows(singletonList(Pair.of(exceptionClass, exceptionDoc))); }
/** * Async exceptions are not thrown from the method, rather the returned {@link java.util.concurrent.CompletableFuture} is * completed exceptionally ({@link java.util.concurrent.CompletableFuture#completeExceptionally(Throwable)}. Because of this * we don't add @throws to the Javadocs or method signature for async methods, we instead add a list of exceptions the future * may be completed exceptionally with in the @returns section of the Javadoc. * * @param exceptionClass Class name of thrown exception. * @param exceptionDoc Documentation for thrown exception. * @return This builder for method chaining. */ public DocumentationBuilder asyncThrows(String exceptionClass, String exceptionDoc) { return asyncThrows(singletonList(Pair.of(exceptionClass, exceptionDoc))); }
/** * Adds a throws tag to the Javadoc. * * @param exceptionClass Class name of thrown exception. * @param exceptionDoc Documentation for thrown exception. * @return This builder for method chaining. */ public DocumentationBuilder syncThrows(String exceptionClass, String exceptionDoc) { return syncThrows(singletonList(Pair.of(exceptionClass, exceptionDoc))); }
/** * Async exceptions are not thrown from the method, rather the returned {@link java.util.concurrent.CompletableFuture} is * completed exceptionally ({@link java.util.concurrent.CompletableFuture#completeExceptionally(Throwable)}. Because of this * we don't add @throws to the Javadocs or method signature for async methods, we instead add a list of exceptions the future * may be completed exceptionally with in the @returns section of the Javadoc. * * @param exceptionClass Class name of thrown exception. * @param exceptionDoc Documentation for thrown exception. * @return This builder for method chaining. */ public DocumentationBuilder asyncThrows(String exceptionClass, String exceptionDoc) { return asyncThrows(singletonList(Pair.of(exceptionClass, exceptionDoc))); }
/** * @return List of thrown exceptions for the given operation. Includes both modeled exceptions and SDK base exceptions. */ final List<Pair<String, String>> getThrows() { List<Pair<String, String>> throwsDocs = opModel.getExceptions().stream() .map(exception -> Pair.of(exception.getExceptionName(), stripHtmlTags(exception.getDocumentation()))) .collect(Collectors.toList()); String baseServiceException = model.getMetadata().getBaseExceptionName(); Collections.addAll(throwsDocs, Pair.of("SdkException ", "Base class for all exceptions that can be thrown by the SDK " + "(both service and client). Can be used for catch all scenarios."), Pair.of("SdkClientException ", "If any client side error occurs such as an IO related failure, " + "failure to get credentials, etc."), Pair.of(baseServiceException, "Base class for all service exceptions. Unknown exceptions will be " + "thrown as an instance of this type.")); return throwsDocs; }
/** * @return List of thrown exceptions for the given operation. Includes both modeled exceptions and SDK base exceptions. */ final List<Pair<String, String>> getThrows() { List<Pair<String, String>> throwsDocs = opModel.getExceptions().stream() .map(exception -> Pair.of(exception.getExceptionName(), stripHtmlTags(exception.getDocumentation()))) .collect(Collectors.toList()); String baseServiceException = model.getMetadata().getBaseExceptionName(); Collections.addAll(throwsDocs, Pair.of("SdkException ", "Base class for all exceptions that can be thrown by the SDK " + "(both service and client). Can be used for catch all scenarios."), Pair.of("SdkClientException ", "If any client side error occurs such as an IO related failure, " + "failure to get credentials, etc."), Pair.of(baseServiceException, "Base class for all service exceptions. Unknown exceptions will be " + "thrown as an instance of this type.")); return throwsDocs; }
/** * Parse the response content into an XML document. If we fail to read the content or the XML is malformed * we still return an empty {@link XmlElement} so that unmarshalling can proceed. In those failure * cases we can't parse out the error code so we'd unmarshall into a generic service exception. * * @param response HTTP response. * @return Pair of the parsed {@link XmlElement} and the raw bytes of the response. */ private Pair<XmlElement, SdkBytes> parseXml(SdkHttpFullResponse response) { SdkBytes bytes = getResponseBytes(response); try { return Pair.of(XmlDomParser.parse(bytes.asInputStream()), bytes); } catch (Exception e) { return Pair.of(XmlElement.empty(), bytes); } }
/** * Parse the response content into an XML document. If we fail to read the content or the XML is malformed * we still return an empty {@link XmlElement} so that unmarshalling can proceed. In those failure * cases we can't parse out the error code so we'd unmarshall into a generic service exception. * * @param response HTTP response. * @return Pair of the parsed {@link XmlElement} and the raw bytes of the response. */ private Pair<XmlElement, SdkBytes> parseXml(SdkHttpFullResponse response) { SdkBytes bytes = getResponseBytes(response); try { return Pair.of(XmlDomParser.parse(bytes.asInputStream()), bytes); } catch (Exception e) { return Pair.of(XmlElement.empty(), bytes); } }
/** * Given a property line, load the property key and value. If the property line is invalid and should be ignored, this will * return empty. */ private static Optional<Pair<String, String>> parsePropertyDefinition(ParserState state, String line) { int firstEqualsLocation = line.indexOf('='); Validate.isTrue(firstEqualsLocation != -1, "Expected an '=' sign defining a property on line " + state.currentLineNumber); String propertyKey = StringUtils.trim(line.substring(0, firstEqualsLocation)); String propertyValue = StringUtils.trim(line.substring(firstEqualsLocation + 1)); Validate.isTrue(!propertyKey.isEmpty(), "Property did not have a name on line " + state.currentLineNumber); // If the profile name includes invalid characters, it should be ignored. if (!isValidIdentifier(propertyKey)) { log.warn(() -> "Ignoring property '" + propertyKey + "' on line " + state.currentLineNumber + " because " + "its name was not alphanumeric with dashes or underscores."); return Optional.empty(); } return Optional.of(Pair.of(propertyKey, propertyValue)); }
/** * Given a property line, load the property key and value. If the property line is invalid and should be ignored, this will * return empty. */ private static Optional<Pair<String, String>> parsePropertyDefinition(ParserState state, String line) { int firstEqualsLocation = line.indexOf('='); Validate.isTrue(firstEqualsLocation != -1, "Expected an '=' sign defining a property on line " + state.currentLineNumber); String propertyKey = StringUtils.trim(line.substring(0, firstEqualsLocation)); String propertyValue = StringUtils.trim(line.substring(firstEqualsLocation + 1)); Validate.isTrue(!propertyKey.isEmpty(), "Property did not have a name on line " + state.currentLineNumber); // If the profile name includes invalid characters, it should be ignored. if (!isValidIdentifier(propertyKey)) { log.warn(() -> "Ignoring property '" + propertyKey + "' on line " + state.currentLineNumber + " because " + "its name was not alphanumeric with dashes or underscores."); return Optional.empty(); } return Optional.of(Pair.of(propertyKey, propertyValue)); }
public <TypeT extends SdkPojo> Pair<TypeT, Map<String, String>> unmarshall(SdkPojo sdkPojo, SdkHttpFullResponse response) { XmlElement document = response.content().map(XmlDomParser::parse).orElse(XmlElement.empty()); XmlElement resultRoot = hasResultWrapper ? document.getFirstChild() : document; return Pair.of(unmarshall(sdkPojo, resultRoot, response), parseMetadata(document)); }
public <TypeT extends SdkPojo> Pair<TypeT, Map<String, String>> unmarshall(SdkPojo sdkPojo, SdkHttpFullResponse response) { XmlElement document = response.content().map(XmlDomParser::parse).orElse(XmlElement.empty()); XmlElement resultRoot = hasResultWrapper ? document.getFirstChild() : document; return Pair.of(unmarshall(sdkPojo, resultRoot, response), parseMetadata(document)); }
/** * Returns the response from executing one httpClientSettings request; or null for retry. */ public Pair<SdkHttpFullRequest, SdkHttpFullResponse> execute(SdkHttpFullRequest request, RequestExecutionContext context) throws Exception { InterruptMonitor.checkInterrupted(); HttpExecuteResponse executeResponse = executeHttpRequest(request, context); // TODO: Plumb through ExecuteResponse instead SdkHttpFullResponse httpResponse = (SdkHttpFullResponse) executeResponse.httpResponse(); return Pair.of(request, httpResponse.toBuilder().content(executeResponse.responseBody().orElse(null)).build()); }
return Pair.of(input.left(), response);