@@ -23,15 +23,13 @@ type AllProjectsDataSource struct {
2323}
2424
2525type AllProjectsDataSourceProjectModel struct {
26- Id types.String `tfsdk:"id"`
27- Slug types.String `tfsdk:"slug"`
28- Name types.String `tfsdk:"name"`
29- Platform types.String `tfsdk:"platform"`
30- DateCreated types.String `tfsdk:"date_created"`
31- Features types.Set `tfsdk:"features"`
32- Color types.String `tfsdk:"color"`
33- Status types.String `tfsdk:"status"`
34- Organization OrganizationModel `tfsdk:"organization"`
26+ Id types.String `tfsdk:"id"`
27+ Slug types.String `tfsdk:"slug"`
28+ Name types.String `tfsdk:"name"`
29+ Platform types.String `tfsdk:"platform"`
30+ DateCreated types.String `tfsdk:"date_created"`
31+ Features types.Set `tfsdk:"features"`
32+ Color types.String `tfsdk:"color"`
3533}
3634
3735func (m * AllProjectsDataSourceProjectModel ) Fill (project sentry.Project ) error {
@@ -48,23 +46,25 @@ func (m *AllProjectsDataSourceProjectModel) Fill(project sentry.Project) error {
4846 m .Features = types .SetValueMust (types .StringType , featureElements )
4947
5048 m .Color = types .StringValue (project .Color )
51- m .Status = types .StringValue (project .Status )
52- m .Organization = OrganizationModel {}
53- if err := m .Organization .Fill (project .Organization ); err != nil {
54- return err
55- }
5649
5750 return nil
5851}
5952
6053type AllProjectsDataSourceModel struct {
6154 Organization types.String `tfsdk:"organization"`
55+ ProjectSlugs types.Set `tfsdk:"project_slugs"`
6256 Projects []AllProjectsDataSourceProjectModel `tfsdk:"projects"`
6357}
6458
6559func (m * AllProjectsDataSourceModel ) Fill (organization string , projects []sentry.Project ) error {
6660 m .Organization = types .StringValue (organization )
6761
62+ projectSlugElements := []attr.Value {}
63+ for _ , project := range projects {
64+ projectSlugElements = append (projectSlugElements , types .StringValue (project .Slug ))
65+ }
66+ m .ProjectSlugs = types .SetValueMust (types .StringType , projectSlugElements )
67+
6868 for _ , project := range projects {
6969 p := AllProjectsDataSourceProjectModel {}
7070 if err := p .Fill (project ); err != nil {
@@ -89,8 +89,14 @@ func (d *AllProjectsDataSource) Schema(ctx context.Context, req datasource.Schem
8989 MarkdownDescription : "The slug of the organization the resource belongs to." ,
9090 Required : true ,
9191 },
92+ "project_slugs" : schema.SetAttribute {
93+ MarkdownDescription : "The slugs of the projects." ,
94+ Computed : true ,
95+ ElementType : types .StringType ,
96+ },
9297 "projects" : schema.SetNestedAttribute {
9398 MarkdownDescription : "The list of projects." ,
99+ Computed : true ,
94100 NestedObject : schema.NestedAttributeObject {
95101 Attributes : map [string ]schema.Attribute {
96102 "id" : schema.StringAttribute {
@@ -122,31 +128,8 @@ func (d *AllProjectsDataSource) Schema(ctx context.Context, req datasource.Schem
122128 MarkdownDescription : "The color of this project." ,
123129 Computed : true ,
124130 },
125- "status" : schema.StringAttribute {
126- MarkdownDescription : "The status of this project." ,
127- Computed : true ,
128- },
129- "organization" : schema.SingleNestedAttribute {
130- MarkdownDescription : "The organization associated with this project." ,
131- Computed : true ,
132- Attributes : map [string ]schema.Attribute {
133- "id" : schema.StringAttribute {
134- MarkdownDescription : "The ID of this organization." ,
135- Computed : true ,
136- },
137- "slug" : schema.StringAttribute {
138- MarkdownDescription : "The slug of this organization." ,
139- Computed : true ,
140- },
141- "name" : schema.StringAttribute {
142- MarkdownDescription : "The name of this organization." ,
143- Computed : true ,
144- },
145- },
146- },
147131 },
148132 },
149- Computed : true ,
150133 },
151134 },
152135 }
@@ -161,10 +144,10 @@ func (d *AllProjectsDataSource) Read(ctx context.Context, req datasource.ReadReq
161144 }
162145
163146 var allProjects []sentry.Project
164- params := & sentry.ListProjectsParams {}
147+ params := & sentry.ListOrganizationProjectsParams {}
165148
166149 for {
167- projects , apiResp , err := d .client .Projects .List (ctx , params )
150+ projects , apiResp , err := d .client .OrganizationProjects .List (ctx , data . Organization . ValueString () , params )
168151 if err != nil {
169152 resp .Diagnostics .AddError ("Client Error" , fmt .Sprintf ("Read error: %s" , err ))
170153 return
0 commit comments