@@ -24,11 +24,12 @@ const orgsBasePath = "api/atlas/v1.0/orgs"
2424
2525// OrganizationsService provides access to the organization related functions in the Atlas API.
2626//
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
2828type OrganizationsService interface {
2929 List (context.Context , * OrganizationsListOptions ) (* Organizations , * Response , error )
3030 Invitations (context.Context , string , * InvitationOptions ) ([]* Invitation , * Response , error )
3131 Get (context.Context , string ) (* Organization , * Response , error )
32+ Create (context.Context , * CreateOrganizationRequest ) (* CreateOrganizationResponse , * Response , error )
3233 Invitation (context.Context , string , string ) (* Invitation , * Response , error )
3334 Projects (context.Context , string , * ProjectsListOptions ) (* Projects , * Response , error )
3435 Users (context.Context , string , * ListOptions ) (* AtlasUsersResponse , * Response , error )
@@ -72,6 +73,20 @@ type Organizations struct {
7273 TotalCount int `json:"totalCount"`
7374}
7475
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+
7590// List gets all organizations.
7691//
7792// 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
198213
199214 return resp , err
200215}
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