Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Marketplace GCP billing model to accounts and clusters mgmt #811

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
export CGO_ENABLED=0

# Details of the model to use:
model_version:=v0.0.301
model_version:=v0.0.302
model_url:=https://github.com/openshift-online/ocm-api-model.git

# Details of the metamodel to use:
Expand Down
2 changes: 2 additions & 0 deletions accountsmgmt/v1/billing_model_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
BillingModelMarketplace BillingModel = "marketplace"
// AWS Marketplace billing model.
BillingModelMarketplaceAWS BillingModel = "marketplace-aws"
// GCP Marketplace billing model.
BillingModelMarketplaceGCP BillingModel = "marketplace-gcp"
// RH Marketplace billing model.
BillingModelMarketplaceRHM BillingModel = "marketplace-rhm"
// Azure Marketplace billing model.
Expand Down
4,688 changes: 2,345 additions & 2,343 deletions accountsmgmt/v1/openapi.go

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions clustersmgmt/v1/billing_model_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ const (
BillingModelMarketplace BillingModel = "marketplace"
// AWS Marketplace billing model.
BillingModelMarketplaceAWS BillingModel = "marketplace-aws"
// GCP Marketplace billing model.
BillingModelMarketplaceGCP BillingModel = "marketplace-gcp"
// RH Marketplace billing model.
BillingModelMarketplaceRHM BillingModel = "marketplace-rhm"
// Azure Marketplace billing model.
Expand Down
26 changes: 26 additions & 0 deletions clustersmgmt/v1/cloud_provider_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ type CloudProviderBuilder struct {
href string
displayName string
name string
regions []*CloudRegionBuilder
}

// NewCloudProvider creates a new builder of 'cloud_provider' objects.
Expand Down Expand Up @@ -74,6 +75,14 @@ func (b *CloudProviderBuilder) Name(value string) *CloudProviderBuilder {
return b
}

// Regions sets the value of the 'regions' attribute to the given values.
func (b *CloudProviderBuilder) Regions(values ...*CloudRegionBuilder) *CloudProviderBuilder {
b.regions = make([]*CloudRegionBuilder, len(values))
copy(b.regions, values)
b.bitmap_ |= 32
return b
}

// Copy copies the attributes of the given object into this builder, discarding any previous values.
func (b *CloudProviderBuilder) Copy(object *CloudProvider) *CloudProviderBuilder {
if object == nil {
Expand All @@ -84,6 +93,14 @@ func (b *CloudProviderBuilder) Copy(object *CloudProvider) *CloudProviderBuilder
b.href = object.href
b.displayName = object.displayName
b.name = object.name
if object.regions != nil {
b.regions = make([]*CloudRegionBuilder, len(object.regions))
for i, v := range object.regions {
b.regions[i] = NewCloudRegion().Copy(v)
}
} else {
b.regions = nil
}
return b
}

Expand All @@ -95,5 +112,14 @@ func (b *CloudProviderBuilder) Build() (object *CloudProvider, err error) {
object.bitmap_ = b.bitmap_
object.displayName = b.displayName
object.name = b.name
if b.regions != nil {
object.regions = make([]*CloudRegion, len(b.regions))
for i, v := range b.regions {
object.regions[i], err = v.Build()
if err != nil {
return
}
}
}
return
}
24 changes: 24 additions & 0 deletions clustersmgmt/v1/cloud_provider_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type CloudProvider struct {
href string
displayName string
name string
regions []*CloudRegion
}

// Kind returns the name of the type of the object.
Expand Down Expand Up @@ -147,6 +148,29 @@ func (o *CloudProvider) GetName() (value string, ok bool) {
return
}

// Regions returns the value of the 'regions' attribute, or
// the zero value of the type if the attribute doesn't have a value.
//
// (optional) Provider's regions - only included when listing providers with `fetchRegions=true`.
func (o *CloudProvider) Regions() []*CloudRegion {
if o != nil && o.bitmap_&32 != 0 {
return o.regions
}
return nil
}

// GetRegions returns the value of the 'regions' attribute and
// a flag indicating if the attribute has a value.
//
// (optional) Provider's regions - only included when listing providers with `fetchRegions=true`.
func (o *CloudProvider) GetRegions() (value []*CloudRegion, ok bool) {
ok = o != nil && o.bitmap_&32 != 0
if ok {
value = o.regions
}
return
}

// CloudProviderListKind is the name of the type used to represent list of objects of
// type 'cloud_provider'.
const CloudProviderListKind = "CloudProviderList"
Expand Down
13 changes: 13 additions & 0 deletions clustersmgmt/v1/cloud_provider_type_json.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,15 @@ func writeCloudProvider(object *CloudProvider, stream *jsoniter.Stream) {
}
stream.WriteObjectField("name")
stream.WriteString(object.name)
count++
}
present_ = object.bitmap_&32 != 0 && object.regions != nil
if present_ {
if count > 0 {
stream.WriteMore()
}
stream.WriteObjectField("regions")
writeCloudRegionList(object.regions, stream)
}
stream.WriteObjectEnd()
}
Expand Down Expand Up @@ -125,6 +134,10 @@ func readCloudProvider(iterator *jsoniter.Iterator) *CloudProvider {
value := iterator.ReadString()
object.name = value
object.bitmap_ |= 16
case "regions":
value := readCloudRegionList(iterator)
object.regions = value
object.bitmap_ |= 32
default:
iterator.ReadAny()
}
Expand Down
28 changes: 20 additions & 8 deletions clustersmgmt/v1/cloud_providers_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,14 +71,15 @@ func (c *CloudProvidersClient) CloudProvider(id string) *CloudProviderClient {

// CloudProvidersListRequest is the request for the 'list' method.
type CloudProvidersListRequest struct {
transport http.RoundTripper
path string
query url.Values
header http.Header
order *string
page *int
search *string
size *int
transport http.RoundTripper
path string
query url.Values
header http.Header
fetchRegions *bool
order *string
page *int
search *string
size *int
}

// Parameter adds a query parameter.
Expand All @@ -100,6 +101,14 @@ func (r *CloudProvidersListRequest) Impersonate(user string) *CloudProvidersList
return r
}

