github.com/GoogleCloudPlatform/terraformer@v0.8.18/providers/commercetools/commercetools_provider.go (about) 1 // Copyright 2018 The Terraformer Authors. 2 // 3 // Licensed under the Apache License, Version 2.0 (the "License"); 4 // you may not use this file except in compliance with the License. 5 // You may obtain a copy of the License at 6 // 7 // http://www.apache.org/licenses/LICENSE-2.0 8 // 9 // Unless required by applicable law or agreed to in writing, software 10 // distributed under the License is distributed on an "AS IS" BASIS, 11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 // See the License for the specific language governing permissions and 13 // limitations under the License. 14 15 package commercetools 16 17 import ( 18 "github.com/GoogleCloudPlatform/terraformer/terraformutils" 19 "github.com/pkg/errors" 20 ) 21 22 type CommercetoolsProvider struct { //nolint 23 terraformutils.Provider 24 clientID string 25 clientSecret string 26 clientScope string 27 projectKey string 28 baseURL string 29 tokenURL string 30 } 31 32 func (p CommercetoolsProvider) GetResourceConnections() map[string]map[string][]string { 33 return map[string]map[string][]string{} 34 } 35 36 func (p CommercetoolsProvider) GetProviderData(arg ...string) map[string]interface{} { 37 return map[string]interface{}{} 38 } 39 40 // Init CommerectoolsProvider 41 func (p *CommercetoolsProvider) Init(args []string) error { 42 p.clientID = args[0] 43 p.clientScope = args[1] 44 p.clientSecret = args[2] 45 p.projectKey = args[3] 46 p.baseURL = args[4] 47 p.tokenURL = args[5] 48 return nil 49 } 50 51 func (p *CommercetoolsProvider) GetName() string { 52 return "commercetools" 53 } 54 55 func (p *CommercetoolsProvider) InitService(serviceName string, verbose bool) error { 56 var isSupported bool 57 if _, isSupported = p.GetSupportedService()[serviceName]; !isSupported { 58 return errors.New(p.GetName() + ": " + serviceName + " not supported service") 59 } 60 p.Service = p.GetSupportedService()[serviceName] 61 p.Service.SetName(serviceName) 62 p.Service.SetVerbose(verbose) 63 p.Service.SetProviderName(p.GetName()) 64 p.Service.SetArgs(map[string]interface{}{ 65 "client_id": p.clientID, 66 "client_secret": p.clientSecret, 67 "client_scope": p.clientScope, 68 "project_key": p.projectKey, 69 "base_url": p.baseURL, 70 "token_url": p.tokenURL, 71 }) 72 return nil 73 } 74 75 // GetSupportedService return map of support service for Logzio 76 func (p *CommercetoolsProvider) GetSupportedService() map[string]terraformutils.ServiceGenerator { 77 return map[string]terraformutils.ServiceGenerator{ 78 "api_extension": &APIExtensionGenerator{}, 79 "channel": &ChannelGenerator{}, 80 "custom_object": &CustomObjectGenerator{}, 81 "product_type": &ProductTypeGenerator{}, 82 "shipping_zone": &ShippingZoneGenerator{}, 83 "shipping_method": &ShippingMethodGenerator{}, 84 "state": &StateGenerator{}, 85 "store": &StoreGenerator{}, 86 "subscription": &SubscriptionGenerator{}, 87 "tax_category": &TaxCategoryGenerator{}, 88 "types": &TypesGenerator{}, 89 } 90 }