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..e3faac9b 100644 --- a/usermanagementv1/user_management_v1_examples_test.go +++ b/usermanagementv1/user_management_v1_examples_test.go @@ -22,13 +22,12 @@ package usermanagementv1_test import ( "encoding/json" "fmt" - "os" - "time" - "github.com/IBM/go-sdk-core/v5/core" "github.com/IBM/platform-services-go-sdk/usermanagementv1" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "os" + "time" ) var _ = Describe(`UserManagementV1 Examples Tests`, func() { @@ -192,14 +191,15 @@ var _ = Describe(`UserManagementV1 Examples Tests`, func() { fmt.Println("\nListUsers() result:") // begin-list_users listUsersOptions := &usermanagementv1.ListUsersOptions{ - AccountID: &accountID, + AccountID: &accountID, + IncludeSettings: core.BoolPtr(true), + Search: core.StringPtr("state:ACTIVE"), } pager, err := userManagementService.NewUsersPager(listUsersOptions) if err != nil { panic(err) } - var allResults []usermanagementv1.UserProfile for pager.HasNext() { nextPage, err := pager.GetNext() diff --git a/usermanagementv1/user_management_v1_integration_test.go b/usermanagementv1/user_management_v1_integration_test.go index 7c7193cf..c2f29fbe 100644 --- a/usermanagementv1/user_management_v1_integration_test.go +++ b/usermanagementv1/user_management_v1_integration_test.go @@ -21,15 +21,14 @@ package usermanagementv1_test import ( "fmt" - "log" - "os" - "time" - "github.com/IBM/go-sdk-core/v5/core" common "github.com/IBM/platform-services-go-sdk/common" "github.com/IBM/platform-services-go-sdk/usermanagementv1" . "github.com/onsi/ginkgo" . "github.com/onsi/gomega" + "log" + "os" + "time" ) /** @@ -159,10 +158,9 @@ var _ = Describe(`UserManagementV1 Integration Tests`, func() { It(`UpdateUserSettings(updateUserSettingsOptions *UpdateUserSettingsOptions)`, func() { updateUserSettingsOptions := &usermanagementv1.UpdateUserSettingsOptions{ - AccountID: &accountID, - IamID: &userID, - AllowedIPAddresses: core.StringPtr("32.96.110.50,172.16.254.1"), - SelfManage: core.BoolPtr(true), + AccountID: &accountID, + IamID: &userID, + SelfManage: core.BoolPtr(true), } response, err := userManagementService.UpdateUserSettings(updateUserSettingsOptions) @@ -205,6 +203,66 @@ var _ = Describe(`UserManagementV1 Integration Tests`, func() { fmt.Fprintf(GinkgoWriter, "Received a total of %d user profiles.\n", len(results)) }) + It(`ListUsers(listUsersOptions *ListUsersOptions) using search`, func() { + + results := []usermanagementv1.UserProfile{} + var moreResults bool = true + var pageStart *string = nil + for moreResults { + listUsersOptions := &usermanagementv1.ListUsersOptions{ + AccountID: &accountID, + Search: core.StringPtr("state:ACTIVE"), + Start: pageStart, + } + result, response, err := userManagementService.ListUsers(listUsersOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(result).ToNot(BeNil()) + // fmt.Fprintf(GinkgoWriter, "ListUsers() result:\n%s\n", common.ToJSON(result)) + + results = append(results, result.Resources...) + + if result.NextURL != nil { + pageStart, err = core.GetQueryParam(result.NextURL, "_start") + Expect(err).To(BeNil()) + } else { + moreResults = false + } + } + + fmt.Fprintf(GinkgoWriter, "Received a total of %d user profiles.\n", len(results)) + }) + It(`ListUsers(listUsersOptions *ListUsersOptions) using include_settings`, func() { + + results := []usermanagementv1.UserProfile{} + var moreResults bool = true + var pageStart *string = nil + + for moreResults { + listUsersOptions := &usermanagementv1.ListUsersOptions{ + AccountID: &accountID, + IncludeSettings: core.BoolPtr(true), + Limit: core.Int64Ptr(10), + Start: pageStart, + } + result, response, err := userManagementService.ListUsers(listUsersOptions) + Expect(err).To(BeNil()) + Expect(response.StatusCode).To(Equal(200)) + Expect(result).ToNot(BeNil()) + // fmt.Fprintf(GinkgoWriter, "ListUsers() result:\n%s\n", common.ToJSON(result)) + + results = append(results, result.Resources...) + + if result.NextURL != nil { + pageStart, err = core.GetQueryParam(result.NextURL, "_start") + Expect(err).To(BeNil()) + } else { + moreResults = false + } + } + + fmt.Fprintf(GinkgoWriter, "Received a total of %d user profiles.\n", len(results)) + }) It(`ListUsers(listUsersOptions *ListUsersOptions) using UsersPager`, func() { listUsersOptions := &usermanagementv1.ListUsersOptions{ AccountID: &accountID, 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"}))