Skip to content

Commit

Permalink
chore: terraform
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Kulube committed Aug 23, 2023
1 parent ec9f35e commit b3d2367
Show file tree
Hide file tree
Showing 4 changed files with 162 additions and 138 deletions.
24 changes: 20 additions & 4 deletions projectv1/project_v1.go
Original file line number Diff line number Diff line change
Expand Up @@ -2586,7 +2586,7 @@ type ProjectConfigCanonical struct {
Setting *ProjectConfigSetting `json:"setting,omitempty"`

// The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.
ConfigID *string `json:"config_id,omitempty"`
ID *string `json:"id,omitempty"`

// The unique ID.
ProjectID *string `json:"project_id,omitempty"`
Expand All @@ -2606,6 +2606,14 @@ type ProjectConfigCanonical struct {
// The flag that indicates whether a configuration update is available.
UpdateAvailable *bool `json:"update_available,omitempty"`

// A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time
// format as specified by RFC 3339.
CreatedAt *strfmt.DateTime `json:"created_at,omitempty"`

// A date and time value in the format YYYY-MM-DDTHH:mm:ssZ or YYYY-MM-DDTHH:mm:ss.sssZ, matching the date and time
// format as specified by RFC 3339.
UpdatedAt *strfmt.DateTime `json:"updated_at,omitempty"`

// The last approved metadata of the configuration.
LastApproved *ProjectConfigMetadataLastApproved `json:"last_approved,omitempty"`

Expand Down Expand Up @@ -2701,7 +2709,7 @@ func UnmarshalProjectConfigCanonical(m map[string]json.RawMessage, result interf
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "config_id", &obj.ConfigID)
err = core.UnmarshalPrimitive(m, "id", &obj.ID)
if err != nil {
return
}
Expand Down Expand Up @@ -2729,6 +2737,14 @@ func UnmarshalProjectConfigCanonical(m map[string]json.RawMessage, result interf
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "created_at", &obj.CreatedAt)
if err != nil {
return
}
err = core.UnmarshalPrimitive(m, "updated_at", &obj.UpdatedAt)
if err != nil {
return
}
err = core.UnmarshalModel(m, "last_approved", &obj.LastApproved, UnmarshalProjectConfigMetadataLastApproved)
if err != nil {
return
Expand Down Expand Up @@ -2865,7 +2881,7 @@ func UnmarshalProjectConfigCanonicalDefinition(m map[string]json.RawMessage, res
// ProjectConfigCollectionMemberTerraform : The configuration metadata.
type ProjectConfigCollectionMemberTerraform struct {
// The ID of the configuration. If this parameter is empty, an ID is automatically created for the configuration.
ConfigID *string `json:"config_id,omitempty"`
ID *string `json:"id,omitempty"`

// The unique ID.
ProjectID *string `json:"project_id,omitempty"`
Expand Down Expand Up @@ -2927,7 +2943,7 @@ const (
// UnmarshalProjectConfigCollectionMemberTerraform unmarshals an instance of ProjectConfigCollectionMemberTerraform from the specified map of raw messages.
func UnmarshalProjectConfigCollectionMemberTerraform(m map[string]json.RawMessage, result interface{}) (err error) {
obj := new(ProjectConfigCollectionMemberTerraform)
err = core.UnmarshalPrimitive(m, "config_id", &obj.ConfigID)
err = core.UnmarshalPrimitive(m, "id", &obj.ID)
if err != nil {
return
}
Expand Down
104 changes: 54 additions & 50 deletions projectv1/project_v1_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {
config map[string]string

// Variables to hold link values
configIdLink string
projectIdLink string
)

Expand Down Expand Up @@ -138,6 +139,48 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {
projectIdLink = *projectCanonical.ID
fmt.Fprintf(GinkgoWriter, "Saved projectIdLink value: %v\n", projectIdLink)
})
It(`CreateConfig request example`, func() {
fmt.Println("\nCreateConfig() result:")
// begin-create_config

inputVariableModel := &projectv1.InputVariable{
}
inputVariableModel.SetProperty("account_id", core.StringPtr(`$configs[].name["account-stage"].input.account_id`))
inputVariableModel.SetProperty("resource_group", core.StringPtr("stage"))
inputVariableModel.SetProperty("access_tags", core.StringPtr(`["env:stage"]`))
inputVariableModel.SetProperty("logdna_name", core.StringPtr("Name of the LogDNA stage service instance"))
inputVariableModel.SetProperty("sysdig_name", core.StringPtr("Name of the SysDig stage service instance"))

projectConfigSettingModel := &projectv1.ProjectConfigSetting{
}
projectConfigSettingModel.SetProperty("IBMCLOUD_TOOLCHAIN_ENDPOINT", core.StringPtr("https://api.us-south.devops.dev.cloud.ibm.com"))

createConfigOptions := projectService.NewCreateConfigOptions(
projectIdLink,
)
createConfigOptions.SetName("env-stage")
createConfigOptions.SetDescription("Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace.")
createConfigOptions.SetLabels([]string{"env:stage", "governance:test", "build:0"})
createConfigOptions.SetLocatorID("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global")
createConfigOptions.SetInput(inputVariableModel)
createConfigOptions.SetSetting(projectConfigSettingModel)

projectConfigCanonical, response, err := projectService.CreateConfig(createConfigOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(projectConfigCanonical, "", " ")
fmt.Println(string(b))

// end-create_config

Expect(err).To(BeNil())
Expect(response.StatusCode).To(Equal(201))
Expect(projectConfigCanonical).ToNot(BeNil())

configIdLink = *projectConfigCanonical.ID
fmt.Fprintf(GinkgoWriter, "Saved configIdLink value: %v\n", configIdLink)
})
It(`ListProjects request example`, func() {
fmt.Println("\nListProjects() result:")
// begin-list_projects
Expand Down Expand Up @@ -206,45 +249,6 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {
Expect(response.StatusCode).To(Equal(200))
Expect(projectCanonical).ToNot(BeNil())
})
It(`CreateConfig request example`, func() {
fmt.Println("\nCreateConfig() result:")
// begin-create_config

inputVariableModel := &projectv1.InputVariable{
}
inputVariableModel.SetProperty("account_id", core.StringPtr(`$configs[].name["account-stage"].input.account_id`))
inputVariableModel.SetProperty("resource_group", core.StringPtr("stage"))
inputVariableModel.SetProperty("access_tags", core.StringPtr(`["env:stage"]`))
inputVariableModel.SetProperty("logdna_name", core.StringPtr("Name of the LogDNA stage service instance"))
inputVariableModel.SetProperty("sysdig_name", core.StringPtr("Name of the SysDig stage service instance"))

projectConfigSettingModel := &projectv1.ProjectConfigSetting{
}
projectConfigSettingModel.SetProperty("IBMCLOUD_TOOLCHAIN_ENDPOINT", core.StringPtr("https://api.us-south.devops.dev.cloud.ibm.com"))

createConfigOptions := projectService.NewCreateConfigOptions(
projectIdLink,
)
createConfigOptions.SetName("env-stage")
createConfigOptions.SetDescription("Stage environment configuration, which includes services common to all the environment regions. There must be a blueprint configuring all the services common to the stage regions. It is a terraform_template type of configuration that points to a Github repo hosting the terraform modules that can be deployed by a Schematics Workspace.")
createConfigOptions.SetLabels([]string{"env:stage", "governance:test", "build:0"})
createConfigOptions.SetLocatorID("1082e7d2-5e2f-0a11-a3bc-f88a8e1931fc.018edf04-e772-4ca2-9785-03e8e03bef72-global")
createConfigOptions.SetInput(inputVariableModel)
createConfigOptions.SetSetting(projectConfigSettingModel)

projectConfigCanonical, response, err := projectService.CreateConfig(createConfigOptions)
if err != nil {
panic(err)
}
b, _ := json.MarshalIndent(projectConfigCanonical, "", " ")
fmt.Println(string(b))

// end-create_config

Expect(err).To(BeNil())
Expect(response.StatusCode).To(Equal(201))
Expect(projectConfigCanonical).ToNot(BeNil())
})
It(`ListConfigs request example`, func() {
fmt.Println("\nListConfigs() result:")
// begin-list_configs
Expand Down Expand Up @@ -272,7 +276,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

getConfigOptions := projectService.NewGetConfigOptions(
projectIdLink,
"testString",
configIdLink,
)

projectConfigCanonical, response, err := projectService.GetConfig(getConfigOptions)
Expand Down Expand Up @@ -302,7 +306,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

updateConfigOptions := projectService.NewUpdateConfigOptions(
projectIdLink,
"testString",
configIdLink,
)
updateConfigOptions.SetInput(inputVariableModel)

Expand All @@ -325,7 +329,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

forceApproveOptions := projectService.NewForceApproveOptions(
projectIdLink,
"testString",
configIdLink,
)
forceApproveOptions.SetComment("Approving the changes")

Expand All @@ -348,7 +352,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

approveOptions := projectService.NewApproveOptions(
projectIdLink,
"testString",
configIdLink,
)
approveOptions.SetComment("Approving the changes")

Expand All @@ -371,7 +375,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

checkConfigOptions := projectService.NewCheckConfigOptions(
projectIdLink,
"testString",
configIdLink,
)

projectConfigVersionResponse, response, err := projectService.CheckConfig(checkConfigOptions)
Expand All @@ -393,7 +397,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

installConfigOptions := projectService.NewInstallConfigOptions(
projectIdLink,
"testString",
configIdLink,
)

projectConfigVersionResponse, response, err := projectService.InstallConfig(installConfigOptions)
Expand All @@ -414,7 +418,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

uninstallConfigOptions := projectService.NewUninstallConfigOptions(
projectIdLink,
"testString",
configIdLink,
)

response, err := projectService.UninstallConfig(uninstallConfigOptions)
Expand All @@ -436,7 +440,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

listConfigResourcesOptions := projectService.NewListConfigResourcesOptions(
projectIdLink,
"testString",
configIdLink,
)

projectConfigResourceCollection, response, err := projectService.ListConfigResources(listConfigResourcesOptions)
Expand All @@ -458,7 +462,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

listConfigVersionsOptions := projectService.NewListConfigVersionsOptions(
projectIdLink,
"testString",
configIdLink,
)

projectConfigVersionSummaryCollection, response, err := projectService.ListConfigVersions(listConfigVersionsOptions)
Expand All @@ -480,7 +484,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

getConfigVersionOptions := projectService.NewGetConfigVersionOptions(
projectIdLink,
"testString",
configIdLink,
int64(38),
)

Expand All @@ -503,7 +507,7 @@ var _ = Describe(`ProjectV1 Examples Tests`, func() {

deleteConfigOptions := projectService.NewDeleteConfigOptions(
projectIdLink,
"testString",
configIdLink,
)

projectConfigDelete, response, err := projectService.DeleteConfig(deleteConfigOptions)
Expand Down
Loading

0 comments on commit b3d2367

Please sign in to comment.