#Copyright (c)  WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
#
# WSO2 Inc. licenses this file to you 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: apim-conf-ingress-1
data:
  deployment.toml: |-
    [server]
    hostname = "wso2apim"
    node_ip = "$env{NODE_IP}"
    #offset=0
    mode = "single" #single or ha
    base_path = "${carbon.protocol}://${carbon.host}:${carbon.management.port}"
    #discard_empty_caches = false
    server_role = "default"

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

    [user_store]
    type = "database_unique_id"

    [database.apim_db]
    type = "mysql"
    url = "jdbc:mysql://mysql-svc:3306/WSO2AM_APIMGT_DB?useSSL=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?autoReconnect=true&amp;useSSL=false"
    username = "wso2carbon"
    password = "wso2carbon"
    driver = "com.mysql.cj.jdbc.Driver"

    [keystore.tls]
    file_name =  "wso2carbon.jks"
    type =  "JKS"
    password =  "wso2carbon"
    alias =  "wso2carbon"
    key_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."
    show_as_token_endpoint_url = true
    service_url = "https://localhost:${mgt.transport.https.port}/services/"
    username= "${admin.username}"
    password= "${admin.password}"
    ws_endpoint = "ws://wso2apim:9099"
    wss_endpoint = "wss://wso2apim:8099"
    http_endpoint = "http://wso2apim-gateway"
    https_endpoint = "https://wso2apim-gateway"

    [apim.analytics]
    enable = true
    store_api_url = "https://wso2-am-analytics-worker-svc:7444"
    username = "$ref{super_admin.username}"
    password = "$ref{super_admin.password}"
    event_publisher_type = "default"
    event_publisher_impl = "org.wso2.carbon.apimgt.usage.publisher.APIMgtUsageDataBridgeDataPublisher"
    publish_response_size = true

    [[apim.analytics.url_group]]
    analytics_url =["tcp://wso2-am-analytics-worker-svc:7612"]
    analytics_auth_url =["ssl://wso2-am-analytics-worker-svc:7712"]

    [apim.devportal]
    url = "https://wso2apim/devportal"

    [[apim.throttling.url_group]]
    traffic_manager_urls = ["tcp://localhost:9611"]
    traffic_manager_auth_urls = ["ssl://localhost:9711"]
    type = "loadbalance"

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

    [apim.cors]
    allow_origins = "*"
    allow_methods = ["GET","PUT","POST","DELETE","PATCH","OPTIONS"]
    allow_headers = ["authorization","Access-Control-Allow-Origin","Content-Type","SOAPAction","apikey"]
    allow_credentials = false

    [[event_handler]]
    name="userPostSelfRegistration"
    subscriptions=["POST_ADD_USER"]

    [service_provider]
    sp_name_regex = "^[\\sa-zA-Z0-9._-]*$"

    [database.local]
    url = "jdbc:h2:./repository/database/WSO2CARBON_DB;DB_CLOSE_ON_EXIT=FALSE"

    [transport.https.properties]
    proxyPort = 443

    [transport.http.properties]
    proxyPort = 80