diff --git a/usermanagementv1/user_management_v1.go b/usermanagementv1/user_management_v1.go index 258a9e23..57e1e371 100644 --- a/usermanagementv1/user_management_v1.go +++ b/usermanagementv1/user_management_v1.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. @@ -15,7 +15,7 @@ */ /* - * IBM OpenAPI SDK Code Generator Version: 3.60.2-95dc7721-20221102-203229 + * IBM OpenAPI SDK Code Generator Version: 3.70.0-7df966bf-20230419-195904 */ // Package usermanagementv1 : Operations and models for the UserManagementV1 service @@ -28,7 +28,6 @@ import ( "net/http" "reflect" "time" - "github.com/IBM/go-sdk-core/v5/core" common "github.com/IBM/platform-services-go-sdk/common" ) @@ -166,7 +165,8 @@ func (userManagement *UserManagementV1) DisableRetries() { // role. If restricted view is enabled and user has the viewer, editor, or administrator role on the user management // service, the API returns all users in the account. If unrestricted view is enabled and the user does not have these // roles, the API returns only the current user. Users are returned in a paginated list with a default limit of 100 -// users. You can iterate through all users by following the `next_url` field. +// users. You can iterate through all users by following the `next_url` field. Additional substring search fields are +// supported to filter the users. func (userManagement *UserManagementV1) ListUsers(listUsersOptions *ListUsersOptions) (result *UserList, response *core.DetailedResponse, err error) { return userManagement.ListUsersWithContext(context.Background(), listUsersOptions) } @@ -207,6 +207,12 @@ func (userManagement *UserManagementV1) ListUsersWithContext(ctx context.Context if listUsersOptions.Limit != nil { builder.AddQuery("limit", fmt.Sprint(*listUsersOptions.Limit)) } + if listUsersOptions.IncludeSettings != nil { + builder.AddQuery("include_settings", fmt.Sprint(*listUsersOptions.IncludeSettings)) + } + if listUsersOptions.Search != nil { + builder.AddQuery("search", fmt.Sprint(*listUsersOptions.Search)) + } if listUsersOptions.Start != nil { builder.AddQuery("_start", fmt.Sprint(*listUsersOptions.Start)) } @@ -994,6 +1000,16 @@ type ListUsersOptions struct { // The number of results to be returned. Limit *int64 `json:"limit,omitempty"` + // The user settings to be returned. Set to true to view language, allowed IP address, and authentication settings. + IncludeSettings *bool `json:"include_settings,omitempty"` + + // The desired search results to be returned. To view the list of users with the additional search filter, use the + // following query options: `firstname`, `lastname`, `email`, `state`, `substate`, `iam_id`, `realm`, and `userId`. + // HTML URL encoding for the search query and `:` must be used. For example, search=state%3AINVALID returns a list of + // invalid users. Multiple search queries can be combined to obtain `OR` results using `,` operator (not URL encoded). + // For example, search=state%3AINVALID,email%3Amail.test.ibm.com. + Search *string `json:"search,omitempty"` + // An optional token that indicates the beginning of the page of results to be returned. If omitted, the first page of // results is returned. This value is obtained from the 'next_url' field of the operation response. Start *string `json:"_start,omitempty"` @@ -1024,6 +1040,18 @@ func (_options *ListUsersOptions) SetLimit(limit int64) *ListUsersOptions { return _options } +// SetIncludeSettings : Allow user to set IncludeSettings +func (_options *ListUsersOptions) SetIncludeSettings(includeSettings bool) *ListUsersOptions { + _options.IncludeSettings = core.BoolPtr(includeSettings) + return _options +} + +// SetSearch : Allow user to set Search +func (_options *ListUsersOptions) SetSearch(search string) *ListUsersOptions { + _options.Search = core.StringPtr(search) + return _options +} + // SetStart : Allow user to set Start func (_options *ListUsersOptions) SetStart(start string) *ListUsersOptions { _options.Start = core.StringPtr(start) diff --git a/usermanagementv1/user_management_v1_examples_test.go b/usermanagementv1/user_management_v1_examples_test.go index 1ed03c6d..7cc39d9f 100644 --- a/usermanagementv1/user_management_v1_examples_test.go +++ b/usermanagementv1/user_management_v1_examples_test.go @@ -27,8 +27,6 @@ import ( "github.com/IBM/go-sdk-core/v5/core" "github.com/IBM/platform-services-go-sdk/usermanagementv1" - . "github.com/onsi/ginkgo" - . "github.com/onsi/gomega" ) var _ = Describe(`UserManagementV1 Examples Tests`, func() { @@ -212,6 +210,56 @@ var _ = Describe(`UserManagementV1 Examples Tests`, func() { fmt.Println(string(b)) // end-list_users }) + It(`ListUsers request include_settings example`, func() { + fmt.Println("\nListUsers() include_settings result:") + // begin-list_users include_settings + listUsersOptions := &usermanagementv1.ListUsersOptions{ + AccountID: &accountID, + IncludeSettings: "true", + } + + pager, err := userManagementService.NewUsersPager(listUsersOptions) + if err != nil { + panic(err) + } + + var allResults []usermanagementv1.UserProfile + for pager.HasNext() { + nextPage, err := pager.GetNext() + if err != nil { + panic(err) + } + allResults = append(allResults, nextPage...) + } + b, _ := json.MarshalIndent(allResults, "", " ") + fmt.Println(string(b)) + // end-list_users include_settings + }) + It(`ListUsers request search example`, func() { + fmt.Println("\nListUsers() search result:") + // begin-list_users search + listUsersOptions := &usermanagementv1.ListUsersOptions{ + AccountID: &accountID, + Search: "state%3AACTIVE", + } + + pager, err := userManagementService.NewUsersPager(listUsersOptions) + if err != nil { + panic(err) + } + + var allResults []usermanagementv1.UserProfile + for pager.HasNext() { + nextPage, err := pager.GetNext() + if err != nil { + panic(err) + } + allResults = append(allResults, nextPage...) + } + b, _ := json.MarshalIndent(allResults, "", " ") + fmt.Println(string(b)) + // end-list_users search + }) It(`RemoveUser request example`, func() { Expect(accountID).ToNot(BeEmpty()) Expect(deleteUserID).ToNot(BeEmpty()) diff --git a/usermanagementv1/user_management_v1_suite_test.go b/usermanagementv1/user_management_v1_suite_test.go index da47b802..e2f4006f 100644 --- a/usermanagementv1/user_management_v1_suite_test.go +++ b/usermanagementv1/user_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/usermanagementv1/user_management_v1_test.go b/usermanagementv1/user_management_v1_test.go index 5b96bcc8..e9bae410 100644 --- a/usermanagementv1/user_management_v1_test.go +++ b/usermanagementv1/user_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. @@ -174,6 +174,8 @@ var _ = Describe(`UserManagementV1`, func() { Expect(req.URL.EscapedPath()).To(Equal(listUsersPath)) Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + // TODO: Add check for include_settings query parameter + Expect(req.URL.Query()["search"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["_start"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["user_id"]).To(Equal([]string{"testString"})) res.Header().Set("Content-type", "application/json") @@ -193,6 +195,8 @@ var _ = Describe(`UserManagementV1`, func() { listUsersOptionsModel := new(usermanagementv1.ListUsersOptions) listUsersOptionsModel.AccountID = core.StringPtr("testString") listUsersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listUsersOptionsModel.IncludeSettings = core.BoolPtr(true) + listUsersOptionsModel.Search = core.StringPtr("testString") listUsersOptionsModel.Start = core.StringPtr("testString") listUsersOptionsModel.UserID = core.StringPtr("testString") listUsersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -226,6 +230,8 @@ var _ = Describe(`UserManagementV1`, func() { Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + // TODO: Add check for include_settings query parameter + Expect(req.URL.Query()["search"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["_start"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["user_id"]).To(Equal([]string{"testString"})) // Sleep a short time to support a timeout test @@ -250,6 +256,8 @@ var _ = Describe(`UserManagementV1`, func() { listUsersOptionsModel := new(usermanagementv1.ListUsersOptions) listUsersOptionsModel.AccountID = core.StringPtr("testString") listUsersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listUsersOptionsModel.IncludeSettings = core.BoolPtr(true) + listUsersOptionsModel.Search = core.StringPtr("testString") listUsersOptionsModel.Start = core.StringPtr("testString") listUsersOptionsModel.UserID = core.StringPtr("testString") listUsersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -289,6 +297,8 @@ var _ = Describe(`UserManagementV1`, func() { Expect(req.Method).To(Equal("GET")) Expect(req.URL.Query()["limit"]).To(Equal([]string{fmt.Sprint(int64(10))})) + // TODO: Add check for include_settings query parameter + Expect(req.URL.Query()["search"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["_start"]).To(Equal([]string{"testString"})) Expect(req.URL.Query()["user_id"]).To(Equal([]string{"testString"})) // Set mock response @@ -315,6 +325,8 @@ var _ = Describe(`UserManagementV1`, func() { listUsersOptionsModel := new(usermanagementv1.ListUsersOptions) listUsersOptionsModel.AccountID = core.StringPtr("testString") listUsersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listUsersOptionsModel.IncludeSettings = core.BoolPtr(true) + listUsersOptionsModel.Search = core.StringPtr("testString") listUsersOptionsModel.Start = core.StringPtr("testString") listUsersOptionsModel.UserID = core.StringPtr("testString") listUsersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -338,6 +350,8 @@ var _ = Describe(`UserManagementV1`, func() { listUsersOptionsModel := new(usermanagementv1.ListUsersOptions) listUsersOptionsModel.AccountID = core.StringPtr("testString") listUsersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listUsersOptionsModel.IncludeSettings = core.BoolPtr(true) + listUsersOptionsModel.Search = core.StringPtr("testString") listUsersOptionsModel.Start = core.StringPtr("testString") listUsersOptionsModel.UserID = core.StringPtr("testString") listUsersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -382,6 +396,8 @@ var _ = Describe(`UserManagementV1`, func() { listUsersOptionsModel := new(usermanagementv1.ListUsersOptions) listUsersOptionsModel.AccountID = core.StringPtr("testString") listUsersOptionsModel.Limit = core.Int64Ptr(int64(10)) + listUsersOptionsModel.IncludeSettings = core.BoolPtr(true) + listUsersOptionsModel.Search = core.StringPtr("testString") listUsersOptionsModel.Start = core.StringPtr("testString") listUsersOptionsModel.UserID = core.StringPtr("testString") listUsersOptionsModel.Headers = map[string]string{"x-custom-header": "x-custom-value"} @@ -457,6 +473,8 @@ var _ = Describe(`UserManagementV1`, func() { listUsersOptionsModel := &usermanagementv1.ListUsersOptions{ AccountID: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), + IncludeSettings: core.BoolPtr(true), + Search: core.StringPtr("testString"), UserID: core.StringPtr("testString"), } @@ -484,6 +502,8 @@ var _ = Describe(`UserManagementV1`, func() { listUsersOptionsModel := &usermanagementv1.ListUsersOptions{ AccountID: core.StringPtr("testString"), Limit: core.Int64Ptr(int64(10)), + IncludeSettings: core.BoolPtr(true), + Search: core.StringPtr("testString"), UserID: core.StringPtr("testString"), } @@ -1840,12 +1860,16 @@ var _ = Describe(`UserManagementV1`, func() { listUsersOptionsModel := userManagementService.NewListUsersOptions(accountID) listUsersOptionsModel.SetAccountID("testString") listUsersOptionsModel.SetLimit(int64(10)) + listUsersOptionsModel.SetIncludeSettings(true) + listUsersOptionsModel.SetSearch("testString") listUsersOptionsModel.SetStart("testString") listUsersOptionsModel.SetUserID("testString") listUsersOptionsModel.SetHeaders(map[string]string{"foo": "bar"}) Expect(listUsersOptionsModel).ToNot(BeNil()) Expect(listUsersOptionsModel.AccountID).To(Equal(core.StringPtr("testString"))) Expect(listUsersOptionsModel.Limit).To(Equal(core.Int64Ptr(int64(10)))) + Expect(listUsersOptionsModel.IncludeSettings).To(Equal(core.BoolPtr(true))) + Expect(listUsersOptionsModel.Search).To(Equal(core.StringPtr("testString"))) Expect(listUsersOptionsModel.Start).To(Equal(core.StringPtr("testString"))) Expect(listUsersOptionsModel.UserID).To(Equal(core.StringPtr("testString"))) Expect(listUsersOptionsModel.Headers).To(Equal(map[string]string{"foo": "bar"}))