@@ -24,11 +24,12 @@ const orgsBasePath = "api/atlas/v1.0/orgs"
24
24
25
25
// OrganizationsService provides access to the organization related functions in the Atlas API.
26
26
//
27
- // See more: https://docs.atlas. mongodb.com/reference/api/organizations/
27
+ // See more: https://www. mongodb.com/docs/atlas/ reference/api-resources-spec/#tag/Organizations
28
28
type OrganizationsService interface {
29
29
List (context.Context , * OrganizationsListOptions ) (* Organizations , * Response , error )
30
30
Invitations (context.Context , string , * InvitationOptions ) ([]* Invitation , * Response , error )
31
31
Get (context.Context , string ) (* Organization , * Response , error )
32
+ Create (context.Context , * CreateOrganizationRequest ) (* CreateOrganizationResponse , * Response , error )
32
33
Invitation (context.Context , string , string ) (* Invitation , * Response , error )
33
34
Projects (context.Context , string , * ProjectsListOptions ) (* Projects , * Response , error )
34
35
Users (context.Context , string , * ListOptions ) (* AtlasUsersResponse , * Response , error )
@@ -72,6 +73,20 @@ type Organizations struct {
72
73
TotalCount int `json:"totalCount"`
73
74
}
74
75
76
+ // CreateOrganizationRequest struct for CreateOrganizationRequest.
77
+ type CreateOrganizationRequest struct {
78
+ APIKey * APIKeyInput `json:"apiKey,omitempty"`
79
+ Name string `json:"name"`
80
+ OrgOwnerID string `json:"orgOwnerId"`
81
+ }
82
+
83
+ // CreateOrganizationResponse struct for CreateOrganizationResponse.
84
+ type CreateOrganizationResponse struct {
85
+ APIKey * APIKey `json:"apiKey,omitempty"`
86
+ OrgOwnerID * string `json:"orgOwnerId,omitempty"`
87
+ Organization * Organization `json:"organization,omitempty"`
88
+ }
89
+
75
90
// List gets all organizations.
76
91
//
77
92
// See more: https://docs.atlas.mongodb.com/reference/api/organization-get-all/
@@ -198,3 +213,25 @@ func (s *OrganizationsServiceOp) Delete(ctx context.Context, orgID string) (*Res
198
213
199
214
return resp , err
200
215
}
216
+
217
+ // Create creates an organization.
218
+ //
219
+ // See more: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/#tag/Organizations/operation/createOrganization
220
+ func (s * OrganizationsServiceOp ) Create (ctx context.Context , request * CreateOrganizationRequest ) (* CreateOrganizationResponse , * Response , error ) {
221
+ if request == nil {
222
+ return nil , nil , NewArgError ("request" , "must be set" )
223
+ }
224
+
225
+ req , err := s .Client .NewRequest (ctx , http .MethodPost , orgsBasePath , request )
226
+ if err != nil {
227
+ return nil , nil , err
228
+ }
229
+
230
+ root := new (CreateOrganizationResponse )
231
+ resp , err := s .Client .Do (ctx , req , root )
232
+ if err != nil {
233
+ return nil , resp , err
234
+ }
235
+
236
+ return root , resp , nil
237
+ }
0 commit comments