-
Notifications
You must be signed in to change notification settings - Fork 138
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #531 from tirthct/ocm-2966
OCM-2966 : Feat : Added subscription_type parameter to create cluster command
- Loading branch information
Showing
6 changed files
with
136 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package billing | ||
|
||
import ( | ||
sdk "github.com/openshift-online/ocm-sdk-go" | ||
amv1 "github.com/openshift-online/ocm-sdk-go/accountsmgmt/v1" | ||
) | ||
|
||
const ( | ||
StandardSubscriptionType = "standard" | ||
MarketplaceRhmSubscriptionType = "marketplace-rhm" | ||
MarketplaceGcpSubscriptionType = "marketplace-gcp" | ||
) | ||
|
||
var ValidSubscriptionTypes = []string{ | ||
StandardSubscriptionType, | ||
MarketplaceRhmSubscriptionType, | ||
MarketplaceGcpSubscriptionType, | ||
} | ||
|
||
func GetBillingModel(connection *sdk.Connection, billingModelID string) (*amv1.BillingModelItem, error) { | ||
bilingModel, err := connection.AccountsMgmt().V1().BillingModels().BillingModel(billingModelID).Get().Send() | ||
if err != nil { | ||
return nil, err | ||
} | ||
return bilingModel.Body(), nil | ||
} | ||
|
||
func GetBillingModels(connection *sdk.Connection) ([]*amv1.BillingModelItem, error) { | ||
response, err := connection.AccountsMgmt().V1().BillingModels().List().Send() | ||
if err != nil { | ||
return nil, err | ||
} | ||
billingModels := response.Items().Slice() | ||
var validBillingModel []*amv1.BillingModelItem | ||
for _, billingModel := range billingModels { | ||
for _, validSubscriptionTypeId := range ValidSubscriptionTypes { | ||
if billingModel.ID() == validSubscriptionTypeId { | ||
validBillingModel = append(validBillingModel, billingModel) | ||
} | ||
} | ||
} | ||
return validBillingModel, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters