diff --git a/pkg/client/client.go b/pkg/client/client.go index 034fc4e6..4b779944 100644 --- a/pkg/client/client.go +++ b/pkg/client/client.go @@ -1,4 +1,4 @@ -// (C) Copyright 2021 Hewlett Packard Enterprise Development LP +// (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP package client @@ -53,14 +53,20 @@ func (i InitialiseClient) NewClient(r *schema.ResourceData) (interface{}, error) // Create VMaas Client client := new(Client) - + queryParam := map[string]string{ + constants.LocationKey: vmaasProviderSettings[constants.LOCATION].(string), + } + space := vmaasProviderSettings[constants.SPACENAME].(string) + // check if glp then pass the space value as workspaceKey + if r.Get("iam_version").(string) == "glp" { + queryParam[constants.WorkspaceKey] = space + } else { + queryParam[constants.SpaceKey] = space + } cfg := api_client.Configuration{ - Host: vmaasProviderSettings[constants.APIURL].(string), - DefaultHeader: getHeaders(), - DefaultQueryParams: map[string]string{ - constants.SpaceKey: vmaasProviderSettings[constants.SPACENAME].(string), - constants.LocationKey: vmaasProviderSettings[constants.LOCATION].(string), - }, + Host: vmaasProviderSettings[constants.APIURL].(string), + DefaultHeader: getHeaders(), + DefaultQueryParams: queryParam, } apiClient := api_client.NewAPIClient(&cfg) utils.SetMeta(apiClient, r) diff --git a/pkg/constants/constants.go b/pkg/constants/constants.go index 08216ad0..d837f94c 100644 --- a/pkg/constants/constants.go +++ b/pkg/constants/constants.go @@ -1,4 +1,4 @@ -// (C) Copyright 2021 Hewlett Packard Enterprise Development LP +// (C) Copyright 2021-2024 Hewlett Packard Enterprise Development LP // Package constants - constants that are used in pkg/client and pkg/resources package constants @@ -8,12 +8,13 @@ const ( ServiceName = "vmaas" ServiceURL = "https://iac-vmaas.us1.greenlake-hpe.com" - LOCATION = "location" - SPACENAME = "space_name" - APIURL = "api_url" - INSECURE = "allow_insecure" - SpaceKey = "space" - LocationKey = "location" + LOCATION = "location" + SPACENAME = "space_name" + APIURL = "api_url" + INSECURE = "allow_insecure" + SpaceKey = "space" + WorkspaceKey = "workspaceID" + LocationKey = "location" MockIAMKey = "TF_ACC_MOCK_IAM" CmpSubjectKey = "TF_ACC_CMP_SUBJECT"