Skip to content

Commit

Permalink
feat(EnterpriseManagementv1): re-gen service after recent API changes (
Browse files Browse the repository at this point in the history
…#237)

* feat(EnterpriseManagementv1): re-gen service after recent API changes

Signed-off-by: namrata <namrta.bhadauriya@ibm.com>
  • Loading branch information
namratabhadauriya authored Apr 21, 2023
1 parent 6e5c440 commit 5efc6b6
Show file tree
Hide file tree
Showing 5 changed files with 457 additions and 12 deletions.
206 changes: 196 additions & 10 deletions enterprisemanagementv1/enterprise_management_v1.go
Original file line number Diff line number Diff line change
@@ -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.
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions enterprisemanagementv1/enterprise_management_v1_examples_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 := "<accountid_to_be_imported>"
Expand Down Expand Up @@ -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")

Expand Down
Loading

0 comments on commit 5efc6b6

Please sign in to comment.