Skip to content

Commit

Permalink
Bring Access Context Manager / VPC Service Controls to GA (hashicorp#576
Browse files Browse the repository at this point in the history
)

<!-- This change is generated by MagicModules. -->
/cc @rileykarson
  • Loading branch information
modular-magician authored and rileykarson committed Apr 2, 2019
1 parent 08a6cfa commit 4eebe56
Show file tree
Hide file tree
Showing 14 changed files with 37 additions and 4,631 deletions.
2 changes: 1 addition & 1 deletion google-beta/access_context_manager_operation.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ func (w *AccessContextManagerOperationWaiter) QueryOp() (interface{}, error) {
return nil, fmt.Errorf("Cannot query operation, it's unset or nil.")
}
// Returns the proper get.
url := fmt.Sprintf("https://accesscontextmanager.googleapis.com/v1beta/%s", w.CommonOperationWaiter.Op.Name)
url := fmt.Sprintf("https://accesscontextmanager.googleapis.com/v1/%s", w.CommonOperationWaiter.Op.Name)
return sendRequest(w.Config, "GET", url, nil)
}

Expand Down
9 changes: 0 additions & 9 deletions google-beta/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import (

"golang.org/x/oauth2"
googleoauth "golang.org/x/oauth2/google"
accesscontextmanager "google.golang.org/api/accesscontextmanager/v1beta"
appengine "google.golang.org/api/appengine/v1"
"google.golang.org/api/bigquery/v2"
"google.golang.org/api/cloudbilling/v1"
Expand Down Expand Up @@ -64,7 +63,6 @@ type Config struct {

tokenSource oauth2.TokenSource

clientAccessContextManager *accesscontextmanager.Service
clientBilling *cloudbilling.APIService
clientBuild *cloudbuild.Service
clientComposer *composer.Service
Expand Down Expand Up @@ -295,13 +293,6 @@ func (c *Config) LoadAndValidate() error {
}
c.clientCloudFunctions.UserAgent = userAgent

log.Printf("[INFO] Instantiating Google Cloud AccessContextManager Client...")
c.clientAccessContextManager, err = accesscontextmanager.New(client)
if err != nil {
return err
}
c.clientAccessContextManager.UserAgent = userAgent

c.bigtableClientFactory = &BigtableClientFactory{
UserAgent: userAgent,
TokenSource: tokenSource,
Expand Down
10 changes: 5 additions & 5 deletions google-beta/resource_access_context_manager_access_level.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func resourceAccessContextManagerAccessLevel() *schema.Resource {
"os_type": {
Type: schema.TypeString,
Optional: true,
ValidateFunc: validation.StringInSlice([]string{"OS_UNSPECIFIED", "DESKTOP_MAC", "DESKTOP_WINDOWS", "DESKTOP_LINUX", "DESKTOP_CHROME_OS", "ANDROID", "IOS", ""}, false),
ValidateFunc: validation.StringInSlice([]string{"OS_UNSPECIFIED", "DESKTOP_MAC", "DESKTOP_WINDOWS", "DESKTOP_LINUX", "DESKTOP_CHROME_OS", ""}, false),
},
},
},
Expand Down Expand Up @@ -198,7 +198,7 @@ func resourceAccessContextManagerAccessLevelCreate(d *schema.ResourceData, meta
return err
}

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/{{parent}}/accessLevels")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/{{parent}}/accessLevels")
if err != nil {
return err
}
Expand Down Expand Up @@ -234,7 +234,7 @@ func resourceAccessContextManagerAccessLevelCreate(d *schema.ResourceData, meta
func resourceAccessContextManagerAccessLevelRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/{{name}}")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/{{name}}")
if err != nil {
return err
}
Expand Down Expand Up @@ -288,7 +288,7 @@ func resourceAccessContextManagerAccessLevelUpdate(d *schema.ResourceData, meta
return err
}

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/{{name}}")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/{{name}}")
if err != nil {
return err
}
Expand Down Expand Up @@ -333,7 +333,7 @@ func resourceAccessContextManagerAccessLevelUpdate(d *schema.ResourceData, meta
func resourceAccessContextManagerAccessLevelDelete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/{{name}}")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/{{name}}")
if err != nil {
return err
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ resource "google_access_context_manager_access_level" "test-access" {
device_policy {
require_screen_lock = false
os_constraints {
os_type = "IOS"
os_type = "DESKTOP_CHROME_OS"
}
}
}
Expand Down
8 changes: 4 additions & 4 deletions google-beta/resource_access_context_manager_access_policy.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func resourceAccessContextManagerAccessPolicyCreate(d *schema.ResourceData, meta
obj["title"] = titleProp
}

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/accessPolicies")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/accessPolicies")
if err != nil {
return err
}
Expand Down Expand Up @@ -130,7 +130,7 @@ func resourceAccessContextManagerAccessPolicyCreate(d *schema.ResourceData, meta
func resourceAccessContextManagerAccessPolicyRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/accessPolicies/{{name}}")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/accessPolicies/{{name}}")
if err != nil {
return err
}
Expand Down Expand Up @@ -170,7 +170,7 @@ func resourceAccessContextManagerAccessPolicyUpdate(d *schema.ResourceData, meta
obj["title"] = titleProp
}

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/accessPolicies/{{name}}")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/accessPolicies/{{name}}")
if err != nil {
return err
}
Expand Down Expand Up @@ -207,7 +207,7 @@ func resourceAccessContextManagerAccessPolicyUpdate(d *schema.ResourceData, meta
func resourceAccessContextManagerAccessPolicyDelete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/accessPolicies/{{name}}")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/accessPolicies/{{name}}")
if err != nil {
return err
}
Expand Down
32 changes: 4 additions & 28 deletions google-beta/resource_access_context_manager_service_perimeter.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,13 +95,6 @@ func resourceAccessContextManagerServicePerimeter() *schema.Resource {
Type: schema.TypeString,
},
},
"unrestricted_services": {
Type: schema.TypeList,
Optional: true,
Elem: &schema.Schema{
Type: schema.TypeString,
},
},
},
},
},
Expand Down Expand Up @@ -163,7 +156,7 @@ func resourceAccessContextManagerServicePerimeterCreate(d *schema.ResourceData,
return err
}

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/{{parent}}/servicePerimeters")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/{{parent}}/servicePerimeters")
if err != nil {
return err
}
Expand Down Expand Up @@ -199,7 +192,7 @@ func resourceAccessContextManagerServicePerimeterCreate(d *schema.ResourceData,
func resourceAccessContextManagerServicePerimeterRead(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/{{name}}")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/{{name}}")
if err != nil {
return err
}
Expand Down Expand Up @@ -262,7 +255,7 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData,
return err
}

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/{{name}}")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/{{name}}")
if err != nil {
return err
}
Expand Down Expand Up @@ -307,7 +300,7 @@ func resourceAccessContextManagerServicePerimeterUpdate(d *schema.ResourceData,
func resourceAccessContextManagerServicePerimeterDelete(d *schema.ResourceData, meta interface{}) error {
config := meta.(*Config)

url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1beta/{{name}}")
url, err := replaceVars(d, config, "https://accesscontextmanager.googleapis.com/v1/{{name}}")
if err != nil {
return err
}
Expand Down Expand Up @@ -379,8 +372,6 @@ func flattenAccessContextManagerServicePerimeterStatus(v interface{}, d *schema.
flattenAccessContextManagerServicePerimeterStatusResources(original["resources"], d)
transformed["access_levels"] =
flattenAccessContextManagerServicePerimeterStatusAccessLevels(original["accessLevels"], d)
transformed["unrestricted_services"] =
flattenAccessContextManagerServicePerimeterStatusUnrestrictedServices(original["unrestrictedServices"], d)
transformed["restricted_services"] =
flattenAccessContextManagerServicePerimeterStatusRestrictedServices(original["restrictedServices"], d)
return []interface{}{transformed}
Expand All @@ -393,10 +384,6 @@ func flattenAccessContextManagerServicePerimeterStatusAccessLevels(v interface{}
return v
}

func flattenAccessContextManagerServicePerimeterStatusUnrestrictedServices(v interface{}, d *schema.ResourceData) interface{} {
return v
}

func flattenAccessContextManagerServicePerimeterStatusRestrictedServices(v interface{}, d *schema.ResourceData) interface{} {
return v
}
Expand Down Expand Up @@ -440,13 +427,6 @@ func expandAccessContextManagerServicePerimeterStatus(v interface{}, d Terraform
transformed["accessLevels"] = transformedAccessLevels
}

transformedUnrestrictedServices, err := expandAccessContextManagerServicePerimeterStatusUnrestrictedServices(original["unrestricted_services"], d, config)
if err != nil {
return nil, err
} else if val := reflect.ValueOf(transformedUnrestrictedServices); val.IsValid() && !isEmptyValue(val) {
transformed["unrestrictedServices"] = transformedUnrestrictedServices
}

transformedRestrictedServices, err := expandAccessContextManagerServicePerimeterStatusRestrictedServices(original["restricted_services"], d, config)
if err != nil {
return nil, err
Expand All @@ -465,10 +445,6 @@ func expandAccessContextManagerServicePerimeterStatusAccessLevels(v interface{},
return v, nil
}

func expandAccessContextManagerServicePerimeterStatusUnrestrictedServices(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}

func expandAccessContextManagerServicePerimeterStatusRestrictedServices(v interface{}, d TerraformResourceData, config *Config) (interface{}, error) {
return v, nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ resource "google_access_context_manager_service_perimeter" "test-access" {
title = "%s"
perimeter_type = "PERIMETER_TYPE_REGULAR"
status {
restricted_services = ["*"]
restricted_services = ["storage.googleapis.com"]
}
}
`, org, policyTitle, levelTitleName, levelTitleName, perimeterTitleName, perimeterTitleName)
Expand Down Expand Up @@ -166,9 +166,6 @@ resource "google_access_context_manager_service_perimeter" "test-access" {
name = "accessPolicies/${google_access_context_manager_access_policy.test-access.name}/servicePerimeters/%s"
title = "%s"
perimeter_type = "PERIMETER_TYPE_REGULAR"
status {
unrestricted_services = ["*"]
}
}
`, org, policyTitle, levelTitleName, levelTitleName, perimeterTitleName, perimeterTitleName)
}
Loading

0 comments on commit 4eebe56

Please sign in to comment.