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 <magic-modules@google.com>
  • Loading branch information
rambleraptor authored and modular-magician committed Aug 16, 2019
1 parent a9bb4b1 commit 2a15416
Show file tree
Hide file tree
Showing 7 changed files with 703 additions and 0 deletions.
2 changes: 2 additions & 0 deletions google-beta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ type Config struct {
HealthcareBasePath string
KmsBasePath string
LoggingBasePath string
MLEngineBasePath string
MonitoringBasePath string
PubsubBasePath string
RedisBasePath string
Expand Down Expand Up @@ -221,6 +222,7 @@ var FirestoreDefaultBasePath = "https://firestore.googleapis.com/v1/"
var HealthcareDefaultBasePath = "https://healthcare.googleapis.com/v1beta1/"
var KmsDefaultBasePath = "https://cloudkms.googleapis.com/v1/"
var LoggingDefaultBasePath = "https://logging.googleapis.com/v2/"
var MLEngineDefaultBasePath = "https://ml.googleapis.com/v1/"
var MonitoringDefaultBasePath = "https://monitoring.googleapis.com/v3/"
var PubsubDefaultBasePath = "https://pubsub.googleapis.com/v1/"
var RedisDefaultBasePath = "https://redis.googleapis.com/v1beta1/"
Expand Down
48 changes: 48 additions & 0 deletions google-beta/ml_engine_operation.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
// ----------------------------------------------------------------------------
//
// *** 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
Project string
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", w.Project, 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,
Project: project,
}
if err := w.CommonOperationWaiter.SetOp(op); err != nil {
return err
}
return OperationWait(w, activity, timeoutMinutes)
}
11 changes: 11 additions & 0 deletions google-beta/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,6 +231,14 @@ func Provider() terraform.ResourceProvider {
"GOOGLE_LOGGING_CUSTOM_ENDPOINT",
}, LoggingDefaultBasePath),
},
"ml_engine_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validateCustomEndpoint,
DefaultFunc: schema.MultiEnvDefaultFunc([]string{
"GOOGLE_ML_ENGINE_CUSTOM_ENDPOINT",
}, MLEngineDefaultBasePath),
},
"monitoring_custom_endpoint": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -493,6 +501,7 @@ func ResourceMapWithErrors() (map[string]*schema.Resource, error) {
"google_kms_key_ring": resourceKmsKeyRing(),
"google_kms_crypto_key": resourceKmsCryptoKey(),
"google_logging_metric": resourceLoggingMetric(),
"google_ml_engine_model": resourceMLEngineModel(),
"google_monitoring_alert_policy": resourceMonitoringAlertPolicy(),
"google_monitoring_group": resourceMonitoringGroup(),
"google_monitoring_notification_channel": resourceMonitoringNotificationChannel(),
Expand Down Expand Up @@ -701,6 +710,7 @@ func providerConfigure(d *schema.ResourceData) (interface{}, error) {
config.HealthcareBasePath = d.Get("healthcare_custom_endpoint").(string)
config.KmsBasePath = d.Get("kms_custom_endpoint").(string)
config.LoggingBasePath = d.Get("logging_custom_endpoint").(string)
config.MLEngineBasePath = d.Get("ml_engine_custom_endpoint").(string)
config.MonitoringBasePath = d.Get("monitoring_custom_endpoint").(string)
config.PubsubBasePath = d.Get("pubsub_custom_endpoint").(string)
config.RedisBasePath = d.Get("redis_custom_endpoint").(string)
Expand Down Expand Up @@ -767,6 +777,7 @@ func ConfigureBasePaths(c *Config) {
c.HealthcareBasePath = HealthcareDefaultBasePath
c.KmsBasePath = KmsDefaultBasePath
c.LoggingBasePath = LoggingDefaultBasePath
c.MLEngineBasePath = MLEngineDefaultBasePath
c.MonitoringBasePath = MonitoringDefaultBasePath
c.PubsubBasePath = PubsubDefaultBasePath
c.RedisBasePath = RedisDefaultBasePath
Expand Down
Loading

0 comments on commit 2a15416

Please sign in to comment.