From 9bcdaf18e770a081be2f35f60334f90164df46ff Mon Sep 17 00:00:00 2001 From: skarimo <40482491+skarimo@users.noreply.github.com> Date: Mon, 5 Jun 2023 14:28:47 -0400 Subject: [PATCH] [datadog_team] Add datadog team data sources (#1946) * add teams datasources * add tests * update docs * apply code review suggestions * apply code review suggestions * update codeowners --- .github/CODEOWNERS | 2 +- .../fwprovider/data_source_datadog_team.go | 172 ++++++++++++ .../data_source_datadog_team_memberships.go | 146 ++++++++++ datadog/fwprovider/framework_provider.go | 2 + .../TestAccDatadogTeamDatasourceBasic.freeze | 1 + .../TestAccDatadogTeamDatasourceBasic.yaml | 122 ++++++++ ...tadogTeamMembershipsDatasourceBasic.freeze | 1 + ...DatadogTeamMembershipsDatasourceBasic.yaml | 261 ++++++++++++++++++ ...ta_source_datadog_team_memberships_test.go | 52 ++++ .../tests/data_source_datadog_team_test.go | 41 +++ datadog/tests/provider_test.go | 2 + docs/data-sources/team.md | 39 +++ docs/data-sources/team_memberships.md | 48 ++++ .../data-sources/datadog_team/data-source.tf | 3 + .../datadog_team_memberships/data-source.tf | 4 + 15 files changed, 895 insertions(+), 1 deletion(-) create mode 100644 datadog/fwprovider/data_source_datadog_team.go create mode 100644 datadog/fwprovider/data_source_datadog_team_memberships.go create mode 100644 datadog/tests/cassettes/TestAccDatadogTeamDatasourceBasic.freeze create mode 100644 datadog/tests/cassettes/TestAccDatadogTeamDatasourceBasic.yaml create mode 100644 datadog/tests/cassettes/TestAccDatadogTeamMembershipsDatasourceBasic.freeze create mode 100644 datadog/tests/cassettes/TestAccDatadogTeamMembershipsDatasourceBasic.yaml create mode 100644 datadog/tests/data_source_datadog_team_memberships_test.go create mode 100644 datadog/tests/data_source_datadog_team_test.go create mode 100644 docs/data-sources/team.md create mode 100644 docs/data-sources/team_memberships.md create mode 100644 examples/data-sources/datadog_team/data-source.tf create mode 100644 examples/data-sources/datadog_team_memberships/data-source.tf diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 1aee60bc4..03fde3096 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -43,7 +43,7 @@ datadog/*datadog_service_level_objective* @DataDog/integrations-tools-and-librar docs/resources/service_level_objective* @DataDog/integrations-tools-and-libraries @DataDog/slo-app @DataDog/documentation datadog/*datadog_synthetics* @DataDog/integrations-tools-and-libraries @DataDog/synthetics-app docs/resources/synthetics* @DataDog/integrations-tools-and-libraries @DataDog/synthetics-app @DataDog/documentation -datadog/*datadog_team* @DataDog/integrations-tools-and-libraries @DataDog/core-app +datadog/**/*datadog_team* @DataDog/integrations-tools-and-libraries @DataDog/core-app docs/resources/team* @DataDog/integrations-tools-and-libraries @DataDog/core-app @DataDog/documentation datadog/*datadog_timeboard* @DataDog/integrations-tools-and-libraries @DataDog/dashboards docs/resources/timeboard* @DataDog/integrations-tools-and-libraries @DataDog/dashboards @DataDog/documentation diff --git a/datadog/fwprovider/data_source_datadog_team.go b/datadog/fwprovider/data_source_datadog_team.go new file mode 100644 index 000000000..59d4b6fd0 --- /dev/null +++ b/datadog/fwprovider/data_source_datadog_team.go @@ -0,0 +1,172 @@ +package fwprovider + +import ( + "context" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils" +) + +var ( + _ datasource.DataSource = &DatadogTeamDataSource{} +) + +func NewDatadogTeamDataSource() datasource.DataSource { + return &DatadogTeamDataSource{} +} + +type DatadogTeamDataSourceModel struct { + // Query Parameters + TeamID types.String `tfsdk:"team_id"` + FilterKeyword types.String `tfsdk:"filter_keyword"` + // Results + ID types.String `tfsdk:"id"` + Description types.String `tfsdk:"description"` + Handle types.String `tfsdk:"handle"` + LinkCount types.Int64 `tfsdk:"link_count"` + Summary types.String `tfsdk:"summary"` + UserCount types.Int64 `tfsdk:"user_count"` + Name types.String `tfsdk:"name"` +} + +type DatadogTeamDataSource struct { + Api *datadogV2.TeamsApi + Auth context.Context +} + +func (r *DatadogTeamDataSource) Configure(_ context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) { + if request.ProviderData == nil { + return + } + + providerData, ok := request.ProviderData.(*FrameworkProvider) + if !ok { + response.Diagnostics.AddError("Unexpected Resource Configure Type", "") + return + } + + r.Api = providerData.DatadogApiInstances.GetTeamsApiV2() + r.Auth = providerData.Auth +} + +func (d *DatadogTeamDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "team" +} + +func (d *DatadogTeamDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Use this data source to retrieve information about an existing Datadog team.", + Attributes: map[string]schema.Attribute{ + // Datasource ID + "id": utils.ResourceIDAttribute(), + // Datasource Parameters + "team_id": schema.StringAttribute{ + Description: "The team's identifier.", + Optional: true, + Computed: true, + }, + "filter_keyword": schema.StringAttribute{ + Description: "Search query. Can be team name, team handle, or email of team member.", + Optional: true, + }, + // Computed values + "description": schema.StringAttribute{ + Computed: true, + Description: "Free-form markdown description/content for the team's homepage.", + }, + "handle": schema.StringAttribute{ + Computed: true, + Description: "The team's handle.", + }, + "link_count": schema.Int64Attribute{ + Description: "The number of links belonging to the team.", + Computed: true, + }, + "summary": schema.StringAttribute{ + Description: "A brief summary of the team, derived from the `description`.", + Computed: true, + }, + "user_count": schema.Int64Attribute{ + Description: "The number of users belonging to the team.", + Computed: true, + }, + "name": schema.StringAttribute{ + Computed: true, + Description: "The name of the team.", + }, + }, + } + +} + +func (d *DatadogTeamDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var state DatadogTeamDataSourceModel + resp.Diagnostics.Append(req.Config.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + if !state.TeamID.IsNull() { + teamID := state.TeamID.ValueString() + ddResp, _, err := d.Api.GetTeam(d.Auth, teamID) + if err != nil { + resp.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error getting datadog team")) + return + } + + d.updateState(&state, ddResp.Data) + } else if !state.FilterKeyword.IsNull() { + filterKeyword := state.FilterKeyword.ValueString() + optionalParams := datadogV2.ListTeamsOptionalParameters{ + FilterKeyword: &filterKeyword, + } + + ddResp, _, err := d.Api.ListTeams(d.Auth, optionalParams) + if err != nil { + resp.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error listing datadog teams")) + return + } + + if len(ddResp.Data) > 1 { + resp.Diagnostics.AddError("filter keyword returned more than one result, use more specific search criteria", "") + return + } + if len(ddResp.Data) == 0 { + resp.Diagnostics.AddError("filter keyword returned no result", "") + return + } + + d.updateStateFromListResponse(&state, &ddResp.Data[0]) + } + + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *DatadogTeamDataSource) updateState(state *DatadogTeamDataSourceModel, teamData *datadogV2.TeamData) { + state.ID = types.StringValue(teamData.GetId()) + attributes := teamData.GetAttributes() + + state.Description = types.StringValue(attributes.GetDescription()) + state.Handle = types.StringValue(attributes.GetHandle()) + state.LinkCount = types.Int64Value(int64(attributes.GetLinkCount())) + state.Name = types.StringValue(attributes.GetName()) + state.UserCount = types.Int64Value(int64(attributes.GetUserCount())) + state.Summary = types.StringValue(attributes.GetSummary()) +} + +func (r *DatadogTeamDataSource) updateStateFromListResponse(state *DatadogTeamDataSourceModel, teamData *datadogV2.Team) { + state.ID = types.StringValue(teamData.GetId()) + state.TeamID = types.StringValue(teamData.GetId()) + + attributes := teamData.GetAttributes() + state.Description = types.StringValue(attributes.GetDescription()) + state.Handle = types.StringValue(attributes.GetHandle()) + state.LinkCount = types.Int64Value(int64(attributes.GetLinkCount())) + state.Name = types.StringValue(attributes.GetName()) + state.UserCount = types.Int64Value(int64(attributes.GetUserCount())) + state.Summary = types.StringValue(attributes.GetSummary()) +} diff --git a/datadog/fwprovider/data_source_datadog_team_memberships.go b/datadog/fwprovider/data_source_datadog_team_memberships.go new file mode 100644 index 000000000..ae5a7e382 --- /dev/null +++ b/datadog/fwprovider/data_source_datadog_team_memberships.go @@ -0,0 +1,146 @@ +package fwprovider + +import ( + "context" + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" + "github.com/hashicorp/terraform-plugin-framework/attr" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" + "github.com/hashicorp/terraform-plugin-framework/types" + + "github.com/terraform-providers/terraform-provider-datadog/datadog/internal/utils" +) + +var ( + _ datasource.DataSource = &DatadogTeamMembershipsDataSource{} +) + +type DatadogTeamMembershipsDataSourceModel struct { + // Query Parameters + TeamID types.String `tfsdk:"team_id"` + FilterKeyword types.String `tfsdk:"filter_keyword"` + // Results + ID types.String `tfsdk:"id"` + TeamMemberships []*TeamMembershipModel `tfsdk:"team_memberships"` +} + +func NewDatadogTeamMembershipsDataSource() datasource.DataSource { + return &DatadogTeamMembershipsDataSource{} +} + +type DatadogTeamMembershipsDataSource struct { + Api *datadogV2.TeamsApi + Auth context.Context +} + +func (r *DatadogTeamMembershipsDataSource) Configure(_ context.Context, request datasource.ConfigureRequest, response *datasource.ConfigureResponse) { + if request.ProviderData == nil { + return + } + + providerData, ok := request.ProviderData.(*FrameworkProvider) + if !ok { + response.Diagnostics.AddError("Unexpected Resource Configure Type", "") + return + } + + r.Api = providerData.DatadogApiInstances.GetTeamsApiV2() + r.Auth = providerData.Auth +} + +func (d *DatadogTeamMembershipsDataSource) Metadata(_ context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "team_memberships" +} + +func (d *DatadogTeamMembershipsDataSource) Schema(_ context.Context, _ datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + Description: "Use this data source to retrieve information about existing Datadog team memberships.", + Attributes: map[string]schema.Attribute{ + // Datasource ID + "id": utils.ResourceIDAttribute(), + // Datasource Parameters + "team_id": schema.StringAttribute{ + Description: "The team's identifier.", + Required: true, + }, + "filter_keyword": schema.StringAttribute{ + Description: "Search query, can be user email or name.", + Optional: true, + }, + // Computed values + "team_memberships": schema.ListAttribute{ + Computed: true, + Description: "List of team memberships.", + ElementType: types.ObjectType{ + AttrTypes: map[string]attr.Type{ + "team_id": types.StringType, + "user_id": types.StringType, + "role": types.StringType, + "id": types.StringType, + }, + }, + }, + }, + } + +} + +func (d *DatadogTeamMembershipsDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + var state DatadogTeamMembershipsDataSourceModel + resp.Diagnostics.Append(req.Config.Get(ctx, &state)...) + if resp.Diagnostics.HasError() { + return + } + + var optionalParams datadogV2.GetTeamMembershipsOptionalParameters + teamID := state.TeamID.ValueString() + + if !state.FilterKeyword.IsNull() { + optionalParams.FilterKeyword = state.FilterKeyword.ValueStringPointer() + } + + pageSize := int64(100) + pageNumber := int64(0) + + var userTeams []datadogV2.UserTeam + for { + optionalParams.PageNumber = &pageNumber + optionalParams.PageSize = &pageSize + + ddResp, _, err := d.Api.GetTeamMemberships(d.Auth, teamID, optionalParams) + if err != nil { + resp.Diagnostics.Append(utils.FrameworkErrorDiag(err, "error getting team memberships")) + return + } + + userTeams = append(userTeams, ddResp.GetData()...) + if len(ddResp.GetData()) < 100 { + break + } + pageNumber++ + } + + d.updateState(&state, &userTeams) + + resp.Diagnostics.Append(resp.State.Set(ctx, &state)...) +} + +func (r *DatadogTeamMembershipsDataSource) updateState(state *DatadogTeamMembershipsDataSourceModel, teamData *[]datadogV2.UserTeam) { + state.ID = types.StringValue(fmt.Sprintf("%s:%s", state.TeamID.ValueString(), state.FilterKeyword.ValueString())) + + var teamMemberships []*TeamMembershipModel + for _, user := range *teamData { + membership := TeamMembershipModel{ + ID: types.StringValue(user.GetId()), + TeamId: types.StringValue(state.TeamID.ValueString()), + UserId: types.StringValue(user.Relationships.User.Data.GetId()), + Role: types.StringValue(string(user.Attributes.GetRole())), + } + + teamMemberships = append(teamMemberships, &membership) + } + + state.TeamMemberships = teamMemberships +} diff --git a/datadog/fwprovider/framework_provider.go b/datadog/fwprovider/framework_provider.go index 6d4aa8c2e..b75193fbd 100644 --- a/datadog/fwprovider/framework_provider.go +++ b/datadog/fwprovider/framework_provider.go @@ -50,6 +50,8 @@ var Resources = []func() resource.Resource{ var Datasources = []func() datasource.DataSource{ NewAPIKeyDataSource, NewDatadogIntegrationAWSNamespaceRulesDatasource, + NewDatadogTeamDataSource, + NewDatadogTeamMembershipsDataSource, NewHostsDataSource, NewIPRangesDataSource, NewSensitiveDataScannerGroupOrderDatasource, diff --git a/datadog/tests/cassettes/TestAccDatadogTeamDatasourceBasic.freeze b/datadog/tests/cassettes/TestAccDatadogTeamDatasourceBasic.freeze new file mode 100644 index 000000000..4d70665cd --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogTeamDatasourceBasic.freeze @@ -0,0 +1 @@ +2023-06-01T15:26:11.394314-04:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogTeamDatasourceBasic.yaml b/datadog/tests/cassettes/TestAccDatadogTeamDatasourceBasic.yaml new file mode 100644 index 000000000..dcc2b1b84 --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogTeamDatasourceBasic.yaml @@ -0,0 +1,122 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"attributes":{"description":"Team description","handle":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","name":"tf-testaccdatadogteamdatasourcebasic-local-1685647571"},"type":"team"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/team + method: POST + response: + body: | + {"data":{"type":"team","id":"2b43ecd4-00b2-11ee-8f10-da7ad0900002","attributes":{"name":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","handle":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","summary":"Team description","description":"Team description","created_at":"2023-06-01T19:26:12.510213+00:00","modified_at":"2023-06-01T19:26:12.510218+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/permission-settings"}}}}} + headers: + Content-Type: + - application/json + status: 201 Created + code: 201 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002 + method: GET + response: + body: | + {"data":{"type":"team","id":"2b43ecd4-00b2-11ee-8f10-da7ad0900002","attributes":{"name":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","handle":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","summary":"Team description","description":"Team description","created_at":"2023-06-01T19:26:12.510213+00:00","modified_at":"2023-06-01T19:26:12.510218+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/permission-settings"}}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002 + method: GET + response: + body: | + {"data":{"type":"team","id":"2b43ecd4-00b2-11ee-8f10-da7ad0900002","attributes":{"name":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","handle":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","summary":"Team description","description":"Team description","created_at":"2023-06-01T19:26:12.510213+00:00","modified_at":"2023-06-01T19:26:12.510218+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/permission-settings"}}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002 + method: GET + response: + body: | + {"data":{"type":"team","id":"2b43ecd4-00b2-11ee-8f10-da7ad0900002","attributes":{"name":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","handle":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","summary":"Team description","description":"Team description","created_at":"2023-06-01T19:26:12.510213+00:00","modified_at":"2023-06-01T19:26:12.510218+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/permission-settings"}}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002 + method: GET + response: + body: | + {"data":{"type":"team","id":"2b43ecd4-00b2-11ee-8f10-da7ad0900002","attributes":{"name":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","handle":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","summary":"Team description","description":"Team description","created_at":"2023-06-01T19:26:12.510213+00:00","modified_at":"2023-06-01T19:26:12.510218+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/permission-settings"}}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002 + method: GET + response: + body: | + {"data":{"type":"team","id":"2b43ecd4-00b2-11ee-8f10-da7ad0900002","attributes":{"name":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","handle":"tf-testaccdatadogteamdatasourcebasic-local-1685647571","summary":"Team description","description":"Team description","created_at":"2023-06-01T19:26:12.510213+00:00","modified_at":"2023-06-01T19:26:12.510218+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002/permission-settings"}}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datadoghq.com/api/v2/team/2b43ecd4-00b2-11ee-8f10-da7ad0900002 + method: DELETE + response: + body: "" + headers: {} + status: 204 No Content + code: 204 + duration: "" diff --git a/datadog/tests/cassettes/TestAccDatadogTeamMembershipsDatasourceBasic.freeze b/datadog/tests/cassettes/TestAccDatadogTeamMembershipsDatasourceBasic.freeze new file mode 100644 index 000000000..70eb5da8f --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogTeamMembershipsDatasourceBasic.freeze @@ -0,0 +1 @@ +2023-06-01T15:34:40.708902-04:00 \ No newline at end of file diff --git a/datadog/tests/cassettes/TestAccDatadogTeamMembershipsDatasourceBasic.yaml b/datadog/tests/cassettes/TestAccDatadogTeamMembershipsDatasourceBasic.yaml new file mode 100644 index 000000000..b53ac1dc8 --- /dev/null +++ b/datadog/tests/cassettes/TestAccDatadogTeamMembershipsDatasourceBasic.yaml @@ -0,0 +1,261 @@ +--- +version: 1 +interactions: +- request: + body: | + {"data":{"attributes":{"description":"TeamMemberships description","handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080","name":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080"},"type":"team"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/team + method: POST + response: + body: | + {"data":{"type":"team","id":"5adbd29e-00b3-11ee-8fdc-da7ad0900002","attributes":{"name":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080","handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080","summary":"TeamMemberships description","description":"TeamMemberships description","created_at":"2023-06-01T19:34:41.855326+00:00","modified_at":"2023-06-01T19:34:41.855331+00:00","user_count":0,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/permission-settings"}}}}} + headers: + Content-Type: + - application/json + status: 201 Created + code: 201 + duration: "" +- request: + body: | + {"data":{"attributes":{"email":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com"},"relationships":{"roles":{"data":[]}},"type":"users"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/users + method: POST + response: + body: | + {"data":{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","attributes":{"name":null,"handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","created_at":"2023-06-01T19:34:42.171363+00:00","modified_at":"2023-06-01T19:34:42.176813+00:00","email":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","icon":"https://secure.gravatar.com/avatar/85a2e2098a9791b574edecaef3fb19a2?s=48&d=retro","title":null,"verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending"},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + headers: + Content-Type: + - application/json + status: 201 Created + code: 201 + duration: "" +- request: + body: | + {"data":[{"relationships":{"user":{"data":{"id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","type":"users"}}},"type":"user_invitations"}]} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/user_invitations + method: POST + response: + body: | + {"data":[{"type":"user_invitations","id":"5ba2d736-00b3-11ee-ba40-da7ad0900002","attributes":{"uuid":"5ba2d736-00b3-11ee-ba40-da7ad0900002","login_method":null,"invite_type":"basic_invite","created_at":"2023-06-01T19:34:43.160530+00:00","expires_at":"2023-06-03T19:34:43.037634+00:00"},"relationships":{"user":{"data":{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc"}}}}]} + headers: + Content-Type: + - application/json + status: 201 Created + code: 201 + duration: "" +- request: + body: | + {"data":{"attributes":{"role":"admin"},"relationships":{"user":{"data":{"id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","type":"users"}}},"type":"team_memberships"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships + method: POST + response: + body: | + {"data":{"type":"team_memberships","id":"TeamMembership-5adbd29e-00b3-11ee-8fdc-da7ad0900002-5545935","attributes":{"role":"admin"},"relationships":{"user":{"data":{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc"}}}},"included":[{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","attributes":{"name":null,"handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","email":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","icon":"https://secure.gravatar.com/avatar/85a2e2098a9791b574edecaef3fb19a2?s=48&d=retro","disabled":false,"service_account":false}}]} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100 + method: GET + response: + body: | + {"data":[{"type":"team_memberships","id":"TeamMembership-5adbd29e-00b3-11ee-8fdc-da7ad0900002-5545935","attributes":{"role":"admin"},"relationships":{"user":{"data":{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc"}}}}],"included":[{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","attributes":{"name":null,"handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","email":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","icon":"https://secure.gravatar.com/avatar/85a2e2098a9791b574edecaef3fb19a2?s=48&d=retro","disabled":false,"service_account":false}}],"meta":{"pagination":{"number":0,"first_number":0,"prev_number":0,"next_number":1,"last_number":0,"size":100,"type":"number_size","total":1}},"links":{"self":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100","last":null,"next":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=1&page[size]=100","prev":null,"first":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=0&page[size]=100"}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100 + method: GET + response: + body: | + {"data":[{"type":"team_memberships","id":"TeamMembership-5adbd29e-00b3-11ee-8fdc-da7ad0900002-5545935","attributes":{"role":"admin"},"relationships":{"user":{"data":{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc"}}}}],"included":[{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","attributes":{"name":null,"handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","email":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","icon":"https://secure.gravatar.com/avatar/85a2e2098a9791b574edecaef3fb19a2?s=48&d=retro","disabled":false,"service_account":false}}],"meta":{"pagination":{"number":0,"first_number":0,"prev_number":0,"next_number":1,"last_number":0,"size":100,"type":"number_size","total":1}},"links":{"self":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100","last":null,"next":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=1&page[size]=100","prev":null,"first":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=0&page[size]=100"}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/users/5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc + method: GET + response: + body: | + {"data":{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","attributes":{"name":null,"handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","created_at":"2023-06-01T19:34:42.171363+00:00","modified_at":"2023-06-01T19:34:42.176813+00:00","email":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","icon":"https://secure.gravatar.com/avatar/85a2e2098a9791b574edecaef3fb19a2?s=48&d=retro","title":null,"verified":false,"service_account":false,"disabled":false,"allowed_login_methods":[],"status":"Pending"},"relationships":{"roles":{"data":[]},"org":{"data":{"type":"orgs","id":"4dee724d-00cc-11ea-a77b-570c9d03c6c5"}}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002 + method: GET + response: + body: | + {"data":{"type":"team","id":"5adbd29e-00b3-11ee-8fdc-da7ad0900002","attributes":{"name":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080","handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080","summary":"TeamMemberships description","description":"TeamMemberships description","created_at":"2023-06-01T19:34:41.855326+00:00","modified_at":"2023-06-01T19:34:41.855331+00:00","user_count":1,"link_count":0},"relationships":{"team_links":{"links":{"related":"/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/links"}},"user_team_permissions":{"links":{"related":"/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/permission-settings"}}}}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100 + method: GET + response: + body: | + {"data":[{"type":"team_memberships","id":"TeamMembership-5adbd29e-00b3-11ee-8fdc-da7ad0900002-5545935","attributes":{"role":"admin"},"relationships":{"user":{"data":{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc"}}}}],"included":[{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","attributes":{"name":null,"handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","email":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","icon":"https://secure.gravatar.com/avatar/85a2e2098a9791b574edecaef3fb19a2?s=48&d=retro","disabled":false,"service_account":false}}],"meta":{"pagination":{"number":0,"first_number":0,"prev_number":0,"next_number":1,"last_number":0,"size":100,"type":"number_size","total":1}},"links":{"self":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100","last":null,"next":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=1&page[size]=100","prev":null,"first":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=0&page[size]=100"}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=1&page%5Bsize%5D=100 + method: GET + response: + body: | + {"data":[],"meta":{"pagination":{"number":1,"first_number":0,"prev_number":0,"next_number":2,"last_number":0,"size":100,"type":"number_size","total":1}},"links":{"self":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=1&page%5Bsize%5D=100","last":null,"next":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=2&page[size]=100","prev":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=0&page[size]=100","first":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=0&page[size]=100"}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100 + method: GET + response: + body: | + {"data":[{"type":"team_memberships","id":"TeamMembership-5adbd29e-00b3-11ee-8fdc-da7ad0900002-5545935","attributes":{"role":"admin"},"relationships":{"user":{"data":{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc"}}}}],"included":[{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","attributes":{"name":null,"handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","email":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","icon":"https://secure.gravatar.com/avatar/85a2e2098a9791b574edecaef3fb19a2?s=48&d=retro","disabled":false,"service_account":false}}],"meta":{"pagination":{"number":0,"first_number":0,"prev_number":0,"next_number":1,"last_number":0,"size":100,"type":"number_size","total":1}},"links":{"self":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100","last":null,"next":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=1&page[size]=100","prev":null,"first":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=0&page[size]=100"}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - application/json + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100 + method: GET + response: + body: | + {"data":[{"type":"team_memberships","id":"TeamMembership-5adbd29e-00b3-11ee-8fdc-da7ad0900002-5545935","attributes":{"role":"admin"},"relationships":{"user":{"data":{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc"}}}}],"included":[{"type":"users","id":"5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc","attributes":{"name":null,"handle":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","email":"tf-testaccdatadogteammembershipsdatasourcebasic-local-1685648080@example.com","icon":"https://secure.gravatar.com/avatar/85a2e2098a9791b574edecaef3fb19a2?s=48&d=retro","disabled":false,"service_account":false}}],"meta":{"pagination":{"number":0,"first_number":0,"prev_number":0,"next_number":1,"last_number":0,"size":100,"type":"number_size","total":1}},"links":{"self":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page%5Bnumber%5D=0&page%5Bsize%5D=100","last":null,"next":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=1&page[size]=100","prev":null,"first":"https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships?page[number]=0&page[size]=100"}} + headers: + Content-Type: + - application/json + status: 200 OK + code: 200 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002/memberships/5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc + method: DELETE + response: + body: "" + headers: {} + status: 204 No Content + code: 204 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datadoghq.com/api/v2/team/5adbd29e-00b3-11ee-8fdc-da7ad0900002 + method: DELETE + response: + body: "" + headers: {} + status: 204 No Content + code: 204 + duration: "" +- request: + body: "" + form: {} + headers: + Accept: + - '*/*' + url: https://api.datadoghq.com/api/v2/users/5b0b94a6-00b3-11ee-b6bc-4e34b8fb63bc + method: DELETE + response: + body: "" + headers: {} + status: 204 No Content + code: 204 + duration: "" diff --git a/datadog/tests/data_source_datadog_team_memberships_test.go b/datadog/tests/data_source_datadog_team_memberships_test.go new file mode 100644 index 000000000..3e63d54fa --- /dev/null +++ b/datadog/tests/data_source_datadog_team_memberships_test.go @@ -0,0 +1,52 @@ +package test + +import ( + "context" + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccDatadogTeamMembershipsDatasourceBasic(t *testing.T) { + t.Parallel() + ctx, _, accProviders := testAccFrameworkMuxProviders(context.Background(), t) + uniq := strings.ToLower(uniqueEntityName(ctx, t)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: accProviders, + Steps: []resource.TestStep{ + { + Config: testAccDatasourceTeamMembershipsConfig(uniq), + Check: resource.TestCheckResourceAttr("data.datadog_team_memberships.foo", "team_memberships.0.role", "admin"), + }, + }, + }) +} + +func testAccDatasourceTeamMembershipsConfig(uniq string) string { + return fmt.Sprintf(` +data "datadog_team_memberships" "foo" { + team_id = datadog_team.foo.id + depends_on = [ datadog_team_membership.foo ] +} + +resource "datadog_user" "foo" { + email = "%s@example.com" +} + +resource "datadog_team" "foo" { + description = "TeamMemberships description" + handle = "%s" + name = "%s" +} + +resource "datadog_team_membership" "foo" { + team_id = datadog_team.foo.id + user_id = datadog_user.foo.id + role = "admin" +} +`, uniq, uniq, uniq) +} diff --git a/datadog/tests/data_source_datadog_team_test.go b/datadog/tests/data_source_datadog_team_test.go new file mode 100644 index 000000000..67442b1a7 --- /dev/null +++ b/datadog/tests/data_source_datadog_team_test.go @@ -0,0 +1,41 @@ +package test + +import ( + "context" + "fmt" + "strings" + "testing" + + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" +) + +func TestAccDatadogTeamDatasourceBasic(t *testing.T) { + t.Parallel() + ctx, _, accProviders := testAccFrameworkMuxProviders(context.Background(), t) + uniq := strings.ToLower(uniqueEntityName(ctx, t)) + + resource.Test(t, resource.TestCase{ + PreCheck: func() { testAccPreCheck(t) }, + ProtoV5ProviderFactories: accProviders, + Steps: []resource.TestStep{ + { + Config: testAccDatasourceTeamConfig(uniq), + Check: resource.TestCheckResourceAttr("data.datadog_team.foo", "handle", uniq), + }, + }, + }) +} + +func testAccDatasourceTeamConfig(uniq string) string { + return fmt.Sprintf(` +data "datadog_team" "foo" { + team_id = datadog_team.foo.id +} + +resource "datadog_team" "foo" { + description = "Team description" + handle = "%s" + name = "%s" +} +`, uniq, uniq) +} diff --git a/datadog/tests/provider_test.go b/datadog/tests/provider_test.go index 7117ed653..4e6a5cf97 100644 --- a/datadog/tests/provider_test.go +++ b/datadog/tests/provider_test.go @@ -81,6 +81,8 @@ var testFiles2EndpointTags = map[string]string{ "tests/data_source_datadog_synthetics_locations_test": "synthetics", "tests/data_source_datadog_synthetics_global_variable_test": "synthetics", "tests/data_source_datadog_synthetics_test_test": "synthetics", + "tests/data_source_datadog_team_memberships_test": "team", + "tests/data_source_datadog_team_test": "team", "tests/import_datadog_downtime_test": "downtimes", "tests/import_datadog_integration_pagerduty_test": "integration-pagerduty", "tests/import_datadog_logs_pipeline_test": "logs-pipelines", diff --git a/docs/data-sources/team.md b/docs/data-sources/team.md new file mode 100644 index 000000000..349bf38b8 --- /dev/null +++ b/docs/data-sources/team.md @@ -0,0 +1,39 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "datadog_team Data Source - terraform-provider-datadog" +subcategory: "" +description: |- + Use this data source to retrieve information about an existing Datadog team. +--- + +# datadog_team (Data Source) + +Use this data source to retrieve information about an existing Datadog team. + +## Example Usage + +```terraform +data "datadog_team" "foo" { + team_id = "e6723c40-edb1-11ed-b816-da7ad0900002" +} +``` + + +## Schema + +### Optional + +- `filter_keyword` (String) Search query. Can be team name, team handle, or email of team member. +- `team_id` (String) The team's identifier. + +### Read-Only + +- `description` (String) Free-form markdown description/content for the team's homepage. +- `handle` (String) The team's handle. +- `id` (String) The ID of this resource. +- `link_count` (Number) The number of links belonging to the team. +- `name` (String) The name of the team. +- `summary` (String) A brief summary of the team, derived from the `description`. +- `user_count` (Number) The number of users belonging to the team. + + diff --git a/docs/data-sources/team_memberships.md b/docs/data-sources/team_memberships.md new file mode 100644 index 000000000..a6ed7e6a3 --- /dev/null +++ b/docs/data-sources/team_memberships.md @@ -0,0 +1,48 @@ +--- +# generated by https://github.com/hashicorp/terraform-plugin-docs +page_title: "datadog_team_memberships Data Source - terraform-provider-datadog" +subcategory: "" +description: |- + Use this data source to retrieve information about existing Datadog team memberships. +--- + +# datadog_team_memberships (Data Source) + +Use this data source to retrieve information about existing Datadog team memberships. + +## Example Usage + +```terraform +data "datadog_team_memberships" "foo" { + team_id = "e6723c40-edb1-11ed-b816-da7ad0900002" + filter_keyword = "foo@example.com" +} +``` + + +## Schema + +### Required + +- `team_id` (String) The team's identifier. + +### Optional + +- `filter_keyword` (String) Search query, can be user email or name. + +### Read-Only + +- `id` (String) The ID of this resource. +- `team_memberships` (List of Object) List of team memberships. (see [below for nested schema](#nestedatt--team_memberships)) + + +### Nested Schema for `team_memberships` + +Read-Only: + +- `id` (String) +- `role` (String) +- `team_id` (String) +- `user_id` (String) + + diff --git a/examples/data-sources/datadog_team/data-source.tf b/examples/data-sources/datadog_team/data-source.tf new file mode 100644 index 000000000..34f2bd8e3 --- /dev/null +++ b/examples/data-sources/datadog_team/data-source.tf @@ -0,0 +1,3 @@ +data "datadog_team" "foo" { + team_id = "e6723c40-edb1-11ed-b816-da7ad0900002" +} diff --git a/examples/data-sources/datadog_team_memberships/data-source.tf b/examples/data-sources/datadog_team_memberships/data-source.tf new file mode 100644 index 000000000..098dc3990 --- /dev/null +++ b/examples/data-sources/datadog_team_memberships/data-source.tf @@ -0,0 +1,4 @@ +data "datadog_team_memberships" "foo" { + team_id = "e6723c40-edb1-11ed-b816-da7ad0900002" + filter_keyword = "foo@example.com" +}