Package org.apache.synapse.mediators.opa

## Class OPAClient

- java.lang.Object
- - org.apache.synapse.mediators.opa.OPAClient

-     public class OPAClient
      extends Object

  This class represents the client used to request and retrieve OPA response for a given policy from the OPA server

- - ### Constructor Summary

    Constructors
    Constructor | Description
    --- | ---
    `OPAClient​(String url, Map<String,​String> additionalParameters)` |

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method | Description
    --- | --- | ---
    `org.apache.http.impl.client.CloseableHttpClient` | `createHttpClient​(String url)` | Return a CloseableHttpClient instance
    `String` | `publish​(String opaServerUrl, String payload, String credentials)` | Method to publish the OPA payload to the OPA server

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### OPAClient

          public OPAClient​(String url,
                           Map<String,​String> additionalParameters)
                    throws OPASecurityException

      Throws:
        `OPASecurityException`

  - ### Method Detail

    - #### publish

          public String publish​(String opaServerUrl,
                                String payload,
                                String credentials)
                         throws OPASecurityException

      Method to publish the OPA payload to the OPA server
      Parameters:
        `opaServerUrl` - The url of the opa server
        `payload` - The payload of the request
        `credentials` - Access key of the opa validation request
      Returns:
        opa response String
      Throws:
        `OPASecurityException`

    - #### createHttpClient

          public org.apache.http.impl.client.CloseableHttpClient createHttpClient​(String url)
                                                                           throws OPASecurityException

      Return a CloseableHttpClient instance
      Parameters:
        `url` - Service endpoint.It can be http/https
      Returns:
        CloseableHttpClient
      Throws:
        `OPASecurityException`