diff --git a/go.mod b/go.mod index aaeb6cd378..131a5f3d50 100644 --- a/go.mod +++ b/go.mod @@ -11,5 +11,5 @@ require ( github.com/spf13/cast v1.3.1 github.com/terraform-providers/terraform-provider-aws v1.60.1-0.20200518153306-40099de47e37 github.com/terraform-providers/terraform-provider-google v1.20.1-0.20200518165017-1dd21651c496 - go.mongodb.org/atlas v0.4.1-0.20200820152733-8dc4a7c19a2b + go.mongodb.org/atlas v0.4.1-0.20200903102338-049d0778b833 ) diff --git a/go.sum b/go.sum index 22faa7da98..6cff037725 100644 --- a/go.sum +++ b/go.sum @@ -609,6 +609,8 @@ go.mongodb.org/atlas v0.4.1-0.20200819194203-09c49e85aa0d h1:5GrmSNMip4s758EBOch go.mongodb.org/atlas v0.4.1-0.20200819194203-09c49e85aa0d/go.mod h1:QlKvZKT43+R6lhHlaTy2E7Q/3AoAljMI6v5apfqslIs= go.mongodb.org/atlas v0.4.1-0.20200820152733-8dc4a7c19a2b h1:AuAQZDrQLesdmz9mIPaIn07OJRoG4Vfm+M3xd31HGgo= go.mongodb.org/atlas v0.4.1-0.20200820152733-8dc4a7c19a2b/go.mod h1:QlKvZKT43+R6lhHlaTy2E7Q/3AoAljMI6v5apfqslIs= +go.mongodb.org/atlas v0.4.1-0.20200903102338-049d0778b833 h1:gH8Ih2OacuB6qVitO+wI5EBKdbtM/YdbhJstiMR2Vfw= +go.mongodb.org/atlas v0.4.1-0.20200903102338-049d0778b833/go.mod h1:CIaBeO8GLHhtYLw7xSSXsw7N90Z4MFY87Oy9qcPyuEs= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= diff --git a/mongodbatlas/data_source_mongodbatlas_database_user.go b/mongodbatlas/data_source_mongodbatlas_database_user.go index 92a0bd1c77..7e304322c0 100644 --- a/mongodbatlas/data_source_mongodbatlas_database_user.go +++ b/mongodbatlas/data_source_mongodbatlas_database_user.go @@ -77,6 +77,22 @@ func dataSourceMongoDBAtlasDatabaseUser() *schema.Resource { }, }, }, + "scopes": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, }, } } @@ -136,6 +152,10 @@ func dataSourceMongoDBAtlasDatabaseUserRead(d *schema.ResourceData, meta interfa return fmt.Errorf("error setting `labels` for database user (%s): %s", d.Id(), err) } + if err := d.Set("scopes", flattenScopes(dbUser.Scopes)); err != nil { + return fmt.Errorf("error setting `scopes` for database user (%s): %s", d.Id(), err) + } + d.SetId(encodeStateID(map[string]string{ "project_id": projectID, "username": username, diff --git a/mongodbatlas/data_source_mongodbatlas_database_users.go b/mongodbatlas/data_source_mongodbatlas_database_users.go index d4376e6273..163fba8dda 100644 --- a/mongodbatlas/data_source_mongodbatlas_database_users.go +++ b/mongodbatlas/data_source_mongodbatlas_database_users.go @@ -81,6 +81,22 @@ func dataSourceMongoDBAtlasDatabaseUsers() *schema.Resource { }, }, }, + "scopes": { + Type: schema.TypeList, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Computed: true, + }, + }, + }, + }, }, }, }, @@ -123,6 +139,7 @@ func flattenDBUsers(dbUsers []matlas.DatabaseUser) []map[string]interface{} { "x509_type": dbUsers[i].X509Type, "aws_iam_type": dbUsers[i].AWSIAMType, "labels": flattenLabels(dbUsers[i].Labels), + "scopes": flattenScopes(dbUsers[i].Scopes), } } } diff --git a/mongodbatlas/data_source_mongodbatlas_database_users_test.go b/mongodbatlas/data_source_mongodbatlas_database_users_test.go index b5a5fa0cc6..9c21400f22 100644 --- a/mongodbatlas/data_source_mongodbatlas_database_users_test.go +++ b/mongodbatlas/data_source_mongodbatlas_database_users_test.go @@ -37,6 +37,7 @@ func TestAccDataSourceMongoDBAtlasDatabaseUsers_basic(t *testing.T) { resource.TestCheckResourceAttrSet(resourceName, "results.0.x509_type"), resource.TestCheckResourceAttrSet(resourceName, "results.0.username"), resource.TestCheckResourceAttrSet(resourceName, "results.0.roles.#"), + resource.TestCheckResourceAttrSet(resourceName, "results.0.scopes.#"), ), }, }, diff --git a/mongodbatlas/data_source_mongodbatlas_project_test.go b/mongodbatlas/data_source_mongodbatlas_project_test.go index 1090bfa088..ef5ea11b36 100644 --- a/mongodbatlas/data_source_mongodbatlas_project_test.go +++ b/mongodbatlas/data_source_mongodbatlas_project_test.go @@ -65,6 +65,7 @@ func TestAccDataSourceMongoDBAtlasProject_byName(t *testing.T) { RoleNames: []string{"GROUP_READ_ONLY", "GROUP_DATA_ACCESS_ADMIN"}, }, { + TeamID: teamsIds[1], RoleNames: []string{"GROUP_DATA_ACCESS_ADMIN", "GROUP_OWNER"}, }, diff --git a/mongodbatlas/resource_mongodbatlas_database_user.go b/mongodbatlas/resource_mongodbatlas_database_user.go index e3b4ab3b84..9597096b20 100644 --- a/mongodbatlas/resource_mongodbatlas_database_user.go +++ b/mongodbatlas/resource_mongodbatlas_database_user.go @@ -105,6 +105,25 @@ func resourceMongoDBAtlasDatabaseUser() *schema.Resource { }, }, }, + "scopes": { + Type: schema.TypeSet, + Optional: true, + Computed: true, + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "name": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + "type": { + Type: schema.TypeString, + Optional: true, + Computed: true, + }, + }, + }, + }, }, } } @@ -161,6 +180,10 @@ func resourceMongoDBAtlasDatabaseUserRead(d *schema.ResourceData, meta interface return fmt.Errorf("error setting `labels` for database user (%s): %s", d.Id(), err) } + if err := d.Set("scopes", flattenScopes(dbUser.Scopes)); err != nil { + return fmt.Errorf("error setting `scopes` for database user (%s): %s", d.Id(), err) + } + d.SetId(encodeStateID(map[string]string{ "project_id": projectID, "username": username, @@ -197,6 +220,7 @@ func resourceMongoDBAtlasDatabaseUserCreate(d *schema.ResourceData, meta interfa AWSIAMType: d.Get("aws_iam_type").(string), DatabaseName: authDatabaseName, Labels: expandLabelSliceFromSetSchema(d), + Scopes: expandScopes(d), } dbUserRes, _, err := conn.DatabaseUsers.Create(context.Background(), projectID, dbUserReq) @@ -240,6 +264,10 @@ func resourceMongoDBAtlasDatabaseUserUpdate(d *schema.ResourceData, meta interfa dbUser.Labels = expandLabelSliceFromSetSchema(d) } + if d.HasChange("scopes") { + dbUser.Scopes = expandScopes(d) + } + _, _, err = conn.DatabaseUsers.Update(context.Background(), projectID, username, dbUser) if err != nil { return fmt.Errorf("error updating database user(%s): %s", username, err) @@ -345,3 +373,30 @@ func flattenRoles(roles []matlas.Role) []interface{} { return roleList } + +func flattenScopes(l []matlas.Scope) []map[string]interface{} { + scopes := make([]map[string]interface{}, len(l)) + for i, v := range l { + scopes[i] = map[string]interface{}{ + "name": v.Name, + "type": v.Type, + } + } + + return scopes +} + +func expandScopes(d *schema.ResourceData) []matlas.Scope { + list := d.Get("scopes").(*schema.Set) + res := make([]matlas.Scope, list.Len()) + + for i, val := range list.List() { + v := val.(map[string]interface{}) + res[i] = matlas.Scope{ + Type: v["type"].(string), + Name: v["name"].(string), + } + } + + return res +} diff --git a/mongodbatlas/resource_mongodbatlas_database_user_test.go b/mongodbatlas/resource_mongodbatlas_database_user_test.go index 2f3008f681..5519e51ddf 100644 --- a/mongodbatlas/resource_mongodbatlas_database_user_test.go +++ b/mongodbatlas/resource_mongodbatlas_database_user_test.go @@ -291,6 +291,68 @@ func TestAccResourceMongoDBAtlasDatabaseUser_withRoles(t *testing.T) { }) } +func TestAccResourceMongoDBAtlasDatabaseUser_withScopes(t *testing.T) { + var ( + dbUser matlas.DatabaseUser + resourceName = "mongodbatlas_database_user.test" + username = acctest.RandomWithPrefix("test-acc-user-") + password = acctest.RandomWithPrefix("test-acc-pass-") + orgID = os.Getenv("MONGODB_ATLAS_ORG_ID") + projectName = acctest.RandomWithPrefix("test-acc") + clusterName = acctest.RandomWithPrefix("test-acc-cluster") + ) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + Providers: testAccProviders, + CheckDestroy: testAccCheckMongoDBAtlasDatabaseUserDestroy, + Steps: []resource.TestStep{ + { + Config: testAccMongoDBAtlasDatabaseUserWithScopes(username, password, projectName, orgID, "atlasAdmin", clusterName, + []*matlas.Scope{ + { + Name: "test-acc-nurk4llu2z", + Type: "CLUSTER", + }, + { + Name: "test-acc-nurk4llu2z", + Type: "DATA_LAKE", + }, + }, + ), + Check: resource.ComposeTestCheckFunc( + testAccCheckMongoDBAtlasDatabaseUserExists(resourceName, &dbUser), + testAccCheckMongoDBAtlasDatabaseUserAttributes(&dbUser, username), + resource.TestCheckResourceAttrSet(resourceName, "project_id"), + resource.TestCheckResourceAttr(resourceName, "username", username), + resource.TestCheckResourceAttr(resourceName, "password", password), + resource.TestCheckResourceAttr(resourceName, "auth_database_name", "admin"), + resource.TestCheckResourceAttr(resourceName, "scopes.#", "2"), + ), + }, + { + Config: testAccMongoDBAtlasDatabaseUserWithScopes(username, password, projectName, orgID, "atlasAdmin", clusterName, + []*matlas.Scope{ + { + Name: "test-acc-nurk4llu2z", + Type: "CLUSTER", + }, + }, + ), + Check: resource.ComposeTestCheckFunc( + testAccCheckMongoDBAtlasDatabaseUserExists(resourceName, &dbUser), + testAccCheckMongoDBAtlasDatabaseUserAttributes(&dbUser, username), + resource.TestCheckResourceAttrSet(resourceName, "project_id"), + resource.TestCheckResourceAttr(resourceName, "username", username), + resource.TestCheckResourceAttr(resourceName, "password", password), + resource.TestCheckResourceAttr(resourceName, "auth_database_name", "admin"), + resource.TestCheckResourceAttr(resourceName, "scopes.#", "1"), + ), + }, + }, + }) +} + func TestAccResourceMongoDBAtlasDatabaseUser_importBasic(t *testing.T) { var ( username = fmt.Sprintf("test-username-%s", acctest.RandString(5)) @@ -589,3 +651,58 @@ func testAccMongoDBAtlasDatabaseUserWithAWSIAMTypeConfig(projectName, orgID, rol } `, projectName, orgID, roleName, username, keyLabel, valueLabel) } + +func testAccMongoDBAtlasDatabaseUserWithScopes(username, password, projectName, orgID, roleName, clusterName string, scopesArr []*matlas.Scope) string { + var scopes string + + for _, scope := range scopesArr { + var scopeType string + + if scope.Type != "" { + scopeType = fmt.Sprintf(`type = "%s"`, scope.Type) + } + + scopes += fmt.Sprintf(` + scopes { + name = "${mongodbatlas_cluster.my_cluster.name}" + %s + } + `, scopeType) + } + + return fmt.Sprintf(` + resource "mongodbatlas_project" "test" { + name = "%s" + org_id = "%s" + } + + resource "mongodbatlas_cluster" "my_cluster" { + project_id = "${mongodbatlas_project.test.id}" + name = "%s" + disk_size_gb = 5 + + // Provider Settings "block" + provider_name = "AWS" + provider_region_name = "US_EAST_2" + provider_instance_size_name = "M10" + provider_backup_enabled = true //enable cloud provider snapshots + provider_disk_iops = 100 + provider_encrypt_ebs_volume = false + } + + resource "mongodbatlas_database_user" "test" { + username = "%s" + password = "%s" + project_id = "${mongodbatlas_project.test.id}" + auth_database_name = "admin" + + roles { + role_name = "%s" + database_name = "admin" + } + + %s + + } + `, projectName, orgID, clusterName, username, password, roleName, scopes) +} diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/atlas_alerts.go b/vendor/go.mongodb.org/atlas/mongodbatlas/alerts.go similarity index 94% rename from vendor/go.mongodb.org/atlas/mongodbatlas/atlas_alerts.go rename to vendor/go.mongodb.org/atlas/mongodbatlas/alerts.go index 00c5b604aa..3ff3113089 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/atlas_alerts.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/alerts.go @@ -10,6 +10,7 @@ const alertPath = "groups/%s/alerts" // AlertsService is an interface for interfacing with the Alerts // endpoints of the MongoDB Atlas API. +// // See more: https://docs.atlas.mongodb.com/reference/api/alerts/ type AlertsService interface { List(context.Context, string, *AlertsListOptions) (*AlertsResponse, *Response, error) @@ -17,8 +18,7 @@ type AlertsService interface { Acknowledge(context.Context, string, string, *AcknowledgeRequest) (*Alert, *Response, error) } -// AlertServiceOp handles communication with the Alert related methods -// of the MongoDB Atlas API +// AlertsServiceOp provides an implementation of AlertsService type AlertsServiceOp service var _ AlertsService = &AlertsServiceOp{} @@ -48,26 +48,27 @@ type Alert struct { Notifications []Notification `json:"notifications,omitempty"` // Notifications are sending when an alert condition is detected. } -// AlertsRequest contains the request Body Parameters +// AcknowledgeRequest contains the request Body Parameters type AcknowledgeRequest struct { AcknowledgedUntil *string `json:"acknowledgedUntil,omitempty"` // The date through which the alert has been acknowledged. Will not be present if the alert has never been acknowledged. AcknowledgementComment string `json:"acknowledgementComment,omitempty"` // The comment left by the user who acknowledged the alert. Will not be present if the alert has never been acknowledged. } -// AlertsListOptions contains the list of options for Alerts +// AlertsListOptions contains the list of options for Alerts. type AlertsListOptions struct { Status string `url:"status,omitempty"` ListOptions } -// AlertResponse is the response from the AlertService.List. +// AlertsResponse is the response from the AlertService.List. type AlertsResponse struct { Links []*Link `json:"links"` Results []Alert `json:"results"` TotalCount int `json:"totalCount"` } -// GetAnAlert gets the alert specified to {ALERT-ID} for the project associated to {GROUP-ID}. +// Get gets the alert specified to {ALERT-ID} for the project associated to {GROUP-ID}. +// // See more: https://docs.atlas.mongodb.com/reference/api/alerts-get-alert/ func (s *AlertsServiceOp) Get(ctx context.Context, groupID, alertID string) (*Alert, *Response, error) { if groupID == "" { @@ -95,6 +96,7 @@ func (s *AlertsServiceOp) Get(ctx context.Context, groupID, alertID string) (*Al } // List gets all alert for the project associated to {GROUP-ID}. +// // See more: https://docs.atlas.mongodb.com/reference/api/alerts-get-all-alerts/ func (s *AlertsServiceOp) List(ctx context.Context, groupID string, listOptions *AlertsListOptions) (*AlertsResponse, *Response, error) { if groupID == "" { @@ -127,7 +129,8 @@ func (s *AlertsServiceOp) List(ctx context.Context, groupID string, listOptions return root, resp, nil } -// AckAnAlert allows to acknowledge an alert +// Acknowledge allows to acknowledge an alert. +// // See more: https://docs.atlas.mongodb.com/reference/api/alerts-acknowledge-alert/ func (s *AlertsServiceOp) Acknowledge(ctx context.Context, groupID, alertID string, params *AcknowledgeRequest) (*Alert, *Response, error) { if groupID == "" { diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/atlas_users.go b/vendor/go.mongodb.org/atlas/mongodbatlas/atlas_users.go index f00c24adf7..0d7dc68d50 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/atlas_users.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/atlas_users.go @@ -12,6 +12,7 @@ const ( // AtlasUsersService is an interface for interfacing with the AtlasUsers // endpoints of the MongoDB Atlas API. +// // See more: https://docs.atlas.mongodb.com/reference/api/users/ type AtlasUsersService interface { List(context.Context, string, *ListOptions) ([]AtlasUser, *Response, error) @@ -26,13 +27,14 @@ type AtlasUsersServiceOp service var _ AtlasUsersService = &AtlasUsersServiceOp{} -// AtlasUsers represents a array of project +// AtlasUsersResponse represents a array of users type AtlasUsersResponse struct { Links []*Link `json:"links"` Results []AtlasUser `json:"results"` TotalCount int `json:"totalCount"` } +// AtlasUser represents a user type AtlasUser struct { EmailAddress string `json:"emailAddress"` FirstName string `json:"firstName"` @@ -47,6 +49,7 @@ type AtlasUser struct { } // List gets all users. +// // See more: https://docs.atlas.mongodb.com/reference/api/user-get-all/ func (s *AtlasUsersServiceOp) List(ctx context.Context, orgID string, listOptions *ListOptions) ([]AtlasUser, *Response, error) { path := fmt.Sprintf(usersBasePath, orgID) @@ -76,6 +79,7 @@ func (s *AtlasUsersServiceOp) List(ctx context.Context, orgID string, listOption } // Get gets a single atlas user. +// // See more: https://docs.atlas.mongodb.com/reference/api/user-get-by-id/ func (s *AtlasUsersServiceOp) Get(ctx context.Context, userID string) (*AtlasUser, *Response, error) { if userID == "" { @@ -99,6 +103,7 @@ func (s *AtlasUsersServiceOp) Get(ctx context.Context, userID string) (*AtlasUse } // GetByName gets a single atlas user by name. +// // See more: https://docs.atlas.mongodb.com/reference/api/user-get-one-by-name/ func (s *AtlasUsersServiceOp) GetByName(ctx context.Context, username string) (*AtlasUser, *Response, error) { if username == "" { @@ -122,6 +127,7 @@ func (s *AtlasUsersServiceOp) GetByName(ctx context.Context, username string) (* } // Create creates an Atlas User. +// // See more: https://docs.atlas.mongodb.com/reference/api/user-create/ func (s *AtlasUsersServiceOp) Create(ctx context.Context, createRequest *AtlasUser) (*AtlasUser, *Response, error) { if createRequest == nil { diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/aws_custom_dns.go b/vendor/go.mongodb.org/atlas/mongodbatlas/aws_custom_dns.go index 785bfa6d42..de6d104903 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/aws_custom_dns.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/aws_custom_dns.go @@ -16,7 +16,7 @@ type AWSCustomDNSService interface { Update(context.Context, string, *AWSCustomDNSSetting) (*AWSCustomDNSSetting, *Response, error) } -// CustomAWSDNSOp provides an implementation of the CustomAWSDNS interface. +// AWSCustomDNSServiceOp provides an implementation of the CustomAWSDNS interface. type AWSCustomDNSServiceOp service var _ AWSCustomDNSService = &AWSCustomDNSServiceOp{} diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/containers.go b/vendor/go.mongodb.org/atlas/mongodbatlas/containers.go index 919184fee2..c417eeaf39 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/containers.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/containers.go @@ -27,6 +27,7 @@ type ContainersServiceOp service var _ ContainersService = &ContainersServiceOp{} +// ContainersListOptions filtering options for containers type ContainersListOptions struct { ProviderName string `url:"providerName,omitempty"` ListOptions diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/continuous_restore_jobs.go b/vendor/go.mongodb.org/atlas/mongodbatlas/continuous_restore_jobs.go index b63ef2e4c6..9f1799c988 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/continuous_restore_jobs.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/continuous_restore_jobs.go @@ -8,6 +8,9 @@ import ( const continuousRestoreJobsPath = "groups/%s/clusters/%s/restoreJobs" +// ContinuousRestoreJobsService provides access to the restore jobs related functions in the Atlas API. +// +// See more: https://docs.atlas.mongodb.com/reference/api/legacy-backup/restore/restores/ type ContinuousRestoreJobsService interface { List(context.Context, string, string, *ListOptions) (*ContinuousJobs, *Response, error) Get(context.Context, string, string, string) (*ContinuousJob, *Response, error) @@ -76,7 +79,8 @@ type ContinuousJobRequest struct { SnapshotID string `json:"snapshotId,omitempty"` } -// List list all continuous backup jobs in Atlas +// List lists all continuous backup jobs in Atlas +// // See more: https://docs.atlas.mongodb.com/reference/api/restore-jobs-get-all/ func (s *ContinuousRestoreJobsServiceOp) List(ctx context.Context, groupID, clusterID string, opts *ListOptions) (*ContinuousJobs, *Response, error) { if clusterID == "" { @@ -105,6 +109,7 @@ func (s *ContinuousRestoreJobsServiceOp) List(ctx context.Context, groupID, clus } // Get gets a continuous backup job in Atlas +// // See more: https://docs.atlas.mongodb.com/reference/api/restore-jobs-get-one/ func (s *ContinuousRestoreJobsServiceOp) Get(ctx context.Context, groupID, clusterID, jobID string) (*ContinuousJob, *Response, error) { if clusterID == "" { @@ -133,6 +138,7 @@ func (s *ContinuousRestoreJobsServiceOp) Get(ctx context.Context, groupID, clust } // Create creates a continuous backup job in Atlas +// // See more: https://docs.atlas.mongodb.com/reference/api/restore-jobs-create-one/ func (s *ContinuousRestoreJobsServiceOp) Create(ctx context.Context, groupID, clusterID string, request *ContinuousJobRequest) (*ContinuousJobs, *Response, error) { if request == nil { diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/continuous_snaphots.go b/vendor/go.mongodb.org/atlas/mongodbatlas/continuous_snaphots.go index 3600466fa8..7a88217e55 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/continuous_snaphots.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/continuous_snaphots.go @@ -12,6 +12,7 @@ const ( // ContinuousSnapshotsService is an interface for interfacing with the Continuous Snapshots // endpoints of the MongoDB Atlas API. +// // See more: https://docs.atlas.mongodb.com/reference/api/snapshots/ type ContinuousSnapshotsService interface { List(context.Context, string, string, *ListOptions) (*ContinuousSnapshots, *Response, error) @@ -26,7 +27,7 @@ type ContinuousSnapshotsServiceOp service var _ ContinuousSnapshotsService = &ContinuousSnapshotsServiceOp{} -// CloudProviderSnapshot represents a cloud provider snapshot. +// ContinuousSnapshot represents a cloud provider snapshot. type ContinuousSnapshot struct { ClusterID string `json:"clusterId,omitempty"` Complete bool `json:"complete,omitempty"` @@ -76,7 +77,7 @@ type MissingShard struct { LastHeartbeat string `json:"lastHeartbeat"` } -// CloudProviderSnapshots represents all cloud provider snapshots. +// ContinuousSnapshots represents all cloud provider snapshots. type ContinuousSnapshots struct { Results []*ContinuousSnapshot `json:"results,omitempty"` // Includes one ContinuousSnapshots object for each item detailed in the results array section. Links []*Link `json:"links,omitempty"` // One or more links to sub-resources and/or related resources. @@ -84,6 +85,7 @@ type ContinuousSnapshots struct { } // List lists continuous snapshots for the given cluster +// // See more: https://docs.atlas.mongodb.com/reference/api/snapshots-get-all/ func (s *ContinuousSnapshotsServiceOp) List(ctx context.Context, groupID, clusterID string, listOptions *ListOptions) (*ContinuousSnapshots, *Response, error) { if groupID == "" { @@ -106,7 +108,8 @@ func (s *ContinuousSnapshotsServiceOp) List(ctx context.Context, groupID, cluste return root, resp, err } -// List gets the continuous snapshot for the given cluster and snapshot ID +// Get gets the continuous snapshot for the given cluster and snapshot ID +// // See more: https://docs.atlas.mongodb.com/reference/api/snapshots-get-one/ func (s *ContinuousSnapshotsServiceOp) Get(ctx context.Context, groupID, clusterID, snapshotID string) (*ContinuousSnapshot, *Response, error) { if groupID == "" { @@ -133,6 +136,7 @@ func (s *ContinuousSnapshotsServiceOp) Get(ctx context.Context, groupID, cluster } // ChangeExpiry changes the expiry date for the given cluster and snapshot ID +// // See more: https://docs.atlas.mongodb.com/reference/api/snapshots-change-expiration/ func (s *ContinuousSnapshotsServiceOp) ChangeExpiry(ctx context.Context, groupID, clusterID, snapshotID string, updateRequest *ContinuousSnapshot) (*ContinuousSnapshot, *Response, error) { if groupID == "" { @@ -160,6 +164,7 @@ func (s *ContinuousSnapshotsServiceOp) ChangeExpiry(ctx context.Context, groupID } // Delete deletes the given continuous snapshot +// // See more: https://docs.atlas.mongodb.com/reference/api/snapshots-delete-one/ func (s *ContinuousSnapshotsServiceOp) Delete(ctx context.Context, groupID, clusterID, snapshotID string) (*Response, error) { if groupID == "" { diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/data_lakes.go b/vendor/go.mongodb.org/atlas/mongodbatlas/data_lakes.go index 0b7c60ae06..094169c4ba 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/data_lakes.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/data_lakes.go @@ -97,13 +97,13 @@ type DataLake struct { Storage Storage `json:"storage,omitempty"` // Configuration for each data store and its mapping to MongoDB collections / databases. } -// DataLakeReqPathParameters represents all possible fields that can be updated in a data lake +// DataLakeUpdateRequest represents all possible fields that can be updated in a data lake type DataLakeUpdateRequest struct { CloudProviderConfig *CloudProviderConfig `json:"cloudProviderConfig,omitempty"` DataProcessRegion *DataProcessRegion `json:"dataProcessRegion,omitempty"` } -// DataLakeReqPathParameters represents the required fields to create a new data lake +// DataLakeCreateRequest represents the required fields to create a new data lake type DataLakeCreateRequest struct { Name string `json:"name,omitempty"` } diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/database_users.go b/vendor/go.mongodb.org/atlas/mongodbatlas/database_users.go index 3d48d0c89b..c8a4dd1223 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/database_users.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/database_users.go @@ -43,10 +43,18 @@ type DatabaseUser struct { AWSIAMType string `json:"awsIAMType,omitempty"` GroupID string `json:"groupId,omitempty"` Roles []Role `json:"roles,omitempty"` + Scopes []Scope `json:"scopes,omitempty"` Password string `json:"password,omitempty"` Username string `json:"username,omitempty"` } +// Scope if presents a database user only have access to the indicated resource +// if none is given then it has access to all +type Scope struct { + Name string `json:"name"` + Type string `json:"type"` +} + // Label containing key-value pairs that tag and categorize the database user type Label struct { Key string `json:"key,omitempty"` diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/indexes.go b/vendor/go.mongodb.org/atlas/mongodbatlas/indexes.go index d37053ff5c..ddcf9a07fb 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/indexes.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/indexes.go @@ -10,6 +10,7 @@ const indexesPath = "groups/%s/clusters/%s/index" // IndexesService is an interface for interfacing with the clusters indexes // endpoints of the MongoDB Atlas API. +// // See more: https://docs.atlas.mongodb.com/reference/api/indexes/ type IndexesService interface { Create(context.Context, string, string, *IndexConfiguration) (*Response, error) @@ -30,7 +31,8 @@ type IndexConfiguration struct { Collation *CollationOptions `json:"collation,omitempty"` // Collation Mongo collation index options } -// IndexOptions, represents mdb index options +// IndexOptions represents mongodb index options. +// // See: https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#options type IndexOptions struct { Background bool `json:"background,omitempty"` @@ -51,7 +53,8 @@ type IndexOptions struct { ExpireAfterSeconds int `json:"expireAfterSeconds,omitempty"` } -// CollationOptions represents options for collation indexes +// CollationOptions represents options for collation indexes. +// // See: https://docs.mongodb.com/manual/reference/method/db.collection.createIndex/#option-for-collation type CollationOptions struct { Locale string `json:"locale,omitempty"` @@ -66,6 +69,7 @@ type CollationOptions struct { } // Create creates a request for a rolling index creation for the project associated to {GROUP-ID} and the {CLUSTER-NAME}. +// // See more: https://docs.atlas.mongodb.com/reference/api/rolling-index-create-one/ func (s *IndexesServiceOp) Create(ctx context.Context, groupID, clusterName string, createReq *IndexConfiguration) (*Response, error) { if groupID == "" { diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/mongodbatlas.go b/vendor/go.mongodb.org/atlas/mongodbatlas/mongodbatlas.go index 08dcde765e..d2e81808bb 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/mongodbatlas.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/mongodbatlas.go @@ -32,20 +32,24 @@ var ( userAgent = fmt.Sprintf("%s/%s (%s;%s)", libraryName, Version, runtime.GOOS, runtime.GOARCH) ) +// Doer basic interface of a client to be able to do a request type Doer interface { Do(context.Context, *http.Request, interface{}) (*Response, error) } +// Completer interface for clients with callback type Completer interface { OnRequestCompleted(RequestCompletionCallback) } +// RequestDoer minimum interface for any service of the client type RequestDoer interface { Doer Completer NewRequest(context.Context, string, string, interface{}) (*http.Request, error) } +// GZipRequestDoer minimum interface for any service of the client that should handle gzip downloads type GZipRequestDoer interface { Doer Completer @@ -100,6 +104,7 @@ type Client struct { OnlineArchives OnlineArchiveService Search SearchService CustomAWSDNS AWSCustomDNSService + Integrations IntegrationsService onRequestCompleted RequestCompletionCallback } @@ -235,6 +240,7 @@ func NewClient(httpClient *http.Client) *Client { c.OnlineArchives = &OnlineArchiveServiceOp{Client: c} c.Search = &SearchServiceOp{Client: c} c.CustomAWSDNS = &AWSCustomDNSServiceOp{Client: c} + c.Integrations = &IntegrationsServiceOp{Client: c} return c } @@ -320,6 +326,9 @@ func (c *Client) newEncodedBody(body interface{}) (io.Reader, error) { // NewGZipRequest creates an API request that accepts gzip. A relative URL can be provided in urlStr, which will be resolved to the // BaseURL of the Client. Relative URLS should always be specified without a preceding slash. func (c *Client) NewGZipRequest(ctx context.Context, method, urlStr string) (*http.Request, error) { + if !strings.HasSuffix(c.BaseURL.Path, "/") { + return nil, fmt.Errorf("base URL must have a trailing slash, but %q does not", c.BaseURL) + } rel, err := url.Parse(urlStr) if err != nil { return nil, err diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/peers.go b/vendor/go.mongodb.org/atlas/mongodbatlas/peers.go index b04590a9ff..0a38a2c639 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/peers.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/peers.go @@ -11,6 +11,7 @@ const peersPath = "groups/%s/peers" // PeersService is an interface for interfacing with the Peers // endpoints of the MongoDB Atlas API. +// // See more: https://docs.atlas.mongodb.com/reference/api/vpc/ type PeersService interface { List(context.Context, string, *ContainersListOptions) ([]Peer, *Response, error) @@ -58,6 +59,7 @@ type peersResponse struct { } // List all peers in the project associated to {GROUP-ID}. +// // See more: https://docs.atlas.mongodb.com/reference/api/vpc-get-connections-list/ func (s *PeersServiceOp) List(ctx context.Context, groupID string, listOptions *ContainersListOptions) ([]Peer, *Response, error) { path := fmt.Sprintf(peersPath, groupID) @@ -87,6 +89,7 @@ func (s *PeersServiceOp) List(ctx context.Context, groupID string, listOptions * } // Get gets the netwprk peering connection specified to {PEER-ID} from the project associated to {GROUP-ID}. +// // See more: https://docs.atlas.mongodb.com/reference/api/vpc-get-connection/ func (s *PeersServiceOp) Get(ctx context.Context, groupID, peerID string) (*Peer, *Response, error) { if peerID == "" { @@ -111,7 +114,8 @@ func (s *PeersServiceOp) Get(ctx context.Context, groupID, peerID string) (*Peer return root, resp, err } -// Add a peer connection to the project associated to {GROUP-ID}. +// Create a peer connection to the project associated to {GROUP-ID}. +// // See more: https://docs.atlas.mongodb.com/reference/api/vpc-create-peering-connection/ func (s *PeersServiceOp) Create(ctx context.Context, groupID string, createRequest *Peer) (*Peer, *Response, error) { if createRequest == nil { @@ -135,6 +139,7 @@ func (s *PeersServiceOp) Create(ctx context.Context, groupID string, createReque } // Update a peer connection in the project associated to {GROUP-ID} +// // See more: https://docs.atlas.mongodb.com/reference/api/vpc-update-peering-connection/ func (s *PeersServiceOp) Update(ctx context.Context, groupID, peerID string, updateRequest *Peer) (*Peer, *Response, error) { if updateRequest == nil { @@ -159,6 +164,7 @@ func (s *PeersServiceOp) Update(ctx context.Context, groupID, peerID string, upd } // Delete the peer connection specified to {PEER-ID} from the project associated to {GROUP-ID}. +// // See more: https://docs.atlas.mongodb.com/reference/api/vpc-delete-peering-connection/ func (s *PeersServiceOp) Delete(ctx context.Context, groupID, peerID string) (*Response, error) { if peerID == "" { diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/process_databases.go b/vendor/go.mongodb.org/atlas/mongodbatlas/process_databases.go index b40a87df2e..a49f0f7a87 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/process_databases.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/process_databases.go @@ -10,12 +10,13 @@ const processesDatabasesPath = "groups/%s/processes/%s:%d/databases" // ProcessDatabasesService is an interface for interfacing with the Process Measurements // endpoints of the MongoDB Atlas API. +// // See more: https://docs.atlas.mongodb.com/reference/api/process-databases/ type ProcessDatabasesService interface { List(context.Context, string, string, int, *ListOptions) (*ProcessDatabasesResponse, *Response, error) } -// ProcessDatabasesOp handles communication with the process disks related methods of the +// ProcessDatabasesServiceOp handles communication with the process disks related methods of the // MongoDB Atlas API type ProcessDatabasesServiceOp service @@ -35,6 +36,7 @@ type ProcessDatabase struct { } // List gets databases for a specific Atlas MongoDB process. +// // See more: https://docs.atlas.mongodb.com/reference/api/process-databases/ func (s *ProcessDatabasesServiceOp) List(ctx context.Context, groupID, host string, port int, opts *ListOptions) (*ProcessDatabasesResponse, *Response, error) { if groupID == "" { diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/projects.go b/vendor/go.mongodb.org/atlas/mongodbatlas/projects.go index 57ea5d8cd8..f5ac314f03 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/projects.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/projects.go @@ -22,6 +22,7 @@ const ( // ProjectsService is an interface for interfacing with the Projects // endpoints of the MongoDB Atlas API. +// // See more: https://docs.atlas.mongodb.com/reference/api/projects/ type ProjectsService interface { GetAllProjects(context.Context, *ListOptions) (*Projects, *Response, error) @@ -31,6 +32,7 @@ type ProjectsService interface { Delete(context.Context, string) (*Response, error) GetProjectTeamsAssigned(context.Context, string) (*TeamsAssigned, *Response, error) AddTeamsToProject(context.Context, string, []*ProjectTeam) (*TeamsAssigned, *Response, error) + RemoveUserFromProject(context.Context, string, string) (*Response, error) } // ProjectsServiceOp handles communication with the Projects related methods of the @@ -77,6 +79,7 @@ type TeamsAssigned struct { } // GetAllProjects gets all project. +// // See more: https://docs.atlas.mongodb.com/reference/api/project-get-all/ func (s *ProjectsServiceOp) GetAllProjects(ctx context.Context, listOptions *ListOptions) (*Projects, *Response, error) { path, err := setListOptions(projectBasePath, listOptions) @@ -103,6 +106,7 @@ func (s *ProjectsServiceOp) GetAllProjects(ctx context.Context, listOptions *Lis } // GetOneProject gets a single project. +// // See more: https://docs.atlas.mongodb.com/reference/api/project-get-one/ func (s *ProjectsServiceOp) GetOneProject(ctx context.Context, projectID string) (*Project, *Response, error) { if projectID == "" { @@ -126,6 +130,7 @@ func (s *ProjectsServiceOp) GetOneProject(ctx context.Context, projectID string) } // GetOneProjectByName gets a single project by its name. +// // See more: https://docs.atlas.mongodb.com/reference/api/project-get-one-by-name/ func (s *ProjectsServiceOp) GetOneProjectByName(ctx context.Context, projectName string) (*Project, *Response, error) { if projectName == "" { @@ -149,6 +154,7 @@ func (s *ProjectsServiceOp) GetOneProjectByName(ctx context.Context, projectName } // Create creates a project. +// // See more: https://docs.atlas.mongodb.com/reference/api/project-create-one/ func (s *ProjectsServiceOp) Create(ctx context.Context, createRequest *Project) (*Project, *Response, error) { if createRequest == nil { @@ -170,6 +176,7 @@ func (s *ProjectsServiceOp) Create(ctx context.Context, createRequest *Project) } // Delete deletes a project. +// // See more: https://docs.atlas.mongodb.com/reference/api/project-delete-one/ func (s *ProjectsServiceOp) Delete(ctx context.Context, projectID string) (*Response, error) { if projectID == "" { @@ -189,6 +196,7 @@ func (s *ProjectsServiceOp) Delete(ctx context.Context, projectID string) (*Resp } // GetProjectTeamsAssigned gets all the teams assigned to a project. +// // See more: https://docs.atlas.mongodb.com/reference/api/project-get-teams/ func (s *ProjectsServiceOp) GetProjectTeamsAssigned(ctx context.Context, projectID string) (*TeamsAssigned, *Response, error) { if projectID == "" { @@ -212,6 +220,7 @@ func (s *ProjectsServiceOp) GetProjectTeamsAssigned(ctx context.Context, project } // AddTeamsToProject adds teams to a project +// // See more: https://docs.atlas.mongodb.com/reference/api/project-add-team/ func (s *ProjectsServiceOp) AddTeamsToProject(ctx context.Context, projectID string, createRequest []*ProjectTeam) (*TeamsAssigned, *Response, error) { if createRequest == nil { @@ -233,3 +242,25 @@ func (s *ProjectsServiceOp) AddTeamsToProject(ctx context.Context, projectID str return root, resp, err } + +// RemoveUserFromProject removes user from a project +// +// See more: https://docs.atlas.mongodb.com/reference/api/project-remove-user/ +func (s *ProjectsServiceOp) RemoveUserFromProject(ctx context.Context, projectID, userID string) (*Response, error) { + if projectID == "" { + return nil, NewArgError("projectID", "must be set") + } + + if userID == "" { + return nil, NewArgError("userID", "must be set") + } + + path := fmt.Sprintf("%s/%s/users/%s", projectBasePath, projectID, userID) + req, err := s.Client.NewRequest(ctx, http.MethodDelete, path, nil) + if err != nil { + return nil, err + } + + resp, err := s.Client.Do(ctx, req, nil) + return resp, err +} diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/search.go b/vendor/go.mongodb.org/atlas/mongodbatlas/search.go index 1d68c2af56..b6ca5e5583 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/search.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/search.go @@ -63,7 +63,7 @@ func (s *SearchServiceOp) ListIndexes(ctx context.Context, groupID, clusterName, return root, resp, err } -// Get gets one Atlas Search index by its indexId. +// GetIndex gets one Atlas Search index by its indexId. // // See more: https://docs.atlas.mongodb.com/reference/api/fts-indexes-get-one/ func (s *SearchServiceOp) GetIndex(ctx context.Context, groupID, clusterName, indexID string) (*SearchIndex, *Response, error) { @@ -91,7 +91,7 @@ func (s *SearchServiceOp) GetIndex(ctx context.Context, groupID, clusterName, in return root, resp, err } -// Create creates an Atlas Search index. +// CreateIndex creates an Atlas Search index. // // See more: https://docs.atlas.mongodb.com/reference/api/fts-indexes-create-one/ func (s *SearchServiceOp) CreateIndex(ctx context.Context, projectID, clusterName string, r *SearchIndex) (*SearchIndex, *Response, error) { @@ -116,7 +116,7 @@ func (s *SearchServiceOp) CreateIndex(ctx context.Context, projectID, clusterNam return root, resp, err } -// Update updates an Atlas Search index by its indexId. +// UpdateIndex updates an Atlas Search index by its indexId. // // See more: https://docs.atlas.mongodb.com/reference/api/fts-indexes-update-one/ func (s *SearchServiceOp) UpdateIndex(ctx context.Context, projectID, clusterName, indexID string, r *SearchIndex) (*SearchIndex, *Response, error) { @@ -144,7 +144,7 @@ func (s *SearchServiceOp) UpdateIndex(ctx context.Context, projectID, clusterNam return root, resp, err } -// Delete deletes one Atlas Search index by its indexId. +// DeleteIndex deletes one Atlas Search index by its indexId. // // See more: https://docs.atlas.mongodb.com/reference/api/fts-indexes-delete-one/ func (s *SearchServiceOp) DeleteIndex(ctx context.Context, projectID, clusterName, indexID string) (*Response, error) { diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/teams.go b/vendor/go.mongodb.org/atlas/mongodbatlas/teams.go index adb433de8e..21694370fa 100644 --- a/vendor/go.mongodb.org/atlas/mongodbatlas/teams.go +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/teams.go @@ -12,6 +12,7 @@ const ( // TeamsService is an interface for interfacing with the Teams // endpoints of the MongoDB Atlas API. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams/ type TeamsService interface { List(context.Context, string, *ListOptions) ([]Team, *Response, error) @@ -33,13 +34,14 @@ type TeamsServiceOp service var _ TeamsService = &TeamsServiceOp{} -// Teams represents a array of project +// TeamsResponse represents a array of project type TeamsResponse struct { Links []*Link `json:"links"` Results []Team `json:"results"` TotalCount int `json:"totalCount"` } +// Team defines an Atlas team structure type Team struct { ID string `json:"id,omitempty"` Name string `json:"name"` @@ -53,23 +55,27 @@ type AtlasUserAssigned struct { TotalCount int `json:"totalCount"` } +// TeamUpdateRoles update request body type TeamUpdateRoles struct { RoleNames []string `json:"roleNames"` } +// TeamUpdateRolesResponse update roles response type TeamUpdateRolesResponse struct { Links []*Link `json:"links"` Results []TeamRoles `json:"results"` TotalCount int `json:"totalCount"` } +// TeamRoles List of roles for a team type TeamRoles struct { Links []*Link `json:"links"` RoleNames []string `json:"roleNames"` TeamID string `json:"teamId"` } -// GetAllTeams gets all teams. +// List gets all teams. +// // See more: https://docs.atlas.mongodb.com/reference/api/project-get-all/ func (s *TeamsServiceOp) List(ctx context.Context, orgID string, listOptions *ListOptions) ([]Team, *Response, error) { path := fmt.Sprintf(teamsBasePath, orgID) @@ -99,6 +105,7 @@ func (s *TeamsServiceOp) List(ctx context.Context, orgID string, listOptions *Li } // Get gets a single team in the organization by team ID. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams-get-one-by-id/ func (s *TeamsServiceOp) Get(ctx context.Context, orgID, teamID string) (*Team, *Response, error) { if teamID == "" { @@ -123,6 +130,7 @@ func (s *TeamsServiceOp) Get(ctx context.Context, orgID, teamID string) (*Team, } // GetOneTeamByName gets a single project by its name. +// // See more: https://docs.atlas.mongodb.com/reference/api/project-get-one-by-name/ func (s *TeamsServiceOp) GetOneTeamByName(ctx context.Context, orgID, teamName string) (*Team, *Response, error) { if teamName == "" { @@ -147,6 +155,7 @@ func (s *TeamsServiceOp) GetOneTeamByName(ctx context.Context, orgID, teamName s } // GetTeamUsersAssigned gets all the users assigned to a team. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams-get-all-users/ func (s *TeamsServiceOp) GetTeamUsersAssigned(ctx context.Context, orgID, teamID string) ([]AtlasUser, *Response, error) { if orgID == "" { @@ -175,6 +184,7 @@ func (s *TeamsServiceOp) GetTeamUsersAssigned(ctx context.Context, orgID, teamID } // Create creates a team. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams-create-one/ func (s *TeamsServiceOp) Create(ctx context.Context, orgID string, createRequest *Team) (*Team, *Response, error) { if createRequest == nil { @@ -195,7 +205,8 @@ func (s *TeamsServiceOp) Create(ctx context.Context, orgID string, createRequest return root, resp, err } -// RenameTeam renames a team +// Rename renames a team. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams-rename-one/ func (s *TeamsServiceOp) Rename(ctx context.Context, orgID, teamID, teamName string) (*Team, *Response, error) { if teamName == "" { @@ -222,6 +233,7 @@ func (s *TeamsServiceOp) Rename(ctx context.Context, orgID, teamID, teamName str } // UpdateTeamRoles Update the roles of a team in an Atlas project. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams-update-roles/ func (s *TeamsServiceOp) UpdateTeamRoles(ctx context.Context, orgID, teamID string, updateTeamRolesRequest *TeamUpdateRoles) ([]TeamRoles, *Response, error) { if updateTeamRolesRequest == nil { @@ -249,6 +261,7 @@ func (s *TeamsServiceOp) UpdateTeamRoles(ctx context.Context, orgID, teamID stri } // AddUsersToTeam adds a users from the organization associated with {ORG-ID} to the team with ID {TEAM-ID}. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams-add-user/ func (s *TeamsServiceOp) AddUsersToTeam(ctx context.Context, orgID, teamID string, usersID []string) ([]AtlasUser, *Response, error) { if len(usersID) < 1 { @@ -283,6 +296,7 @@ func (s *TeamsServiceOp) AddUsersToTeam(ctx context.Context, orgID, teamID strin } // RemoveUserToTeam removes the specified user from the specified team. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams-remove-user/ func (s *TeamsServiceOp) RemoveUserToTeam(ctx context.Context, orgID, teamID, userID string) (*Response, error) { if userID == "" { @@ -306,6 +320,7 @@ func (s *TeamsServiceOp) RemoveUserToTeam(ctx context.Context, orgID, teamID, us } // RemoveTeamFromOrganization deletes the team with ID {TEAM-ID} from the organization specified to {ORG-ID}. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams-delete-one/ func (s *TeamsServiceOp) RemoveTeamFromOrganization(ctx context.Context, orgID, teamID string) (*Response, error) { if teamID == "" { @@ -329,6 +344,7 @@ func (s *TeamsServiceOp) RemoveTeamFromOrganization(ctx context.Context, orgID, } // RemoveTeamFromProject removes the specified team from the specified project. +// // See more: https://docs.atlas.mongodb.com/reference/api/teams-remove-from-project/ func (s *TeamsServiceOp) RemoveTeamFromProject(ctx context.Context, groupID, teamID string) (*Response, error) { if teamID == "" { diff --git a/vendor/go.mongodb.org/atlas/mongodbatlas/third_party_integration.go b/vendor/go.mongodb.org/atlas/mongodbatlas/third_party_integration.go new file mode 100644 index 0000000000..4f4697e371 --- /dev/null +++ b/vendor/go.mongodb.org/atlas/mongodbatlas/third_party_integration.go @@ -0,0 +1,202 @@ +package mongodbatlas + +import ( + "context" + "fmt" + "net/http" +) + +const ( + integrationBasePath = "groups/%s/integrations" +) + +// IntegrationsService is an interface for interfacing with the Third-Party Integrations +// endpoints of the MongoDB Atlas API. +// +// See more: https://docs.atlas.mongodb.com/reference/api/third-party-integration-settings/ +type IntegrationsService interface { + Create(context.Context, string, string, *ThirdPartyIntegration) (*ThirdPartyIntegrations, *Response, error) + Replace(context.Context, string, string, *ThirdPartyIntegration) (*ThirdPartyIntegrations, *Response, error) + Delete(context.Context, string, string) (*Response, error) + Get(context.Context, string, string) (*ThirdPartyIntegration, *Response, error) + List(context.Context, string) (*ThirdPartyIntegrations, *Response, error) +} + +// IntegrationsServiceOp handles communication with the third-party integrations related methods of the MongoDB Atlas API +type IntegrationsServiceOp service + +var _ IntegrationsService = &IntegrationsServiceOp{} + +// ThirdPartyIntegration contains parameters for different third-party services +type ThirdPartyIntegration struct { + Type string `json:"type,omitempty"` + LicenseKey string `json:"licenseKey,omitempty"` + AccountID string `json:"accountId,omitempty"` + WriteToken string `json:"writeToken,omitempty"` + ReadToken string `json:"readToken,omitempty"` + APIKey string `json:"apiKey,omitempty"` + Region string `json:"region,omitempty"` + ServiceKey string `json:"serviceKey,omitempty"` + APIToken string `json:"apiToken,omitempty"` + TeamName string `json:"teamName,omitempty"` + ChannelName string `json:"channelName,omitempty"` + RoutingKey string `json:"routingKey,omitempty"` + FlowName string `json:"flowName,omitempty"` + OrgName string `json:"orgName,omitempty"` + URL string `json:"url,omitempty"` + Secret string `json:"secret,omitempty"` +} + +// ThirdPartyIntegrations contains the response from the endpoint +type ThirdPartyIntegrations struct { + Links []*Link `json:"links"` + Results []*ThirdPartyIntegration `json:"results"` + TotalCount int `json:"totalCount"` +} + +// Create adds a new third-party integration configuration. +// +// See more: https://docs.atlas.mongodb.com/reference/api/third-party-integration-settings-create/index.html +func (s *IntegrationsServiceOp) Create(ctx context.Context, projectID, integrationType string, body *ThirdPartyIntegration) (*ThirdPartyIntegrations, *Response, error) { + if projectID == "" { + return nil, nil, NewArgError("projectID", "must be set") + } + + if integrationType == "" { + return nil, nil, NewArgError("integrationType", "must be set") + } + + basePath := fmt.Sprintf(integrationBasePath, projectID) + path := fmt.Sprintf("%s/%s", basePath, integrationType) + + req, err := s.Client.NewRequest(ctx, http.MethodPost, path, body) + if err != nil { + return nil, nil, err + } + + root := new(ThirdPartyIntegrations) + resp, err := s.Client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + if l := root.Links; l != nil { + resp.Links = l + } + + return root, resp, nil +} + +// Replace replaces the third-party integration configuration with a new configuration, or add a new configuration if there is no configuration. +// +// https://docs.atlas.mongodb.com/reference/api/third-party-integration-settings-update/ +func (s *IntegrationsServiceOp) Replace(ctx context.Context, projectID, integrationType string, body *ThirdPartyIntegration) (*ThirdPartyIntegrations, *Response, error) { + if projectID == "" { + return nil, nil, NewArgError("projectID", "must be set") + } + + if integrationType == "" { + return nil, nil, NewArgError("integrationType", "must be set") + } + + basePath := fmt.Sprintf(integrationBasePath, projectID) + path := fmt.Sprintf("%s/%s", basePath, integrationType) + + req, err := s.Client.NewRequest(ctx, http.MethodPut, path, body) + if err != nil { + return nil, nil, err + } + + root := new(ThirdPartyIntegrations) + resp, err := s.Client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + if l := root.Links; l != nil { + resp.Links = l + } + + return root, resp, nil +} + +// Delete removes the third-party integration configuration +// +// https://docs.atlas.mongodb.com/reference/api/third-party-integration-settings-delete/ +func (s *IntegrationsServiceOp) Delete(ctx context.Context, projectID, integrationType string) (*Response, error) { + if projectID == "" { + return nil, NewArgError("projectID", "must be set") + } + + if integrationType == "" { + return nil, NewArgError("integrationType", "must be set") + } + + basePath := fmt.Sprintf(integrationBasePath, projectID) + path := fmt.Sprintf("%s/%s", basePath, integrationType) + + req, err := s.Client.NewRequest(ctx, http.MethodDelete, path, nil) + if err != nil { + return nil, err + } + + resp, err := s.Client.Do(ctx, req, nil) + return resp, err +} + +// Get retrieves a specific third-party integration configuration +// +// https://docs.atlas.mongodb.com/reference/api/third-party-integration-settings-get-one/ +func (s *IntegrationsServiceOp) Get(ctx context.Context, projectID, integrationType string) (*ThirdPartyIntegration, *Response, error) { + if projectID == "" { + return nil, nil, NewArgError("projectID", "must be set") + } + + if integrationType == "" { + return nil, nil, NewArgError("integrationType", "must be set") + } + + basePath := fmt.Sprintf(integrationBasePath, projectID) + path := fmt.Sprintf("%s/%s", basePath, integrationType) + + req, err := s.Client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(ThirdPartyIntegration) + resp, err := s.Client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + return root, resp, nil +} + +// List retrieves all third-party integration configurations. +// +// See more: https://docs.atlas.mongodb.com/reference/api/third-party-integration-settings-get-all/ +func (s *IntegrationsServiceOp) List(ctx context.Context, projectID string) (*ThirdPartyIntegrations, *Response, error) { + if projectID == "" { + return nil, nil, NewArgError("projectID", "must be set") + } + + path := fmt.Sprintf(integrationBasePath, projectID) + + req, err := s.Client.NewRequest(ctx, http.MethodGet, path, nil) + if err != nil { + return nil, nil, err + } + + root := new(ThirdPartyIntegrations) + resp, err := s.Client.Do(ctx, req, root) + if err != nil { + return nil, resp, err + } + + if l := root.Links; l != nil { + resp.Links = l + } + + return root, resp, nil +} diff --git a/vendor/modules.txt b/vendor/modules.txt index f8dd643112..0854d85391 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -476,7 +476,7 @@ github.com/zclconf/go-cty/cty/msgpack github.com/zclconf/go-cty/cty/set # github.com/zclconf/go-cty-yaml v1.0.1 github.com/zclconf/go-cty-yaml -# go.mongodb.org/atlas v0.4.1-0.20200820152733-8dc4a7c19a2b +# go.mongodb.org/atlas v0.4.1-0.20200903102338-049d0778b833 ## explicit go.mongodb.org/atlas/mongodbatlas # go.opencensus.io v0.22.3 diff --git a/website/docs/d/database_user.html.markdown b/website/docs/d/database_user.html.markdown index 3414363bb5..1dbd718fc8 100644 --- a/website/docs/d/database_user.html.markdown +++ b/website/docs/d/database_user.html.markdown @@ -63,6 +63,9 @@ In addition to all arguments above, the following attributes are exported: * `roles` - List of user’s roles and the databases / collections on which the roles apply. A role allows the user to perform particular actions on the specified database. A role on the admin database can include privileges that apply to the other databases as well. See [Roles](#roles) below for more details. * `x509_type` - X.509 method by which the provided username is authenticated. * `aws_iam_type` - The new database user authenticates with AWS IAM credentials. Default is `NONE`, `USER` means user has AWS IAM user credentials, `ROLE` - means user has credentials associated with an AWS IAM role. +* `scopes` - Array of clusters and Atlas Data Lakes that this user has access to. + * `name` - Name of the cluster or Atlas Data Lake that the user has access to. + * `type` - Type of resource that the user has access to. Valid values are: `CLUSTER` and `DATA_LAKE` ### Roles diff --git a/website/docs/d/database_users.html.markdown b/website/docs/d/database_users.html.markdown index d8afa01dbf..981bb0cd62 100644 --- a/website/docs/d/database_users.html.markdown +++ b/website/docs/d/database_users.html.markdown @@ -74,6 +74,9 @@ Possible values include: * `x509_type` - X.509 method by which the provided username is authenticated. * `aws_iam_type` - The new database user authenticates with AWS IAM credentials. Default is `NONE`, `USER` means user has AWS IAM user credentials, `ROLE` - means user has credentials associated with an AWS IAM role. +* `scopes` - Array of clusters and Atlas Data Lakes that this user has access to. + * `name` - Name of the cluster or Atlas Data Lake that the user has access to. + * `type` - Type of resource that the user has access to. Valid values are: `CLUSTER` and `DATA_LAKE` ### Roles diff --git a/website/docs/r/database_user.html.markdown b/website/docs/r/database_user.html.markdown index 582081235d..282937f9cf 100644 --- a/website/docs/r/database_user.html.markdown +++ b/website/docs/r/database_user.html.markdown @@ -39,6 +39,16 @@ resource "mongodbatlas_database_user" "test" { key = "My Key" value = "My Value" } + + scopes { + name = "My cluster name" + type = "CLUSTER" + } + + scopes { + name = "My second cluster name" + type = "CLUSTER" + } } ``` @@ -59,6 +69,11 @@ resource "mongodbatlas_database_user" "test" { key = "%s" value = "%s" } + + scopes { + name = "My cluster name" + type = "CLUSTER" + } } ``` @@ -103,6 +118,12 @@ Containing key-value pairs that tag and categorize the database user. Each key a * `key` - The key that you want to write. * `value` - The value that you want to write. +### Scopes +Array of clusters and Atlas Data Lakes that this user has access to. If omitted, Atlas grants the user access to all the clusters and Atlas Data Lakes in the project by default. + +* `name` - (Required) Name of the cluster or Atlas Data Lake that the user has access to. +* `type` - (Required) Type of resource that the user has access to. Valid values are: `CLUSTER` and `DATA_LAKE` + ## Attributes Reference In addition to all arguments above, the following attributes are exported: