Skip to content

Commit

Permalink
ML Engine Models in Terraform
Browse files Browse the repository at this point in the history
Signed-off-by: Modular Magician <[email protected]>
  • Loading branch information
rambleraptor authored and modular-magician committed Aug 5, 2019
1 parent d678d7b commit 0b25ac5
Show file tree
Hide file tree
Showing 9 changed files with 719 additions and 2 deletions.
1 change: 1 addition & 0 deletions google/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ type Config struct {
FirestoreBasePath string
KmsBasePath string
LoggingBasePath string
MLEngineBasePath string
MonitoringBasePath string
PubsubBasePath string
RedisBasePath string
Expand Down
46 changes: 46 additions & 0 deletions google/ml_engine_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------
package google

import (
"fmt"
)

type MLEngineOperationWaiter struct {
Config *Config
CommonOperationWaiter
}

func (w *MLEngineOperationWaiter) QueryOp() (interface{}, error) {
if w == nil {
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
}
// Returns the proper get.
url := fmt.Sprintf("https://ml.googleapis.com/v1/%s", w.CommonOperationWaiter.Op.Name)
return sendRequest(w.Config, "GET", url, nil)
}

func mLEngineOperationWaitTime(config *Config, op map[string]interface{}, project, activity string, timeoutMinutes int) error {
if val, ok := op["name"]; !ok || val == "" {
// This was a synchronous call - there is no operation to wait for.
return nil
}
w := &MLEngineOperationWaiter{
Config: config,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return err
}
return OperationWait(w, activity, timeoutMinutes)
}
6 changes: 4 additions & 2 deletions google/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ func Provider() terraform.ResourceProvider {
FirestoreCustomEndpointEntryKey: FirestoreCustomEndpointEntry,
KmsCustomEndpointEntryKey: KmsCustomEndpointEntry,
LoggingCustomEndpointEntryKey: LoggingCustomEndpointEntry,
MLEngineCustomEndpointEntryKey: MLEngineCustomEndpointEntry,
MonitoringCustomEndpointEntryKey: MonitoringCustomEndpointEntry,
PubsubCustomEndpointEntryKey: PubsubCustomEndpointEntry,
RedisCustomEndpointEntryKey: RedisCustomEndpointEntry,
Expand Down Expand Up @@ -221,6 +222,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
GeneratedFirestoreResourcesMap,
GeneratedKmsResourcesMap,
GeneratedLoggingResourcesMap,
GeneratedMLEngineResourcesMap,
GeneratedMonitoringResourcesMap,
GeneratedPubsubResourcesMap,
GeneratedRedisResourcesMap,
Expand Down Expand Up @@ -392,6 +394,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config.FirestoreBasePath = d.Get(FirestoreCustomEndpointEntryKey).(string)
config.KmsBasePath = d.Get(KmsCustomEndpointEntryKey).(string)
config.LoggingBasePath = d.Get(LoggingCustomEndpointEntryKey).(string)
config.MLEngineBasePath = d.Get(MLEngineCustomEndpointEntryKey).(string)
config.MonitoringBasePath = d.Get(MonitoringCustomEndpointEntryKey).(string)
config.PubsubBasePath = d.Get(PubsubCustomEndpointEntryKey).(string)
config.RedisBasePath = d.Get(RedisCustomEndpointEntryKey).(string)
Expand All @@ -402,8 +405,6 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config.StorageBasePath = d.Get(StorageCustomEndpointEntryKey).(string)
config.TpuBasePath = d.Get(TpuCustomEndpointEntryKey).(string)

// Handwritten Products / Versioned / Atypical Entries

config.CloudBillingBasePath = d.Get(CloudBillingCustomEndpointEntryKey).(string)
config.ComposerBasePath = d.Get(ComposerCustomEndpointEntryKey).(string)
config.ComputeBetaBasePath = d.Get(ComputeBetaCustomEndpointEntryKey).(string)
Expand Down Expand Up @@ -449,6 +450,7 @@ func ConfigureBasePaths(c *Config) {
c.FirestoreBasePath = FirestoreDefaultBasePath
c.KmsBasePath = KmsDefaultBasePath
c.LoggingBasePath = LoggingDefaultBasePath
c.MLEngineBasePath = MLEngineDefaultBasePath
c.MonitoringBasePath = MonitoringDefaultBasePath
c.PubsubBasePath = PubsubDefaultBasePath
c.RedisBasePath = RedisDefaultBasePath
Expand Down
34 changes: 34 additions & 0 deletions google/provider_ml_engine_gen.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// ----------------------------------------------------------------------------
//
// *** AUTO GENERATED CODE *** AUTO GENERATED CODE ***
//
// ----------------------------------------------------------------------------
//
// This file is automatically generated by Magic Modules and manual
// changes will be clobbered when the file is regenerated.
//
// Please read more about how to change this file in
// .github/CONTRIBUTING.md.
//
// ----------------------------------------------------------------------------

package google

import "github.com/hashicorp/terraform/helper/schema"

// If the base path has changed as a result of your PR, make sure to update
// the provider_reference page!
var MLEngineDefaultBasePath = "https://ml.googleapis.com/v1/"
var MLEngineCustomEndpointEntryKey = "ml_engine_custom_endpoint"
var MLEngineCustomEndpointEntry = &schema.Schema{
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateCustomEndpoint,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_ML_ENGINE_CUSTOM_ENDPOINT",
}, MLEngineDefaultBasePath),
}

var GeneratedMLEngineResourcesMap = map[string]*schema.Resource{
"google_ml_engine_model": resourceMLEngineModel(),
}
Loading

0 comments on commit 0b25ac5

Please sign in to comment.