// FetchRegions sets the value of the 'fetch_regions' parameter.
Copy link
Contributor

@cben cben Jul 21, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FYI the param is actually called fetchRegions, correctly sent on L180, just the comments generated by metamodel are still inaccurate when overriding url param names with @http override.

//
// If true, includes the regions on each provider in the output. Could slow request response time.
func (r *CloudProvidersListRequest) FetchRegions(value bool) *CloudProvidersListRequest {
r.fetchRegions = &value
return r
}

// Order sets the value of the 'order' parameter.
//
// Order criteria.
Expand Down Expand Up @@ -167,6 +176,9 @@ func (r *CloudProvidersListRequest) Send() (result *CloudProvidersListResponse,
// SendContext sends this request, waits for the response, and returns it.
func (r *CloudProvidersListRequest) SendContext(ctx context.Context) (result *CloudProvidersListResponse, err error) {
query := helpers.CopyQuery(r.query)
if r.fetchRegions != nil {
helpers.AddValue(&query, "fetchRegions", *r.fetchRegions)
}
if r.order != nil {
helpers.AddValue(&query, "order", *r.order)
}
Expand Down
44 changes: 37 additions & 7 deletions clustersmgmt/v1/cloud_region_builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,14 @@ type CloudRegionBuilder struct {
bitmap_ uint32
id string
href string
kmsLocationID string
kmsLocationName string
cloudProvider *CloudProviderBuilder
displayName string
name string
ccsOnly bool
enabled bool
govCloud bool
supportsHypershift bool
supportsMultiAZ bool
}
Expand Down Expand Up @@ -72,51 +75,72 @@ func (b *CloudRegionBuilder) CCSOnly(value bool) *CloudRegionBuilder {
return b
}

// KMSLocationID sets the value of the 'KMS_location_ID' attribute to the given value.
func (b *CloudRegionBuilder) KMSLocationID(value string) *CloudRegionBuilder {
b.kmsLocationID = value
b.bitmap_ |= 16
return b
}

// KMSLocationName sets the value of the 'KMS_location_name' attribute to the given value.
func (b *CloudRegionBuilder) KMSLocationName(value string) *CloudRegionBuilder {
b.kmsLocationName = value
b.bitmap_ |= 32
return b
}

// CloudProvider sets the value of the 'cloud_provider' attribute to the given value.
//
// Cloud provider.
func (b *CloudRegionBuilder) CloudProvider(value *CloudProviderBuilder) *CloudRegionBuilder {
b.cloudProvider = value
if value != nil {
b.bitmap_ |= 16
b.bitmap_ |= 64
} else {
b.bitmap_ &^= 16
b.bitmap_ &^= 64
}
return b
}

// DisplayName sets the value of the 'display_name' attribute to the given value.
func (b *CloudRegionBuilder) DisplayName(value string) *CloudRegionBuilder {
b.displayName = value
b.bitmap_ |= 32
b.bitmap_ |= 128
return b
}

// Enabled sets the value of the 'enabled' attribute to the given value.
func (b *CloudRegionBuilder) Enabled(value bool) *CloudRegionBuilder {
b.enabled = value
b.bitmap_ |= 64
b.bitmap_ |= 256
return b
}

// GovCloud sets the value of the 'gov_cloud' attribute to the given value.
func (b *CloudRegionBuilder) GovCloud(value bool) *CloudRegionBuilder {
b.govCloud = value
b.bitmap_ |= 512
return b
}

// Name sets the value of the 'name' attribute to the given value.
func (b *CloudRegionBuilder) Name(value string) *CloudRegionBuilder {
b.name = value
b.bitmap_ |= 128
b.bitmap_ |= 1024
return b
}

// SupportsHypershift sets the value of the 'supports_hypershift' attribute to the given value.
func (b *CloudRegionBuilder) SupportsHypershift(value bool) *CloudRegionBuilder {
b.supportsHypershift = value
b.bitmap_ |= 256
b.bitmap_ |= 2048
return b
}

// SupportsMultiAZ sets the value of the 'supports_multi_AZ' attribute to the given value.
func (b *CloudRegionBuilder) SupportsMultiAZ(value bool) *CloudRegionBuilder {
b.supportsMultiAZ = value
b.bitmap_ |= 512
b.bitmap_ |= 4096
return b
}

Expand All @@ -129,13 +153,16 @@ func (b *CloudRegionBuilder) Copy(object *CloudRegion) *CloudRegionBuilder {
b.id = object.id
b.href = object.href
b.ccsOnly = object.ccsOnly
b.kmsLocationID = object.kmsLocationID
b.kmsLocationName = object.kmsLocationName
if object.cloudProvider != nil {
b.cloudProvider = NewCloudProvider().Copy(object.cloudProvider)
} else {
b.cloudProvider = nil
}
b.displayName = object.displayName
b.enabled = object.enabled
b.govCloud = object.govCloud
b.name = object.name
b.supportsHypershift = object.supportsHypershift
b.supportsMultiAZ = object.supportsMultiAZ
Expand All @@ -149,6 +176,8 @@ func (b *CloudRegionBuilder) Build() (object *CloudRegion, err error) {
object.href = b.href
object.bitmap_ = b.bitmap_
object.ccsOnly = b.ccsOnly
object.kmsLocationID = b.kmsLocationID
object.kmsLocationName = b.kmsLocationName
if b.cloudProvider != nil {
object.cloudProvider, err = b.cloudProvider.Build()
if err != nil {
Expand All @@ -157,6 +186,7 @@ func (b *CloudRegionBuilder) Build() (object *CloudRegion, err error) {
}
object.displayName = b.displayName
object.enabled = b.enabled
object.govCloud = b.govCloud
object.name = b.name
object.supportsHypershift = b.supportsHypershift
object.supportsMultiAZ = b.supportsMultiAZ
Expand Down
Loading