Uploaded image for project: 'Subscription Watch'
  1. Subscription Watch
  2. SWATCH-2021

Report filtered subscription data to Export Service in JSON

    XMLWordPrintable

Details

    Description

      The expectation for this story is that when a subscription export request is encountered, we'll actually query the database for data, and then POST it back to the export service.

      Requirements:

      • Implement the fetchData method for subscriptions export in swatch-subscription-sync
      • fetched data should always be limited to the orgId that the user is allowed to access.  There's a redhatorgid field on the message, as well as the an org id in the base64 encoded data.x-rh-identity field.
      • consult the data.filters field when querying the database for subscription data. The following filter parameters must be supported:
        • product_id
        • sla
        • usage
        • uom metric_id
        • billing_provider
        • billing_account_id
        • display_name_contains
        • category
      • If any extra filters are provided, log it and move on.
      • If no filters are provided, return unfiltered results (with the exception of limiting by appropriate org id)
      • fetchData must throw an exception for bad product_id, sla, usage, uom, billing_provider, or category
        • The listener must catch and report these errors with exportClient.downloadExportError with error code 400 and a message explaining what parameter(s) are bad. The error message may be limited to a single parameter.
      • If the data.format != json, continue to throw not yet implemented exception.
      • If no exceptions are thrown, implement uploadJson and call exportClient.downloadExportUpload with JSON-formatted data
        • Create a yaml json schema file in src/main/resources/subscriptions-export.yaml and generate the POJO model using jsonSchema2Pojo.

      JSON example:

       {
          "subscriptions": [
              {
                  "sku": "RH00001",
                  "product_name": "Red Hat Enterprise Linux for Virtual Datacenters, Premium",
                  "service_level": "Premium",
                  "usage": "Production",
                  "metric_id": "Sockets",
                  "subscriptions": [
                      {
                          "id": "123456",
                          "number": "123456",
                          "quantity": 42,
                          "capacity": 0,
                          "hypervisor_capacity": 42,
                          "begin": "2021-11-28T16:38:12.951046Z",
                          "end": "2023-11-28T16:38:12.951046Z",
                      }
                  ]
              }
          ]
      }
      

       

      • Use streams wherever possible to mitigate OOM issues

      Testing:

      • Attempted export with bad parameter(s) should fail with a message explaining which parameter(s) are bad.
      • Attempted export for JSON should succeed (after correcting bad parameters)
      • Attempted export for CSV should fail because the format is not yet implemented.

      Attachments

        Issue Links

          Activity

            People

              jcarvaja@redhat.com Jose Carvajal Hilario
              lburnett0 Lindsey Burnett
              Sanket Jagtap Sanket Jagtap
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: