# Silicon Overdrive
# Support: helpdesk@overdrive.co.za
# Tel: 27 21 448 5759
# https://www.overdrive.co.za/
#
# This is an serverless framework yml
#
#
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/recaptcha
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/details
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/update
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/user/details
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/logs
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/transactions
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/register
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/registerpayment
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/evidence
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/getallfines
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/getfinesearch
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/streamevidence
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/getoutstandingfines
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/getcharges
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/queryinfringements
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/queryinfringer
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/payinfringement
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/updateregistration
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/postsettings
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/getgraphs
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/getsettings
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/getgraphsettings
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/postgraphsettings
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/postiveritransaction
  # POST - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/iveripayment
  # GET - https://puru95wxc8.execute-api.eu-west-1.amazonaws.com/production/runcronjob
################################

service: tmt-pmf-prod # NOTE: update this with your service name

# You can pin your service to only deploy with a specific Serverless version
# Check out our docs for more details
# frameworkVersion: "=X.X.X"

provider:
  name: aws
  runtime: dotnetcore3.1
  profile: pmf-prod
  region: eu-west-1
  stage: production
  vpc:
    securityGroupIds:
      - sg-0ef1507ae1fcd0913
    subnetIds:
      - subnet-0c1aaf57b8d9fdb93
      - subnet-0827171db5e6ea7bb

package:
  individually: true
  artifact: bin/release/netcoreapp3.1/pay-my-fines-lambda.zip

