diff --git a/enterprisemanagementv1/enterprise_management_v1.go b/enterprisemanagementv1/enterprise_management_v1.go index 31df9444..86dbf1a2 100644 --- a/enterprisemanagementv1/enterprise_management_v1.go +++ b/enterprisemanagementv1/enterprise_management_v1.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2021, 2022. + * (C) Copyright IBM Corp. 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.60.2-95dc7721-20221102-203229 + * IBM OpenAPI SDK Code Generator Version: 3.64.1-cee95189-20230124-211647 */ // Package enterprisemanagementv1 : Operations and models for the EnterpriseManagementV1 service @@ -559,6 +559,9 @@ func (enterpriseManagement *EnterpriseManagementV1) CreateAccountWithContext(ctx if createAccountOptions.OwnerIamID != nil { body["owner_iam_id"] = createAccountOptions.OwnerIamID } + if createAccountOptions.Traits != nil { + body["traits"] = createAccountOptions.Traits + } _, err = builder.SetBodyContentJSON(body) if err != nil { return @@ -639,6 +642,9 @@ func (enterpriseManagement *EnterpriseManagementV1) ListAccountsWithContext(ctx if listAccountsOptions.Limit != nil { builder.AddQuery("limit", fmt.Sprint(*listAccountsOptions.Limit)) } + if listAccountsOptions.IncludeDeleted != nil { + builder.AddQuery("include_deleted", fmt.Sprint(*listAccountsOptions.IncludeDeleted)) + } request, err := builder.Build() if err != nil { @@ -780,6 +786,55 @@ func (enterpriseManagement *EnterpriseManagementV1) UpdateAccountWithContext(ctx return } +// DeleteAccount : Remove an account from its enterprise +// Remove an account from the enterprise its currently in. After an account is removed, it will be canceled and cannot +// be reactivated. +func (enterpriseManagement *EnterpriseManagementV1) DeleteAccount(deleteAccountOptions *DeleteAccountOptions) (response *core.DetailedResponse, err error) { + return enterpriseManagement.DeleteAccountWithContext(context.Background(), deleteAccountOptions) +} + +// DeleteAccountWithContext is an alternate form of the DeleteAccount method which supports a Context parameter +func (enterpriseManagement *EnterpriseManagementV1) DeleteAccountWithContext(ctx context.Context, deleteAccountOptions *DeleteAccountOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteAccountOptions, "deleteAccountOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteAccountOptions, "deleteAccountOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "account_id": *deleteAccountOptions.AccountID, + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = enterpriseManagement.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(enterpriseManagement.Service.Options.URL, `/accounts/{account_id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range deleteAccountOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("enterprise_management", "V1", "DeleteAccount") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + + request, err := builder.Build() + if err != nil { + return + } + + response, err = enterpriseManagement.Service.Request(request, nil) + + return +} + // CreateAccountGroup : Create an account group // Create a new account group, which can be used to group together multiple accounts. To create an account group, you // must have an existing enterprise. The API creates an account group entity under the parent that is specified in the @@ -909,6 +964,9 @@ func (enterpriseManagement *EnterpriseManagementV1) ListAccountGroupsWithContext if listAccountGroupsOptions.Limit != nil { builder.AddQuery("limit", fmt.Sprint(*listAccountGroupsOptions.Limit)) } + if listAccountGroupsOptions.IncludeDeleted != nil { + builder.AddQuery("include_deleted", fmt.Sprint(*listAccountGroupsOptions.IncludeDeleted)) + } request, err := builder.Build() if err != nil { @@ -1054,6 +1112,56 @@ func (enterpriseManagement *EnterpriseManagementV1) UpdateAccountGroupWithContex return } +// DeleteAccountGroup : Delete an account group from the enterprise +// Delete an existing account group from the enterprise. You can't delete an account group that has child account +// groups, the delete request will fail. This API doesn't perform a recursive delete on the child account groups, it +// only deletes the current account group. +func (enterpriseManagement *EnterpriseManagementV1) DeleteAccountGroup(deleteAccountGroupOptions *DeleteAccountGroupOptions) (response *core.DetailedResponse, err error) { + return enterpriseManagement.DeleteAccountGroupWithContext(context.Background(), deleteAccountGroupOptions) +} + +// DeleteAccountGroupWithContext is an alternate form of the DeleteAccountGroup method which supports a Context parameter +func (enterpriseManagement *EnterpriseManagementV1) DeleteAccountGroupWithContext(ctx context.Context, deleteAccountGroupOptions *DeleteAccountGroupOptions) (response *core.DetailedResponse, err error) { + err = core.ValidateNotNil(deleteAccountGroupOptions, "deleteAccountGroupOptions cannot be nil") + if err != nil { + return + } + err = core.ValidateStruct(deleteAccountGroupOptions, "deleteAccountGroupOptions") + if err != nil { + return + } + + pathParamsMap := map[string]string{ + "account_group_id": *deleteAccountGroupOptions.AccountGroupID, + } + + builder := core.NewRequestBuilder(core.DELETE) + builder = builder.WithContext(ctx) + builder.EnableGzipCompression = enterpriseManagement.GetEnableGzipCompression() + _, err = builder.ResolveRequestURL(enterpriseManagement.Service.Options.URL, `/account-groups/{account_group_id}`, pathParamsMap) + if err != nil { + return + } + + for headerName, headerValue := range deleteAccountGroupOptions.Headers { + builder.AddHeader(headerName, headerValue) + } + + sdkHeaders := common.GetSdkHeaders("enterprise_management", "V1", "DeleteAccountGroup") + for headerName, headerValue := range sdkHeaders { + builder.AddHeader(headerName, headerValue) + } + + request, err := builder.Build() + if err != nil { + return + } + + response, err = enterpriseManagement.Service.Request(request, nil) + + return +} + // Account : An account resource. type Account struct { // The URL of the account. @@ -1376,6 +1484,10 @@ type CreateAccountOptions struct { // The IAM ID of the account owner, such as `IBMid-0123ABC`. The IAM ID must already exist. OwnerIamID *string `json:"owner_iam_id" validate:"required"` + // The traits object can be used to opt-out of Multi-Factor Authentication setting when creating a child account in the + // enterprise. This is an optional field. + Traits map[string]interface{} `json:"traits,omitempty"` + // Allows users to set headers on API requests Headers map[string]string } @@ -1407,6 +1519,12 @@ func (_options *CreateAccountOptions) SetOwnerIamID(ownerIamID string) *CreateAc return _options } +// SetTraits : Allow user to set Traits +func (_options *CreateAccountOptions) SetTraits(traits map[string]interface{}) *CreateAccountOptions { + _options.Traits = traits + return _options +} + // SetHeaders : Allow user to set Headers func (options *CreateAccountOptions) SetHeaders(param map[string]string) *CreateAccountOptions { options.Headers = param @@ -1512,6 +1630,62 @@ func UnmarshalCreateEnterpriseResponse(m map[string]json.RawMessage, result inte return } +// DeleteAccountGroupOptions : The DeleteAccountGroup options. +type DeleteAccountGroupOptions struct { + // The ID of the account group to retrieve. + AccountGroupID *string `json:"account_group_id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteAccountGroupOptions : Instantiate DeleteAccountGroupOptions +func (*EnterpriseManagementV1) NewDeleteAccountGroupOptions(accountGroupID string) *DeleteAccountGroupOptions { + return &DeleteAccountGroupOptions{ + AccountGroupID: core.StringPtr(accountGroupID), + } +} + +// SetAccountGroupID : Allow user to set AccountGroupID +func (_options *DeleteAccountGroupOptions) SetAccountGroupID(accountGroupID string) *DeleteAccountGroupOptions { + _options.AccountGroupID = core.StringPtr(accountGroupID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteAccountGroupOptions) SetHeaders(param map[string]string) *DeleteAccountGroupOptions { + options.Headers = param + return options +} + +// DeleteAccountOptions : The DeleteAccount options. +type DeleteAccountOptions struct { + // The ID of the target account. + AccountID *string `json:"account_id" validate:"required,ne="` + + // Allows users to set headers on API requests + Headers map[string]string +} + +// NewDeleteAccountOptions : Instantiate DeleteAccountOptions +func (*EnterpriseManagementV1) NewDeleteAccountOptions(accountID string) *DeleteAccountOptions { + return &DeleteAccountOptions{ + AccountID: core.StringPtr(accountID), + } +} + +// SetAccountID : Allow user to set AccountID +func (_options *DeleteAccountOptions) SetAccountID(accountID string) *DeleteAccountOptions { + _options.AccountID = core.StringPtr(accountID) + return _options +} + +// SetHeaders : Allow user to set Headers +func (options *DeleteAccountOptions) SetHeaders(param map[string]string) *DeleteAccountOptions { + options.Headers = param + return options +} + // Enterprise : An enterprise resource. type Enterprise struct { // The URL of the enterprise. @@ -1643,7 +1817,7 @@ func (options *GetAccountGroupOptions) SetHeaders(param map[string]string) *GetA // GetAccountOptions : The GetAccount options. type GetAccountOptions struct { - // The ID of the account to retrieve. + // The ID of the target account. AccountID *string `json:"account_id" validate:"required,ne="` // Allows users to set headers on API requests @@ -1773,6 +1947,9 @@ type ListAccountGroupsOptions struct { // Return results up to this limit. Valid values are between `0` and `100`. Limit *int64 `json:"limit,omitempty"` + // Include the deleted account groups from an enterprise when used in conjunction with other query parameters. + IncludeDeleted *bool `json:"include_deleted,omitempty"` + // Allows users to set headers on API requests Headers map[string]string } @@ -1812,6 +1989,12 @@ func (_options *ListAccountGroupsOptions) SetLimit(limit int64) *ListAccountGrou return _options } +// SetIncludeDeleted : Allow user to set IncludeDeleted +func (_options *ListAccountGroupsOptions) SetIncludeDeleted(includeDeleted bool) *ListAccountGroupsOptions { + _options.IncludeDeleted = core.BoolPtr(includeDeleted) + return _options +} + // SetHeaders : Allow user to set Headers func (options *ListAccountGroupsOptions) SetHeaders(param map[string]string) *ListAccountGroupsOptions { options.Headers = param @@ -1879,6 +2062,9 @@ type ListAccountsOptions struct { // Return results up to this limit. Valid values are between `0` and `100`. Limit *int64 `json:"limit,omitempty"` + // Include the deleted accounts from an enterprise when used in conjunction with enterprise_id. + IncludeDeleted *bool `json:"include_deleted,omitempty"` + // Allows users to set headers on API requests Headers map[string]string } @@ -1918,6 +2104,12 @@ func (_options *ListAccountsOptions) SetLimit(limit int64) *ListAccountsOptions return _options } +// SetIncludeDeleted : Allow user to set IncludeDeleted +func (_options *ListAccountsOptions) SetIncludeDeleted(includeDeleted bool) *ListAccountsOptions { + _options.IncludeDeleted = core.BoolPtr(includeDeleted) + return _options +} + // SetHeaders : Allow user to set Headers func (options *ListAccountsOptions) SetHeaders(param map[string]string) *ListAccountsOptions { options.Headers = param @@ -2121,7 +2313,7 @@ func (options *UpdateAccountGroupOptions) SetHeaders(param map[string]string) *U // UpdateAccountOptions : The UpdateAccount options. type UpdateAccountOptions struct { - // The ID of the account to retrieve. + // The ID of the target account. AccountID *string `json:"account_id" validate:"required,ne="` // The CRN of the new parent within the enterprise. @@ -2212,9 +2404,7 @@ func (options *UpdateEnterpriseOptions) SetHeaders(param map[string]string) *Upd return options } -// // EnterprisesPager can be used to simplify the use of the "ListEnterprises" method. -// type EnterprisesPager struct { hasNext bool options *ListEnterprisesOptions @@ -2299,9 +2489,7 @@ func (pager *EnterprisesPager) GetAll() (allItems []Enterprise, err error) { return pager.GetAllWithContext(context.Background()) } -// // AccountsPager can be used to simplify the use of the "ListAccounts" method. -// type AccountsPager struct { hasNext bool options *ListAccountsOptions @@ -2386,9 +2574,7 @@ func (pager *AccountsPager) GetAll() (allItems []Account, err error) { return pager.GetAllWithContext(context.Background()) } -// // AccountGroupsPager can be used to simplify the use of the "ListAccountGroups" method. -// type AccountGroupsPager struct { hasNext bool options *ListAccountGroupsOptions diff --git a/enterprisemanagementv1/enterprise_management_v1_examples_test.go b/enterprisemanagementv1/enterprise_management_v1_examples_test.go index 46fce269..77f7591a 100644 --- a/enterprisemanagementv1/enterprise_management_v1_examples_test.go +++ b/enterprisemanagementv1/enterprise_management_v1_examples_test.go @@ -236,6 +236,23 @@ var _ = Describe(`EnterpriseManagementV1 Examples Tests`, func() { fmt.Printf("\nUpdateAccountGroup() response status code: %d\n", response.StatusCode) Expect(response.StatusCode).To(Equal(204)) }) + It(`DeleteAccountGroup request example`, func() { + // begin-delete_account_group + deleteAccountGroupOptions := enterpriseManagementService.NewDeleteAccountGroupOptions( + accountGroupID, + ) + + response, err := enterpriseManagementService.DeleteAccountGroup(deleteAccountGroupOptions) + if err != nil { + panic(err) + } + + // end-delete_account_group + + Expect(err).To(BeNil()) + fmt.Printf("\nDeleteAccountGroup() response status code: %d\n", response.StatusCode) + Expect(response.StatusCode).To(Equal(204)) + }) It(`ImportAccountToEnterprise request example`, func() { Skip("Skip by design") importAccountID := "" @@ -349,6 +366,25 @@ var _ = Describe(`EnterpriseManagementV1 Examples Tests`, func() { fmt.Printf("\nUpdateAccount() response status code: %d\n", response.StatusCode) Expect(response.StatusCode).To(Equal(202)) }) + It(`DeleteAccount request example`, func() { + fmt.Println("\nDeleteAccount() result:") + // begin-delete_account + + deleteAccountOptions := enterpriseManagementService.NewDeleteAccountOptions( + accountID, + ) + + response, err := enterpriseManagementService.DeleteAccount(deleteAccountOptions) + if err != nil { + panic(err) + } + + // end-delete_account + + Expect(err).To(BeNil()) + fmt.Printf("\nDeleteAccount() response status code: %d\n", response.StatusCode) + Expect(response.StatusCode).To(Equal(204)) + }) It(`CreateEnterprise request example`, func() { Skip("Skip by design") diff --git a/enterprisemanagementv1/enterprise_management_v1_integration_test.go b/enterprisemanagementv1/enterprise_management_v1_integration_test.go index 50c57c7c..e20e0364 100644 --- a/enterprisemanagementv1/enterprise_management_v1_integration_test.go +++ b/enterprisemanagementv1/enterprise_management_v1_integration_test.go @@ -284,6 +284,24 @@ var _ = Describe(`EnterpriseManagementV1 Integration Tests`, func() { }) }) + Describe(`DeleteAccountGroup - Delete an account group from the enterprise`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteAccountGroup(deleteAccountGroupOptions *DeleteAccountGroupOptions)`, func() { + + deleteAccountGroupOptions := &enterprisemanagementv1.DeleteAccountGroupOptions{ + AccountGroupID: &accountGroupID, + } + + response, err := enterpriseManagementService.DeleteAccountGroup(deleteAccountGroupOptions) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + + }) + }) + Describe(`CreateAccount - Create a new account in an enterprise`, func() { BeforeEach(func() { shouldSkipTest() @@ -423,6 +441,24 @@ var _ = Describe(`EnterpriseManagementV1 Integration Tests`, func() { }) }) + Describe(`DeleteAccount - Remove an account from its enterprise`, func() { + BeforeEach(func() { + shouldSkipTest() + }) + It(`DeleteAccount(deleteAccountOptions *DeleteAccountOptions)`, func() { + + deleteAccountOptions := &enterprisemanagementv1.DeleteAccountOptions{ + AccountID: &exampleAccountID, + } + + response, err := enterpriseManagementService.DeleteAccount(deleteAccountOptions) + + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(204)) + + }) + }) + Describe(`ListEnterprises - List enterprises`, func() { BeforeEach(func() { shouldSkipTest() diff --git a/enterprisemanagementv1/enterprise_management_v1_suite_test.go b/enterprisemanagementv1/enterprise_management_v1_suite_test.go index 4fef3b17..8cf2bc14 100644 --- a/enterprisemanagementv1/enterprise_management_v1_suite_test.go +++ b/enterprisemanagementv1/enterprise_management_v1_suite_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2021. + * (C) Copyright IBM Corp. 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/enterprisemanagementv1/enterprise_management_v1_test.go b/enterprisemanagementv1/enterprise_management_v1_test.go index 05c86da5..2e1ee17a 100644 --- a/enterprisemanagementv1/enterprise_management_v1_test.go +++ b/enterprisemanagementv1/enterprise_management_v1_test.go @@ -1,5 +1,5 @@ /** - * (C) Copyright IBM Corp. 2022. + * (C) Copyright IBM Corp. 2023. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -1183,6 +1183,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { createAccountOptionsModel.Parent = core.StringPtr("testString") createAccountOptionsModel.Name = core.StringPtr("testString") createAccountOptionsModel.OwnerIamID = core.StringPtr("testString") + createAccountOptionsModel.Traits = map[string]interface{}{"anyKey": "anyValue"} createAccountOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := enterpriseManagementService.CreateAccount(createAccountOptionsModel) @@ -1252,6 +1253,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { createAccountOptionsModel.Parent = core.StringPtr("testString") createAccountOptionsModel.Name = core.StringPtr("testString") createAccountOptionsModel.OwnerIamID = core.StringPtr("testString") + createAccountOptionsModel.Traits = map[string]interface{}{"anyKey": "anyValue"} createAccountOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -1329,6 +1331,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { createAccountOptionsModel.Parent = core.StringPtr("testString") createAccountOptionsModel.Name = core.StringPtr("testString") createAccountOptionsModel.OwnerIamID = core.StringPtr("testString") + createAccountOptionsModel.Traits = map[string]interface{}{"anyKey": "anyValue"} createAccountOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -1351,6 +1354,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { createAccountOptionsModel.Parent = core.StringPtr("testString") createAccountOptionsModel.Name = core.StringPtr("testString") createAccountOptionsModel.OwnerIamID = core.StringPtr("testString") + createAccountOptionsModel.Traits = map[string]interface{}{"anyKey": "anyValue"} createAccountOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := enterpriseManagementService.SetServiceURL("") @@ -1394,6 +1398,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { createAccountOptionsModel.Parent = core.StringPtr("testString") createAccountOptionsModel.Name = core.StringPtr("testString") createAccountOptionsModel.OwnerIamID = core.StringPtr("testString") + createAccountOptionsModel.Traits = map[string]interface{}{"anyKey": "anyValue"} createAccountOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -1424,6 +1429,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { Expect(req.URL.Query()["next_docid"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["parent"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + // TODO: Add check for include_deleted query parameter res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) @@ -1444,6 +1450,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountsOptionsModel.NextDocid = core.StringPtr("testString") listAccountsOptionsModel.Parent = core.StringPtr("testString") listAccountsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := enterpriseManagementService.ListAccounts(listAccountsOptionsModel) @@ -1479,6 +1486,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { Expect(req.URL.Query()["next_docid"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["parent"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + // TODO: Add check for include_deleted query parameter // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -1504,6 +1512,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountsOptionsModel.NextDocid = core.StringPtr("testString") listAccountsOptionsModel.Parent = core.StringPtr("testString") listAccountsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -1545,6 +1554,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { Expect(req.URL.Query()["next_docid"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["parent"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + // TODO: Add check for include_deleted query parameter // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) @@ -1572,6 +1582,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountsOptionsModel.NextDocid = core.StringPtr("testString") listAccountsOptionsModel.Parent = core.StringPtr("testString") listAccountsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -1596,6 +1607,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountsOptionsModel.NextDocid = core.StringPtr("testString") listAccountsOptionsModel.Parent = core.StringPtr("testString") listAccountsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := enterpriseManagementService.SetServiceURL("") @@ -1634,6 +1646,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountsOptionsModel.NextDocid = core.StringPtr("testString") listAccountsOptionsModel.Parent = core.StringPtr("testString") listAccountsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -1709,6 +1722,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { AccountGroupID: core.StringPtr("testString"), Parent: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), + IncludeDeleted: core.BoolPtr(true), } pager, err := enterpriseManagementService.NewAccountsPager(listAccountsOptionsModel) @@ -1737,6 +1751,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { AccountGroupID: core.StringPtr("testString"), Parent: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), + IncludeDeleted: core.BoolPtr(true), } pager, err := enterpriseManagementService.NewAccountsPager(listAccountsOptionsModel) @@ -2048,6 +2063,74 @@ var _ = Describe(`EnterpriseManagementV1`, func() { }) }) }) + Describe(`DeleteAccount(deleteAccountOptions *DeleteAccountOptions)`, func() { + deleteAccountPath := "/accounts/testString" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteAccountPath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteAccount successfully`, func() { + enterpriseManagementService, serviceErr := enterprisemanagementv1.NewEnterpriseManagementV1(&enterprisemanagementv1.EnterpriseManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(enterpriseManagementService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := enterpriseManagementService.DeleteAccount(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteAccountOptions model + deleteAccountOptionsModel := new(enterprisemanagementv1.DeleteAccountOptions) + deleteAccountOptionsModel.AccountID = core.StringPtr("testString") + deleteAccountOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = enterpriseManagementService.DeleteAccount(deleteAccountOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteAccount with error: Operation validation and request error`, func() { + enterpriseManagementService, serviceErr := enterprisemanagementv1.NewEnterpriseManagementV1(&enterprisemanagementv1.EnterpriseManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(enterpriseManagementService).ToNot(BeNil()) + + // Construct an instance of the DeleteAccountOptions model + deleteAccountOptionsModel := new(enterprisemanagementv1.DeleteAccountOptions) + deleteAccountOptionsModel.AccountID = core.StringPtr("testString") + deleteAccountOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := enterpriseManagementService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := enterpriseManagementService.DeleteAccount(deleteAccountOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteAccountOptions model with no property values + deleteAccountOptionsModelNew := new(enterprisemanagementv1.DeleteAccountOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = enterpriseManagementService.DeleteAccount(deleteAccountOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`CreateAccountGroup(createAccountGroupOptions *CreateAccountGroupOptions) - Operation response error`, func() { createAccountGroupPath := "/account-groups" Context(`Using mock server endpoint with invalid JSON response`, func() { @@ -2317,6 +2400,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { Expect(req.URL.Query()["next_docid"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["parent"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + // TODO: Add check for include_deleted query parameter res.Header().Set("Content-type", "application/json") res.WriteHeader(200) fmt.Fprint(res, `} this is not valid json {`) @@ -2337,6 +2421,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountGroupsOptionsModel.NextDocid = core.StringPtr("testString") listAccountGroupsOptionsModel.Parent = core.StringPtr("testString") listAccountGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountGroupsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Expect response parsing to fail since we are receiving a text/plain response result, response, operationErr := enterpriseManagementService.ListAccountGroups(listAccountGroupsOptionsModel) @@ -2372,6 +2457,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { Expect(req.URL.Query()["next_docid"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["parent"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + // TODO: Add check for include_deleted query parameter // Sleep a short time to support a timeout test time.Sleep(100 * time.Millisecond) @@ -2397,6 +2483,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountGroupsOptionsModel.NextDocid = core.StringPtr("testString") listAccountGroupsOptionsModel.Parent = core.StringPtr("testString") listAccountGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountGroupsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with a Context to test a timeout error @@ -2438,6 +2525,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { Expect(req.URL.Query()["next_docid"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["parent"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + // TODO: Add check for include_deleted query parameter // Set mock response res.Header().Set("Content-type", "application/json") res.WriteHeader(200) @@ -2465,6 +2553,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountGroupsOptionsModel.NextDocid = core.StringPtr("testString") listAccountGroupsOptionsModel.Parent = core.StringPtr("testString") listAccountGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountGroupsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with valid options model (positive test) @@ -2489,6 +2578,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountGroupsOptionsModel.NextDocid = core.StringPtr("testString") listAccountGroupsOptionsModel.Parent = core.StringPtr("testString") listAccountGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountGroupsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation with empty URL (negative test) err := enterpriseManagementService.SetServiceURL("") @@ -2527,6 +2617,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountGroupsOptionsModel.NextDocid = core.StringPtr("testString") listAccountGroupsOptionsModel.Parent = core.StringPtr("testString") listAccountGroupsOptionsModel.Limit = core.Int64Ptr(int64(10)) + listAccountGroupsOptionsModel.IncludeDeleted = core.BoolPtr(true) listAccountGroupsOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} // Invoke operation @@ -2602,6 +2693,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { ParentAccountGroupID: core.StringPtr("testString"), Parent: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), + IncludeDeleted: core.BoolPtr(true), } pager, err := enterpriseManagementService.NewAccountGroupsPager(listAccountGroupsOptionsModel) @@ -2630,6 +2722,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { ParentAccountGroupID: core.StringPtr("testString"), Parent: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), + IncludeDeleted: core.BoolPtr(true), } pager, err := enterpriseManagementService.NewAccountGroupsPager(listAccountGroupsOptionsModel) @@ -2943,6 +3036,74 @@ var _ = Describe(`EnterpriseManagementV1`, func() { }) }) }) + Describe(`DeleteAccountGroup(deleteAccountGroupOptions *DeleteAccountGroupOptions)`, func() { + deleteAccountGroupPath := "/account-groups/testString" + Context(`Using mock server endpoint`, func() { + BeforeEach(func() { + testServer = httptest.NewServer(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) { + defer GinkgoRecover() + + // Verify the contents of the request + Expect(req.URL.EscapedPath()).To(Equal(deleteAccountGroupPath)) + Expect(req.Method).To(Equal("DELETE")) + + res.WriteHeader(204) + })) + }) + It(`Invoke DeleteAccountGroup successfully`, func() { + enterpriseManagementService, serviceErr := enterprisemanagementv1.NewEnterpriseManagementV1(&enterprisemanagementv1.EnterpriseManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(enterpriseManagementService).ToNot(BeNil()) + + // Invoke operation with nil options model (negative test) + response, operationErr := enterpriseManagementService.DeleteAccountGroup(nil) + Expect(operationErr).NotTo(BeNil()) + Expect(response).To(BeNil()) + + // Construct an instance of the DeleteAccountGroupOptions model + deleteAccountGroupOptionsModel := new(enterprisemanagementv1.DeleteAccountGroupOptions) + deleteAccountGroupOptionsModel.AccountGroupID = core.StringPtr("testString") + deleteAccountGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + + // Invoke operation with valid options model (positive test) + response, operationErr = enterpriseManagementService.DeleteAccountGroup(deleteAccountGroupOptionsModel) + Expect(operationErr).To(BeNil()) + Expect(response).ToNot(BeNil()) + }) + It(`Invoke DeleteAccountGroup with error: Operation validation and request error`, func() { + enterpriseManagementService, serviceErr := enterprisemanagementv1.NewEnterpriseManagementV1(&enterprisemanagementv1.EnterpriseManagementV1Options{ + URL: testServer.URL, + Authenticator: &core.NoAuthAuthenticator{}, + }) + Expect(serviceErr).To(BeNil()) + Expect(enterpriseManagementService).ToNot(BeNil()) + + // Construct an instance of the DeleteAccountGroupOptions model + deleteAccountGroupOptionsModel := new(enterprisemanagementv1.DeleteAccountGroupOptions) + deleteAccountGroupOptionsModel.AccountGroupID = core.StringPtr("testString") + deleteAccountGroupOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} + // Invoke operation with empty URL (negative test) + err := enterpriseManagementService.SetServiceURL("") + Expect(err).To(BeNil()) + response, operationErr := enterpriseManagementService.DeleteAccountGroup(deleteAccountGroupOptionsModel) + Expect(operationErr).ToNot(BeNil()) + Expect(operationErr.Error()).To(ContainSubstring(core.ERRORMSG_SERVICE_URL_MISSING)) + Expect(response).To(BeNil()) + // Construct a second instance of the DeleteAccountGroupOptions model with no property values + deleteAccountGroupOptionsModelNew := new(enterprisemanagementv1.DeleteAccountGroupOptions) + // Invoke operation with invalid model (negative test) + response, operationErr = enterpriseManagementService.DeleteAccountGroup(deleteAccountGroupOptionsModelNew) + Expect(operationErr).ToNot(BeNil()) + Expect(response).To(BeNil()) + }) + AfterEach(func() { + testServer.Close() + }) + }) + }) Describe(`Model constructor tests`, func() { Context(`Using a service client instance`, func() { enterpriseManagementService, _ := enterprisemanagementv1.NewEnterpriseManagementV1(&enterprisemanagementv1.EnterpriseManagementV1Options{ @@ -2974,11 +3135,13 @@ var _ = Describe(`EnterpriseManagementV1`, func() { createAccountOptionsModel.SetParent("testString") createAccountOptionsModel.SetName("testString") createAccountOptionsModel.SetOwnerIamID("testString") + createAccountOptionsModel.SetTraits(map[string]interface{}{"anyKey": "anyValue"}) createAccountOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(createAccountOptionsModel).ToNot(BeNil()) Expect(createAccountOptionsModel.Parent).To(Equal(core.StringPtr("testString"))) Expect(createAccountOptionsModel.Name).To(Equal(core.StringPtr("testString"))) Expect(createAccountOptionsModel.OwnerIamID).To(Equal(core.StringPtr("testString"))) + Expect(createAccountOptionsModel.Traits).To(Equal(map[string]interface{}{"anyKey": "anyValue"})) Expect(createAccountOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewCreateEnterpriseOptions successfully`, func() { @@ -2999,6 +3162,26 @@ var _ = Describe(`EnterpriseManagementV1`, func() { Expect(createEnterpriseOptionsModel.Domain).To(Equal(core.StringPtr("testString"))) Expect(createEnterpriseOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) + It(`Invoke NewDeleteAccountGroupOptions successfully`, func() { + // Construct an instance of the DeleteAccountGroupOptions model + accountGroupID := "testString" + deleteAccountGroupOptionsModel := enterpriseManagementService.NewDeleteAccountGroupOptions(accountGroupID) + deleteAccountGroupOptionsModel.SetAccountGroupID("testString") + deleteAccountGroupOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteAccountGroupOptionsModel).ToNot(BeNil()) + Expect(deleteAccountGroupOptionsModel.AccountGroupID).To(Equal(core.StringPtr("testString"))) + Expect(deleteAccountGroupOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) + It(`Invoke NewDeleteAccountOptions successfully`, func() { + // Construct an instance of the DeleteAccountOptions model + accountID := "testString" + deleteAccountOptionsModel := enterpriseManagementService.NewDeleteAccountOptions(accountID) + deleteAccountOptionsModel.SetAccountID("testString") + deleteAccountOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) + Expect(deleteAccountOptionsModel).ToNot(BeNil()) + Expect(deleteAccountOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) + Expect(deleteAccountOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) + }) It(`Invoke NewGetAccountGroupOptions successfully`, func() { // Construct an instance of the GetAccountGroupOptions model accountGroupID := "testString" @@ -3054,6 +3237,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountGroupsOptionsModel.SetNextDocid("testString") listAccountGroupsOptionsModel.SetParent("testString") listAccountGroupsOptionsModel.SetLimit(int64(10)) + listAccountGroupsOptionsModel.SetIncludeDeleted(true) listAccountGroupsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listAccountGroupsOptionsModel).ToNot(BeNil()) Expect(listAccountGroupsOptionsModel.EnterpriseID).To(Equal(core.StringPtr("testString"))) @@ -3061,6 +3245,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { Expect(listAccountGroupsOptionsModel.NextDocid).To(Equal(core.StringPtr("testString"))) Expect(listAccountGroupsOptionsModel.Parent).To(Equal(core.StringPtr("testString"))) Expect(listAccountGroupsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(10)))) + Expect(listAccountGroupsOptionsModel.IncludeDeleted).To(Equal(core.BoolPtr(true))) Expect(listAccountGroupsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListAccountsOptions successfully`, func() { @@ -3071,6 +3256,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { listAccountsOptionsModel.SetNextDocid("testString") listAccountsOptionsModel.SetParent("testString") listAccountsOptionsModel.SetLimit(int64(10)) + listAccountsOptionsModel.SetIncludeDeleted(true) listAccountsOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listAccountsOptionsModel).ToNot(BeNil()) Expect(listAccountsOptionsModel.EnterpriseID).To(Equal(core.StringPtr("testString"))) @@ -3078,6 +3264,7 @@ var _ = Describe(`EnterpriseManagementV1`, func() { Expect(listAccountsOptionsModel.NextDocid).To(Equal(core.StringPtr("testString"))) Expect(listAccountsOptionsModel.Parent).To(Equal(core.StringPtr("testString"))) Expect(listAccountsOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(10)))) + Expect(listAccountsOptionsModel.IncludeDeleted).To(Equal(core.BoolPtr(true))) Expect(listAccountsOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"})) }) It(`Invoke NewListEnterprisesOptions successfully`, func() {