# Copyright (c) 2020, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: v1
kind: ConfigMap
metadata:
  name: wso2-am-publisher-conf
  namespace : wso2-system
data:
  deployment.toml: |-
    [server]
    hostname = "publisher.am.wso2.com"
    node_ip = "$env{NODE_IP}"
    server_role = "api-publisher"

    [user_store]
    type = "database_unique_id"

    [super_admin]
    username = "admin"
    password = "admin"
    create_admin_account = true

    [database.apim_db]
    type = "mysql"
    url = "jdbc:mysql://mysql-svc:3306/WSO2AM_APIMGT_DB?useSSL=false&amp;autoReconnect=true&amp;requireSSL=false&amp;verifyServerCertificate=false"
    username = "wso2carbon"
    password = "wso2carbon"
    driver = "com.mysql.cj.jdbc.Driver"

    [database.shared_db]
    type = "mysql"
    url = "jdbc:mysql://mysql-svc:3306/WSO2AM_SHARED_DB?useSSL=false&amp;autoReconnect=true&amp;requireSSL=false&amp;verifyServerCertificate=false"
    username = "wso2carbon"
    password = "wso2carbon"
    driver = "com.mysql.cj.jdbc.Driver"
    
    [apim.sync_runtime_artifacts.publisher]
    artifact_saver = "DBSaver"
    publish_directly_to_gateway = "true"

    [keystore.tls]
    file_name =  "wso2carbon.jks"
    type =  "JKS"
    password =  "wso2carbon"
    alias =  "wso2carbon"
    key_password =  "wso2carbon"

    [truststore]
    file_name = "client-truststore.jks"
    type = "JKS"
    password = "wso2carbon"

    [[apim.gateway.environment]]
    name= "Production and Sandbox"
    type= "hybrid"
    display_in_api_console= true
    description= "This is a hybrid gateway that handles both production and sandbox token traffic."
    service_url= "https://wso2-am-gw-svc:${mgt.transport.https.port}${carbon.context}services/"
    username= "${admin.username}"
    password= "${admin.password}"
    http_endpoint = "http://gateway.am.wso2.com"
    https_endpoint = "https://gateway.am.wso2.com"


    # key manager implementation
    [apim.key_manager]
    service_url = "https://wso2-am-km-service:${mgt.transport.https.port}/services/"
    username= "$ref{super_admin.username}"
    password= "$ref{super_admin.password}"

    [apim.analytics]
    enable = "true"
    store_api_url = "https://wso2-am-analytics-worker-svc:7444"
    username= "$ref{super_admin.username}"
    password= "$ref{super_admin.password}"

    [[apim.analytics.url_group]]
    analytics_url =["tcp://wso2-am-analytics-worker-statefulset-0.wso2-am-analytics-worker-headless-svc:7612","tcp://wso2-am-analytics-worker-statefulset-1.wso2-am-analytics-worker-headless-svc:7612"]
    analytics_auth_url =["ssl://wso2-am-analytics-worker-statefulset-0.wso2-am-analytics-worker-headless-svc:7712","ssl://wso2-am-analytics-worker-statefulset-1.wso2-am-analytics-worker-headless-svc:7712"]
    type = "failover"

    # Traffic Manager configurations
    [apim.throttling]
    service_url = "https://wso2-am-tm-svc:${mgt.transport.https.port}/services/"
    username= "$ref{super_admin.username}"
    password= "$ref{super_admin.password}"
    throttle_decision_endpoints = ["tcp://{{wso2-am-tm-statefulset-0.wso2-am-tm-headless-svc:5672","tcp://wso2-am-tm-statefulset-1.wso2-am-tm-headless-svc:5672"]

    [[apim.throttling.url_group]]
    traffic_manager_urls = ["tcp://wso2-am-tm-statefulset-0.wso2-am-tm-headless-svc:9611"]
    traffic_manager_auth_urls = ["ssl://wso2-am-tm-statefulset-0.wso2-am-tm-headless-svc:9711"]
    type = "loadbalance"

    [[apim.throttling.url_group]]
    traffic_manager_urls = ["tcp://wso2-am-tm-statefulset-1.wso2-am-tm-headless-svc:9611"]
    traffic_manager_auth_urls = ["ssl://wso2-am-tm-statefulset-1.wso2-am-tm-headless-svc:9711"]
    type = "loadbalance"

    [apim.cache.scopes]
    enable = true

    [apim.cache.publisher_roles] #check the usage and move to dev role
    enable = true

    [apim.devportal]
    url = "https://devportal.am.wso2.com/devportal"

    [apim.workflow]
    enable = false
    service_url = "https://localhost:9445/bpmn"
    username = "$ref{super_admin.username}"
    password = "$ref{super_admin.password}"
    callback_endpoint = "https://localhost:9443/api/am/publisher/v0.16/workflows/update-workflow-status"
    token_endpoint = "https://localhost:8243/token"
    client_registration_endpoint = "https://localhost:9443/client-registration/v0.17/register"
    client_registration_username = "$ref{super_admin.username}"
    client_registration_password = "$ref{super_admin.password}"

    [apim.event_hub]
    service_url = "https://wso2-am-tm-svc:9443"
    event_listening_endpoints = ["tcp://wso2-am-tm-statefulset-0.wso2-am-tm-headless-svc:5672","tcp://wso2-am-tm-statefulset-1.wso2-am-tm-headless-svc:5672"]

    [[apim.event_hub.publish.url_group]]
    urls = ["tcp://wso2-am-tm-statefulset-0.wso2-am-tm-headless-svc:9611"]
    auth_urls = ["ssl://wso2-am-tm-statefulset-0.wso2-am-tm-headless-svc:9711"]

    [[apim.event_hub.publish.url_group]]
    urls = ["tcp://wso2-am-tm-statefulset-1.wso2-am-tm-headless-svc:9611"]
    auth_urls = ["ssl://wso2-am-tm-statefulset-1.wso2-am-tm-headless-svc:9711"]

    [transport.https.properties]
    proxyPort = 443
