Class SdkCommon


  • public class SdkCommon
    extends java.lang.Object
    The purpose of this class is to provide SDK-specific HTTP headers to be included in REST API requests made by the SDK.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.String getProjectName()
      Returns the SDK project's name.
      static java.util.Map<java.lang.String,​java.lang.String> getSdkHeaders​(java.lang.String serviceName, java.lang.String version, java.lang.String methodName)
      This function is invoked by generated service methods (i.e.
      static java.lang.String getVersion()
      Returns the SDK project's version.
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • getVersion

        public static java.lang.String getVersion()
        Returns the SDK project's version.
        Returns:
        a string containing the version (e.g. "1.2.3")
      • getProjectName

        public static java.lang.String getProjectName()
        Returns the SDK project's name.
        Returns:
        a string containing the name (e.g. "dph-services-java-sdk")
      • getSdkHeaders

        public static java.util.Map<java.lang.String,​java.lang.String> getSdkHeaders​(java.lang.String serviceName,
                                                                                           java.lang.String version,
                                                                                           java.lang.String methodName)
        This function is invoked by generated service methods (i.e. methods which implement the REST API operations defined within the API definition). The purpose of this function is to give the SDK implementor the opportunity to provide SDK-specific HTTP headers that will be sent with an outgoing REST API request.

        This function is invoked for each invocation of a generated service method, so the set of HTTP headers could be request-specific. As an optimization, if your SDK will be returning the same set of HTTP headers for each invocation of this function, it is recommended that you initialize the returned map just once (perhaps by using lazy initialization) and simply return it each time the function is invoked, instead of building it each time as in the example below. If you plan to gather metrics for your SDK, the User-Agent header value must be a string similar to the following: my-java-sdk/0.0.1 (lang=java; java.vendor=AdoptOpenJDK; java.version=1.8.0_232; os.arch=x86_64; os.name=Linux; os.version=5.1) In the example above, the analytics tool will parse the user-agent header and use the following properties: "my-java-sdk" - the name of your sdk "0.0.1"- the version of your sdk "lang=java" - the language of the current sdk "java.vendor=AdoptOpenJDK; java.version=1.8.0_232; os.arch=x86_64; os.name=Linux; os.version=5.1" - system information Note: It is very important that the sdk name ends with the string `-sdk`, as the analytics data collector uses this to gather usage data.

        Returns:
        a Map which contains the set of headers to be included in the REST API request