Skip to content

Commit

Permalink
feat(Usage Reports): add "created_by_email_id" to Offer schema (#355)
Browse files Browse the repository at this point in the history
Signed-off-by: Jonathan Date-chong <[email protected]>
  • Loading branch information
Jdatechong authored Oct 28, 2024
1 parent 8dfb7aa commit b57da5a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 19 deletions.
36 changes: 22 additions & 14 deletions usagereportsv4/usage_reports_v4.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
*/

/*
* IBM OpenAPI SDK Code Generator Version: 3.89.0-f33c767b-20240410-144451
* IBM OpenAPI SDK Code Generator Version: 3.96.0-d6dec9d7-20241008-212902
*/

// Package usagereportsv4 : Operations and models for the UsageReportsV4 service
Expand Down Expand Up @@ -1445,7 +1445,7 @@ type CreateReportsSnapshotConfigOptions struct {
// "new".
Versioning *string `json:"versioning,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -1533,7 +1533,7 @@ type DeleteReportsSnapshotConfigOptions struct {
// Account ID for which the billing report snapshot is configured.
AccountID *string `json:"account_id" validate:"required"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -1606,7 +1606,7 @@ type GetAccountSummaryOptions struct {
// The billing month for which the usage report is requested. Format is yyyy-mm.
Billingmonth *string `json:"billingmonth" validate:"required,ne="`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -1650,7 +1650,7 @@ type GetAccountUsageOptions struct {
// Prioritize the names returned in the order of the specified languages. Language will default to English.
AcceptLanguage *string `json:"Accept-Language,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -1709,7 +1709,7 @@ type GetOrgUsageOptions struct {
// Prioritize the names returned in the order of the specified languages. Language will default to English.
AcceptLanguage *string `json:"Accept-Language,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -1763,7 +1763,7 @@ type GetReportsSnapshotConfigOptions struct {
// Account ID for which the billing report snapshot is configured.
AccountID *string `json:"account_id" validate:"required"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -1806,7 +1806,7 @@ type GetReportsSnapshotOptions struct {
// The offset from which the records must be fetched. Offset information is included in the response.
Start *string `json:"_start,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -1877,7 +1877,7 @@ type GetResourceGroupUsageOptions struct {
// Prioritize the names returned in the order of the specified languages. Language will default to English.
AcceptLanguage *string `json:"Accept-Language,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -1967,7 +1967,7 @@ type GetResourceUsageAccountOptions struct {
// Region in which the resource instance is provisioned.
Region *string `json:"region,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -2101,7 +2101,7 @@ type GetResourceUsageOrgOptions struct {
// Region in which the resource instance is provisioned.
Region *string `json:"region,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -2230,7 +2230,7 @@ type GetResourceUsageResourceGroupOptions struct {
// Region in which the resource instance is provisioned.
Region *string `json:"region,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -2792,6 +2792,9 @@ type Offer struct {
// The date from which the offer is valid.
ValidFrom *strfmt.DateTime `json:"valid_from" validate:"required"`

// The offer's creator's email id.
CreatedByEmailID *string `json:"created_by_email_id" validate:"required"`

// The date until the offer is valid.
ExpiresOn *strfmt.DateTime `json:"expires_on" validate:"required"`

Expand Down Expand Up @@ -2822,6 +2825,11 @@ func UnmarshalOffer(m map[string]json.RawMessage, result interface{}) (err error
err = core.SDKErrorf(err, "", "valid_from-error", common.GetComponentInfo())
return
}
err = core.UnmarshalPrimitive(m, "created_by_email_id", &obj.CreatedByEmailID)
if err != nil {
err = core.SDKErrorf(err, "", "created_by_email_id-error", common.GetComponentInfo())
return
}
err = core.UnmarshalPrimitive(m, "expires_on", &obj.ExpiresOn)
if err != nil {
err = core.SDKErrorf(err, "", "expires_on-error", common.GetComponentInfo())
Expand Down Expand Up @@ -4170,7 +4178,7 @@ type UpdateReportsSnapshotConfigOptions struct {
// A new version of report is created or the existing report version is overwritten with every update.
Versioning *string `json:"versioning,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down Expand Up @@ -4274,7 +4282,7 @@ type ValidateReportsSnapshotConfigOptions struct {
// "new".
Versioning *string `json:"versioning,omitempty"`

// Allows users to set headers on API requests
// Allows users to set headers on API requests.
Headers map[string]string
}

Expand Down
14 changes: 9 additions & 5 deletions usagereportsv4/usage_reports_v4_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package usagereportsv4_test
import (
"bytes"
"context"
"encoding/base64"
"fmt"
"io"
"net/http"
Expand Down Expand Up @@ -226,7 +227,7 @@ var _ = Describe(`UsageReportsV4`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"account_id": "AccountID", "account_resources": [{"resource_id": "ResourceID", "catalog_id": "CatalogID", "resource_name": "ResourceName", "billable_cost": 12, "billable_rated_cost": 17, "non_billable_cost": 15, "non_billable_rated_cost": 20, "plans": [{"plan_id": "PlanID", "plan_name": "PlanName", "pricing_region": "PricingRegion", "pricing_plan_id": "PricingPlanID", "billable": true, "cost": 4, "rated_cost": 9, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}], "volume_discount": 14, "volume_cost": 10}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}], "pending": true}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "month": "Month", "billing_country_code": "BillingCountryCode", "billing_currency_code": "BillingCurrencyCode", "resources": {"billable_cost": 12, "non_billable_cost": 15}, "offers": [{"offer_id": "OfferID", "credits_total": 12, "offer_template": "OfferTemplate", "valid_from": "2019-01-01T12:00:00.000Z", "expires_on": "2019-01-01T12:00:00.000Z", "credits": {"starting_balance": 15, "used": 4, "balance": 7}}], "support": [{"cost": 4, "type": "Type", "overage": 7}], "support_resources": ["anyValue"], "subscription": {"overage": 7, "subscriptions": [{"subscription_id": "SubscriptionID", "charge_agreement_number": "ChargeAgreementNumber", "type": "Type", "subscription_amount": 18, "start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits_total": 12, "terms": [{"start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits": {"total": 5, "starting_balance": 15, "used": 4, "balance": 7}}]}]}}`)
fmt.Fprintf(res, "%s", `{"account_id": "AccountID", "account_resources": [{"resource_id": "ResourceID", "catalog_id": "CatalogID", "resource_name": "ResourceName", "billable_cost": 12, "billable_rated_cost": 17, "non_billable_cost": 15, "non_billable_rated_cost": 20, "plans": [{"plan_id": "PlanID", "plan_name": "PlanName", "pricing_region": "PricingRegion", "pricing_plan_id": "PricingPlanID", "billable": true, "cost": 4, "rated_cost": 9, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}], "volume_discount": 14, "volume_cost": 10}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}], "pending": true}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "month": "Month", "billing_country_code": "BillingCountryCode", "billing_currency_code": "BillingCurrencyCode", "resources": {"billable_cost": 12, "non_billable_cost": 15}, "offers": [{"offer_id": "OfferID", "credits_total": 12, "offer_template": "OfferTemplate", "valid_from": "2019-01-01T12:00:00.000Z", "created_by_email_id": "CreatedByEmailID", "expires_on": "2019-01-01T12:00:00.000Z", "credits": {"starting_balance": 15, "used": 4, "balance": 7}}], "support": [{"cost": 4, "type": "Type", "overage": 7}], "support_resources": ["anyValue"], "subscription": {"overage": 7, "subscriptions": [{"subscription_id": "SubscriptionID", "charge_agreement_number": "ChargeAgreementNumber", "type": "Type", "subscription_amount": 18, "start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits_total": 12, "terms": [{"start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits": {"total": 5, "starting_balance": 15, "used": 4, "balance": 7}}]}]}}`)
}))
})
It(`Invoke GetAccountSummary successfully with retries`, func() {
Expand Down Expand Up @@ -281,7 +282,7 @@ var _ = Describe(`UsageReportsV4`, func() {
// Set mock response
res.Header().Set("Content-type", "application/json")
res.WriteHeader(200)
fmt.Fprintf(res, "%s", `{"account_id": "AccountID", "account_resources": [{"resource_id": "ResourceID", "catalog_id": "CatalogID", "resource_name": "ResourceName", "billable_cost": 12, "billable_rated_cost": 17, "non_billable_cost": 15, "non_billable_rated_cost": 20, "plans": [{"plan_id": "PlanID", "plan_name": "PlanName", "pricing_region": "PricingRegion", "pricing_plan_id": "PricingPlanID", "billable": true, "cost": 4, "rated_cost": 9, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}], "volume_discount": 14, "volume_cost": 10}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}], "pending": true}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "month": "Month", "billing_country_code": "BillingCountryCode", "billing_currency_code": "BillingCurrencyCode", "resources": {"billable_cost": 12, "non_billable_cost": 15}, "offers": [{"offer_id": "OfferID", "credits_total": 12, "offer_template": "OfferTemplate", "valid_from": "2019-01-01T12:00:00.000Z", "expires_on": "2019-01-01T12:00:00.000Z", "credits": {"starting_balance": 15, "used": 4, "balance": 7}}], "support": [{"cost": 4, "type": "Type", "overage": 7}], "support_resources": ["anyValue"], "subscription": {"overage": 7, "subscriptions": [{"subscription_id": "SubscriptionID", "charge_agreement_number": "ChargeAgreementNumber", "type": "Type", "subscription_amount": 18, "start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits_total": 12, "terms": [{"start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits": {"total": 5, "starting_balance": 15, "used": 4, "balance": 7}}]}]}}`)
fmt.Fprintf(res, "%s", `{"account_id": "AccountID", "account_resources": [{"resource_id": "ResourceID", "catalog_id": "CatalogID", "resource_name": "ResourceName", "billable_cost": 12, "billable_rated_cost": 17, "non_billable_cost": 15, "non_billable_rated_cost": 20, "plans": [{"plan_id": "PlanID", "plan_name": "PlanName", "pricing_region": "PricingRegion", "pricing_plan_id": "PricingPlanID", "billable": true, "cost": 4, "rated_cost": 9, "usage": [{"metric": "UP-TIME", "metric_name": "UP-TIME", "quantity": 711.11, "rateable_quantity": 700, "cost": 123.45, "rated_cost": 130.0, "price": ["anyValue"], "unit": "HOURS", "unit_name": "HOURS", "non_chargeable": true, "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}], "volume_discount": 14, "volume_cost": 10}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}], "pending": true}], "discounts": [{"ref": "Discount-d27beddb-111b-4bbf-8cb1-b770f531c1a9", "name": "platform-discount", "display_name": "Platform Service Discount", "discount": 5}]}], "month": "Month", "billing_country_code": "BillingCountryCode", "billing_currency_code": "BillingCurrencyCode", "resources": {"billable_cost": 12, "non_billable_cost": 15}, "offers": [{"offer_id": "OfferID", "credits_total": 12, "offer_template": "OfferTemplate", "valid_from": "2019-01-01T12:00:00.000Z", "created_by_email_id": "CreatedByEmailID", "expires_on": "2019-01-01T12:00:00.000Z", "credits": {"starting_balance": 15, "used": 4, "balance": 7}}], "support": [{"cost": 4, "type": "Type", "overage": 7}], "support_resources": ["anyValue"], "subscription": {"overage": 7, "subscriptions": [{"subscription_id": "SubscriptionID", "charge_agreement_number": "ChargeAgreementNumber", "type": "Type", "subscription_amount": 18, "start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits_total": 12, "terms": [{"start": "2019-01-01T12:00:00.000Z", "end": "2019-01-01T12:00:00.000Z", "credits": {"total": 5, "starting_balance": 15, "used": 4, "balance": 7}}]}]}}`)
}))
})
It(`Invoke GetAccountSummary successfully`, func() {
Expand Down Expand Up @@ -4112,7 +4113,7 @@ var _ = Describe(`UsageReportsV4`, func() {
})
Describe(`Utility function tests`, func() {
It(`Invoke CreateMockByteArray() successfully`, func() {
mockByteArray := CreateMockByteArray("This is a test")
mockByteArray := CreateMockByteArray("VGhpcyBpcyBhIHRlc3Qgb2YgdGhlIGVtZXJnZW5jeSBicm9hZGNhc3Qgc3lzdGVt")
Expect(mockByteArray).ToNot(BeNil())
})
It(`Invoke CreateMockUUID() successfully`, func() {
Expand All @@ -4138,8 +4139,11 @@ var _ = Describe(`UsageReportsV4`, func() {
// Utility functions used by the generated test code
//

func CreateMockByteArray(mockData string) *[]byte {
ba := []byte(mockData)
func CreateMockByteArray(encodedString string) *[]byte {
ba, err := base64.StdEncoding.DecodeString(encodedString)
if err != nil {
panic(err)
}
return &ba
}

Expand Down

0 comments on commit b57da5a

Please sign in to comment.