functions:
  isRecaptchaValid:
    handler: AwsDotnetCsharp::PMF.Handler::IsRecaptchaValid
    events:
      - http:
          path: recaptcha
          method: post
          cors: true
    #provisionedConcurrency: 5
  getLoggedInUserDetails:
    handler: AwsDotnetCsharp::PMF.Handler::GetLoggedInUserDetails
    events:
      - http:
          path: details
          method: get
          cors: true
    #provisionedConcurrency: 5
  postUserDetails:
    handler: AwsDotnetCsharp::PMF.Handler::PostUserDetails
    events:
      - http:
          path: update
          method: post
          cors: true
    #provisionedConcurrency: 5
  getUserDetails:
    handler: AwsDotnetCsharp::PMF.Handler::GetUserDetails
    events:
      - http:
          path: user/details
          method: get
          cors: true
    #provisionedConcurrency: 5
  getAPILogs:
    handler: AwsDotnetCsharp::PMF.Handler::GetAPILogs
    events:
      - http:
          path: logs
          method: get
          cors: true
    #provisionedConcurrency: 5
  getTransactions:
    handler: AwsDotnetCsharp::PMF.Handler::GetTransactions
    events:
      - http:
          path: transactions
          method: get
          cors: true
    #provisionedConcurrency: 5
  registerUser:
    handler: AwsDotnetCsharp::PMF.Handler::RegisterUser
    events:
      - http:
          path: register
          method: post
          cors: true
    #provisionedConcurrency: 5
  registerpayment:
    handler: AwsDotnetCsharp::PMF.Handler::PostPayment
    events:
      - http:
          path: registerpayment
          method: post
          cors: true
    #provisionedConcurrency: 5
  # deletepayment:
  #   handler: AwsDotnetCsharp::AwsDotnetCsharp.Handler::DeletePayment
  #   events:
  #     - http:
  #         path: deletepayment
  #         method: post
  #         cors: true
    #provisionedConcurrency: 5
  getEvidence:
    handler: AwsDotnetCsharp::PMF.Handler::GetEvidence
    events:
      - http:
          path: evidence
          method: get
          cors: true
    timeout: 30
    #provisionedConcurrency: 5
  getAllFines:
    handler: AwsDotnetCsharp::PMF.Handler::GetAllFines
    events:
      - http:
          path: getallfines
          method: get
          cors: true
    timeout: 45
    #provisionedConcurrency: 5
  getQuickFines:
    handler: AwsDotnetCsharp::PMF.Handler::GetQuickFines
    events:
      - http:
          path: getfinesearch
          method: get
          cors: true
    timeout: 30
    #provisionedConcurrency: 5
  getStreamEvidence:
    handler: AwsDotnetCsharp::PMF.Handler::GetStreamEvidence
    events:
      - http:
          path: streamevidence
          method: get
          cors: true
    timeout: 30
    #provisionedConcurrency: 5
  getoutstandingfines:
    handler: AwsDotnetCsharp::PMF.Handler::GetOutstandingFines
    events:
      - http:
          path: getoutstandingfines
          method: get
          cors: true
    timeout: 30
    #provisionedConcurrency: 5
  getcharges:
    handler: AwsDotnetCsharp::PMF.Handler::GetCharges
    events:
      - http:
          path: getcharges
          method: get
          cors: true
    timeout: 30
    #provisionedConcurrency: 5
  queryinfringements:
    handler: AwsDotnetCsharp::PMF.Handler::QueryExternalInfringement
    events:
      - http:
          path: queryinfringements
          method: get
          cors: true
    timeout: 30
    #provisionedConcurrency: 5
  queryinfringer:
    handler: AwsDotnetCsharp::PMF.Handler::QueryExternalInfringer
    events:
      - http:
          path: queryinfringer
          method: get
          cors: true
    timeout: 30     
    #provisionedConcurrency: 5
  payinfringement:
    handler: AwsDotnetCsharp::PMF.Handler::PayExternalInfringement
    events:
      - http:
          path: payinfringement
          method: post
          cors: true
    timeout: 30  
    #provisionedConcurrency: 5
  generateCustomMessage:
    handler: AwsDotnetCsharp::PMF.Handler::GenerateCustomEmail
    events:
      - cognitoUserPool:
          pool: tmt-pmf-prod-user-pool
          trigger: CustomMessage
          existing: true
    #provisionedConcurrency: 5
  updateRegistration:
    handler: AwsDotnetCsharp::PMF.Handler::UpdateRegistration
    events:
      - http:
          path: updateregistration
          method: post
          cors: true
    #provisionedConcurrency: 5
  postsettings:
    handler: AwsDotnetCsharp::PMF.Handler::PostUpdateSettings
    events:
      - http:
          path: postsettings
          method: post
          cors: true
    #provisionedConcurrency: 5
  getFinanceReportData:
    handler: AwsDotnetCsharp::PMF.Handler::GetFinanceReportData
    events:
      - http:
          path: reports
          method: get
          cors: true
    #provisionedConcurrency: 5
  getgraphs:
    handler: AwsDotnetCsharp::PMF.Handler::GetGraphs
    events:
      - http:
          path: getgraphs
          method: get
          cors: true
    #provisionedConcurrency: 5
  getsettings:
    handler: AwsDotnetCsharp::PMF.Handler::GetSettings
    events:
      - http:
          path: getsettings
          method: get
          cors: true
    #provisionedConcurrency: 5
  getgraphsettings:
    handler: AwsDotnetCsharp::PMF.Handler::GetGraphSettings
    events:
      - http:
          path: getgraphsettings
          method: get
          cors: true
    #provisionedConcurrency: 5
  postgraphsettings:
    handler: AwsDotnetCsharp::PMF.Handler::PostGraphSettings
    events:
      - http:
          path: postgraphsettings
          method: post
          cors: true
    #provisionedConcurrency: 5
  postIveriLiteTransaction:
    handler: AwsDotnetCsharp::PMF.Handler::PostIveriLiteTransaction
    events:
      - http:
          path: postiveritransaction
          method: post
          cors: true
    timeout: 30  
  iVeriPayment:
    handler: AwsDotnetCsharp::PMF.Handler::IVeriPayment
    events:
      - http:
          path: iveripayment
          method: post
          cors: true
    timeout: 45  
    #provisionedConcurrency: 5
  RunCronJob:
     handler: AwsDotnetCsharp::PMF.Handler::RunCronJob
     events:
        - http:
            path: runcronjob
            method: get
            cors: true
        #  authorizer: aws_iam
        - schedule:
            name: RunCronJobDev
            description: 'run the cronjob every 8 hours'
        #     we can use cron expressions here should we require the cron to run on certain days.
        #     schedule: cron(0 18 * * ? *) ---> use this to run the cron everyday at 6pm
            rate: rate(2 hours)      # --> use this for every 8 hours recommended  2 hours for testing
  
