IBM / platform-services-go-sdk

Go client library for IBM Cloud Platform Services

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

globalcatalogv1.PricingGet: API is not returning the price of the plan

JohnPaulParkin opened this issue · comments

Describe the bug

The Price field of the Price structure is not being unmarshalled because there's a case mismatch between the annotation in the go code and the value returned in the json payload. Looks like it's this code that's the problem, but since it's generated I'm assuming there's something else similar to the other PricingGet issue I opened last week. Likely some entries here : https://github.ibm.com/cloud-api-docs/resource-catalog/blob/production/global-catalog.json#L397

The struct definition here is wrong ( compared with the plain REST payloads ) : https://github.com/IBM/platform-services-go-sdk/blob/main/globalcatalogv1/global_catalog_v1.go#L3685

// Price : Pricing-related information.
type Price struct {
	// Pricing tier.
	QuantityTier *int64 `json:"quantity_tier,omitempty"`

	// Price in the selected currency.
	Price *float64 `json:"Price,omitempty"` <<<<<<<<<<<<<< The json annotation is the wrong case
}

To Reproduce

You can use the application that I posted as part of #247 to reproduce the problem. What you will see is that when the price information is dumped there's no Price value ( ie. the dollar cost ) - only the quantity tier is reported.

For example, a partial output of one of the Kubernetes plans reports :

{
    "deployment_id": "public.containers.kubernetes.b1c.32x128:ca-tor28613",
    "deployment_location": "ca-tor",
    "type": "Paid",
    "origin": "pricing_catalog",
    "starting_price": {},
    "metrics": [
        {
            "part_ref": "",
            "metric_id": "D1SL6LL",
            "tier_model": "Step Tier",
            "charge_unit": "Instance-Hours",
            "charge_unit_name": "instance_hours",
            "charge_unit_quantity": 1,
            "resource_display_name": "",
            "charge_unit_display_name": "",
            "usage_cap_qty": 0,
            "display_cap": 0,
            "effective_from": "2023-04-01T00:00:00.000Z",
            "effective_until": "2023-04-30T23:59:59.999Z",
            "amounts": [
                {
                    "country": "USA",
                    "currency": "USD",
                    "prices": [
                        {
                            "quantity_tier": 150                 <<<<<<<<<<<<<< price is missing here 
                        },
                        {
                            "quantity_tier": 290
                        },
                        {
                            "quantity_tier": 540
                        },
                        {
                            "quantity_tier": 999999999
                        }
                    ]
                },

but in the similar REST payload, the content looks like :

{
  "deployment_id": "public.containers.kubernetes.b1c.32x128:ca-tor28613",
  "deployment_location": "ca-tor",
  "deployment_region": "DEFAULT",
  "origin": "pricing_catalog",
  "type": "Paid",
  "i18n": {},
  "starting_price": {},
  "effective_from": "2023-04-01T00:00:00Z",
  "effective_until": "2023-04-30T23:59:59.999Z",
  "metrics": [
    {
      "part_ref": "",
      "metric_id": "D1SL6LL",
      "tier_model": "Step Tier",
      "resource_display_name": "",
      "charge_unit_display_name": "",
      "charge_unit_name": "instance_hours",
      "charge_unit": "Instance-Hours",
      "charge_unit_quantity": 1,
      "amounts": [
        {
          "country": "USA",
          "currency": "USD",
          "prices": [
            {
              "quantity_tier": 150,
              "price": 1.87  <<<<<<< expecting to get the price like this in the above output
            },
            {
              "quantity_tier": 290,
              "price": 1.78
            },

Must gather (please complete the following information):

SDK Version : 0.37.1
Go Version : go1.19.8
Name of service that you're trying to use : globalcatalogv1
Name of operation that you're trying to invoke :PricingGet

@dubee - here's another issue with the Pricing API - can you please have a look ?

@dubee I checked the global-catalog API definition and the "price" property is defined as "Price". The name used in the API definition should match the field name that will appear in the JSON response returned by the server.
So, to fix this, we'd need to fix the API definition and then re-gen the SDK code.
Do we have an integration test for the affected operation(s) where we can test that this is working correctly once fixed?