@@ -16,7 +16,7 @@ type ProjectIPWhitelistService interface {
1616 List (context.Context , string , * ListOptions ) ([]ProjectIPWhitelist , * Response , error )
1717 Get (context.Context , string , string ) (* ProjectIPWhitelist , * Response , error )
1818 Create (context.Context , string , []* ProjectIPWhitelist ) ([]ProjectIPWhitelist , * Response , error )
19- Update (context.Context , string , string , []* ProjectIPWhitelist ) ([]ProjectIPWhitelist , * Response , error )
19+ Update (context.Context , string , []* ProjectIPWhitelist ) ([]ProjectIPWhitelist , * Response , error )
2020 Delete (context.Context , string , string ) (* Response , error )
2121}
2222
@@ -30,11 +30,12 @@ var _ ProjectIPWhitelistService = &ProjectIPWhitelistServiceOp{}
3030
3131// ProjectIPWhitelist represents MongoDB project's IP whitelist.
3232type ProjectIPWhitelist struct {
33- Comment string `json:"comment,omitempty"`
34- GroupID string `json:"groupId,omitempty"`
35- CIDRBlock string `json:"cidrBlock,omitempty"`
36- IPAddress string `json:"ipAddress,omitempty"`
37- DeleteAfterDate string `json:"deleteAfterDate,omitempty"`
33+ GroupID string `json:"groupId,omitempty"` // The unique identifier for the project for which you want to update one or more whitelist entries.
34+ AwsSecurityGroup string `json:"awsSecurityGroup,omitempty"` // ID of the whitelisted AWS security group to update. Mutually exclusive with cidrBlock and ipAddress.
35+ CIDRBlock string `json:"cidrBlock,omitempty"` // Whitelist entry in Classless Inter-Domain Routing (CIDR) notation to update. Mutually exclusive with awsSecurityGroup and ipAddress.
36+ IPAddress string `json:"ipAddress,omitempty"` // Whitelisted IP address to update. Mutually exclusive with awsSecurityGroup and cidrBlock.
37+ Comment string `json:"comment,omitempty"` // Optional The comment associated with the whitelist entry. Specify an empty string "" to delete the comment associated to an IP address.
38+ DeleteAfterDate string `json:"deleteAfterDate,omitempty"` // Optional The ISO-8601-formatted UTC date after which Atlas removes the entry from the whitelist. The specified date must be in the future and within one week of the time you make the API request. To update a temporary whitelist entry to be permanent, set the value of this field to null
3839}
3940
4041// projectIPWhitelistsResponse is the response from the ProjectIPWhitelistService.List.
@@ -44,18 +45,16 @@ type projectIPWhitelistsResponse struct {
4445 TotalCount int `json:"totalCount"`
4546}
4647
47- //List all whitelist entries in the project associated to {GROUP-ID}.
48- //See more: https://docs.atlas.mongodb.com/reference/api/whitelist-get-all/
49- func (s * ProjectIPWhitelistServiceOp ) List (ctx context.Context , groupID string , listOptions * ListOptions ) ([]ProjectIPWhitelist , * Response , error ) {
50- path := fmt .Sprintf (projectIPWhitelistPath , groupID )
51-
52- //Add query params from listOptions
53- path , err := setListOptions (path , listOptions )
54- if err != nil {
55- return nil , nil , err
48+ // Create adds one or more whitelist entries to the project associated to {GROUP-ID}.
49+ // See more: https://docs.atlas.mongodb.com/reference/api/database-users-create-a-user/
50+ func (s * ProjectIPWhitelistServiceOp ) Create (ctx context.Context , groupID string , createRequest []* ProjectIPWhitelist ) ([]ProjectIPWhitelist , * Response , error ) {
51+ if createRequest == nil {
52+ return nil , nil , NewArgError ("createRequest" , "cannot be nil" )
5653 }
5754
58- req , err := s .client .NewRequest (ctx , http .MethodGet , path , nil )
55+ path := fmt .Sprintf (projectIPWhitelistPath , groupID )
56+
57+ req , err := s .client .NewRequest (ctx , http .MethodPost , path , createRequest )
5958 if err != nil {
6059 return nil , nil , err
6160 }
@@ -70,11 +69,11 @@ func (s *ProjectIPWhitelistServiceOp) List(ctx context.Context, groupID string,
7069 resp .Links = l
7170 }
7271
73- return root .Results , resp , nil
72+ return root .Results , resp , err
7473}
7574
76- //Get gets the whitelist entry specified to {WHITELIST-ENTRY} from the project associated to {GROUP-ID}.
77- //See more: https://docs.atlas.mongodb.com/reference/api/whitelist-get-one-entry/
75+ // Get gets the whitelist entry specified to {WHITELIST-ENTRY} from the project associated to {GROUP-ID}.
76+ // See more: https://docs.atlas.mongodb.com/reference/api/whitelist-get-one-entry/
7877func (s * ProjectIPWhitelistServiceOp ) Get (ctx context.Context , groupID string , whiteListEntry string ) (* ProjectIPWhitelist , * Response , error ) {
7978 if whiteListEntry == "" {
8079 return nil , nil , NewArgError ("whiteListEntry" , "must be set" )
@@ -98,16 +97,18 @@ func (s *ProjectIPWhitelistServiceOp) Get(ctx context.Context, groupID string, w
9897 return root , resp , err
9998}
10099
101- //Add one or more whitelist entries to the project associated to {GROUP-ID}.
102- //See more: https://docs.atlas.mongodb.com/reference/api/database-users-create-a-user/
103- func (s * ProjectIPWhitelistServiceOp ) Create (ctx context.Context , groupID string , createRequest []* ProjectIPWhitelist ) ([]ProjectIPWhitelist , * Response , error ) {
104- if createRequest == nil {
105- return nil , nil , NewArgError ("createRequest" , "cannot be nil" )
106- }
107-
100+ // List all whitelist entries in the project associated to {GROUP-ID}.
101+ // See more: https://docs.atlas.mongodb.com/reference/api/whitelist-get-all/
102+ func (s * ProjectIPWhitelistServiceOp ) List (ctx context.Context , groupID string , listOptions * ListOptions ) ([]ProjectIPWhitelist , * Response , error ) {
108103 path := fmt .Sprintf (projectIPWhitelistPath , groupID )
109104
110- req , err := s .client .NewRequest (ctx , http .MethodPost , path , createRequest )
105+ // Add query params from listOptions
106+ path , err := setListOptions (path , listOptions )
107+ if err != nil {
108+ return nil , nil , err
109+ }
110+
111+ req , err := s .client .NewRequest (ctx , http .MethodGet , path , nil )
111112 if err != nil {
112113 return nil , nil , err
113114 }
@@ -122,18 +123,17 @@ func (s *ProjectIPWhitelistServiceOp) Create(ctx context.Context, groupID string
122123 resp .Links = l
123124 }
124125
125- return root .Results , resp , err
126+ return root .Results , resp , nil
126127}
127128
128- //Update one or more whitelist entries in the project associated to {GROUP-ID}
129- //See more: https://docs.atlas.mongodb.com/reference/api/whitelist-update-one/
130- func (s * ProjectIPWhitelistServiceOp ) Update (ctx context.Context , groupID string , whitelistEntry string , updateRequest []* ProjectIPWhitelist ) ([]ProjectIPWhitelist , * Response , error ) {
129+ // Update one or more whitelist entries in the project associated to {GROUP-ID}
130+ // See more: https://docs.atlas.mongodb.com/reference/api/whitelist-update-one/
131+ func (s * ProjectIPWhitelistServiceOp ) Update (ctx context.Context , groupID string , updateRequest []* ProjectIPWhitelist ) ([]ProjectIPWhitelist , * Response , error ) {
131132 if updateRequest == nil {
132133 return nil , nil , NewArgError ("updateRequest" , "cannot be nil" )
133134 }
134135
135- basePath := fmt .Sprintf (projectIPWhitelistPath , groupID )
136- path := fmt .Sprintf ("%s/%s" , basePath , whitelistEntry )
136+ path := fmt .Sprintf (projectIPWhitelistPath , groupID )
137137
138138 req , err := s .client .NewRequest (ctx , http .MethodPost , path , updateRequest )
139139 if err != nil {
0 commit comments