@@ -2,7 +2,6 @@ package create
22
33import (
44 "github.com/redhat-developer/app-services-cli/pkg/shared/accountmgmtutil"
5- "github.com/redhat-developer/app-services-cli/pkg/shared/connection"
65 "github.com/redhat-developer/app-services-cli/pkg/shared/factory"
76 "github.com/redhat-developer/app-services-cli/pkg/shared/remote"
87 "github.com/spf13/cobra"
@@ -28,7 +27,7 @@ func GetCloudProviderRegionCompletionValues(f *factory.Factory, providerID strin
2827}
2928
3029// GetKafkaSizeCompletionValues returns a list of valid kafka sizes for the specified region and ams instance types
31- func GetKafkaSizeCompletionValues (f * factory.Factory , providerID string , regionId string ) (validRegions []string , directive cobra.ShellCompDirective ) {
30+ func GetKafkaSizeCompletionValues (f * factory.Factory , providerID string , regionId string ) (validSizes []string , directive cobra.ShellCompDirective ) {
3231 directive = cobra .ShellCompDirectiveNoSpace
3332
3433 // We need both values to provide a valid list of sizes
@@ -41,33 +40,76 @@ func GetKafkaSizeCompletionValues(f *factory.Factory, providerID string, regionI
4140 return nil , directive
4241 }
4342
44- conn , err := f . Connection ( connection . DefaultConfigSkipMasAuth )
43+ orgQuota , err := accountmgmtutil . GetOrgQuotas ( f , & constants . Kafka . Ams )
4544 if err != nil {
4645 return nil , directive
4746 }
4847
49- userInstanceType , _ := accountmgmtutil .GetUserSupportedInstanceType ( f . Context , & constants . Kafka . Ams , conn )
48+ userInstanceType , _ := accountmgmtutil .SelectQuotaForUser ( f , orgQuota , accountmgmtutil. MarketplaceInfo {} )
5049
5150 // Not including quota in this request as it takes very long time to list quota for all regions in suggestion mode
52- validRegions , _ = FetchValidKafkaSizesLabels (f , providerID , regionId , * userInstanceType )
51+ validSizes , _ = FetchValidKafkaSizesLabels (f , providerID , regionId , * userInstanceType )
5352
54- return validRegions , cobra .ShellCompDirectiveNoSpace
53+ return validSizes , cobra .ShellCompDirectiveNoSpace
5554}
5655
57- // GetMarketplaceAcctIdCompletionValues returns a list of valid marketplace account IDs for the organization
58- func GetMarketplaceAcctIdCompletionValues ( f * factory. Factory ) ( validMarketplaceAcctIDs [] string , directive cobra. ShellCompDirective ) {
56+ func GetMarketplaceCompletionValues ( f * factory. Factory ) ( validSizes [] string , directive cobra. ShellCompDirective ) {
57+
5958 directive = cobra .ShellCompDirectiveNoSpace
6059
61- validMarketplaceAcctIDs , _ = accountmgmtutil .GetValidMarketplaceAcctIDs (f .Context , f .Connection , "" )
60+ err , constants := remote .GetRemoteServiceConstants (f .Context , f .Logger )
61+ if err != nil {
62+ return nil , directive
63+ }
64+
65+ orgQuota , err := accountmgmtutil .GetOrgQuotas (f , & constants .Kafka .Ams )
66+ if err != nil {
67+ return nil , directive
68+ }
69+
70+ validMarketPlaces := FetchValidMarketplaces (orgQuota .MarketplaceQuotas )
71+
72+ return validMarketPlaces , cobra .ShellCompDirectiveNoSpace
73+ }
74+
75+ func GetMarketplaceAccountCompletionValues (f * factory.Factory , marketplace string ) (validMarketplaceAcctIDs []string , directive cobra.ShellCompDirective ) {
76+
77+ directive = cobra .ShellCompDirectiveNoSpace
78+
79+ if marketplace == "" {
80+ return validMarketplaceAcctIDs , directive
81+ }
82+
83+ err , constants := remote .GetRemoteServiceConstants (f .Context , f .Logger )
84+ if err != nil {
85+ return nil , directive
86+ }
87+
88+ orgQuota , err := accountmgmtutil .GetOrgQuotas (f , & constants .Kafka .Ams )
89+ if err != nil {
90+ return nil , directive
91+ }
6292
63- return validMarketplaceAcctIDs , directive
93+ validMarketplaceAcctIDs = FetchValidMarketplaceAccounts (orgQuota .MarketplaceQuotas , marketplace )
94+
95+ return validMarketplaceAcctIDs , cobra .ShellCompDirectiveNoSpace
6496}
6597
66- // GetMarketplaceCompletionValues returns a list of valid marketplaces for the organization
67- func GetMarketplaceCompletionValues ( f * factory. Factory ) ( validMarketplaces [] string , directive cobra. ShellCompDirective ) {
98+ func GetBillingModelCompletionValues ( f * factory. Factory ) ( availableBillingModels [] string , directive cobra. ShellCompDirective ) {
99+
68100 directive = cobra .ShellCompDirectiveNoSpace
69101
70- validMarketplaces , _ = accountmgmtutil .GetValidMarketplaces (f .Context , f .Connection )
102+ err , constants := remote .GetRemoteServiceConstants (f .Context , f .Logger )
103+ if err != nil {
104+ return nil , directive
105+ }
106+
107+ orgQuota , err := accountmgmtutil .GetOrgQuotas (f , & constants .Kafka .Ams )
108+ if err != nil {
109+ return nil , directive
110+ }
111+
112+ availableBillingModels = FetchSupportedBillingModels (orgQuota )
71113
72- return validMarketplaces , directive
114+ return availableBillingModels , directive
73115}
0 commit comments