Skip to content

Commit

Permalink
Merge branch 'main' into apps_datasource
Browse files Browse the repository at this point in the history
  • Loading branch information
Dray56 authored Oct 30, 2024
2 parents 8b94ce6 + c2e178a commit 3dd83bb
Show file tree
Hide file tree
Showing 28 changed files with 1,351 additions and 95 deletions.
50 changes: 50 additions & 0 deletions docs/data-sources/space_roles.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
---
page_title: "cloudfoundry_space_roles Data Source - terraform-provider-cloudfoundry"
subcategory: ""
description: |-
Gets information on Cloud Foundry roles within a space.
---

# cloudfoundry_space_roles (Data Source)

Gets information on Cloud Foundry roles within a space.

## Example Usage

```terraform
data "cloudfoundry_space_roles" "roles" {
space = "02c0cc92-6ecc-44b1-b7b2-096ca19ee143"
}
output "role_objects" {
value = data.cloudfoundry_space_roles.roles
}
```

<!-- schema generated by tfplugindocs -->
## Schema

### Required

- `space` (String) The guid of the space the role is assigned to

### Optional

- `type` (String) Valid space role type to filter for; see [Valid role types](https://v3-apidocs.cloudfoundry.org/version/3.154.0/index.html#valid-role-types)
- `user` (String) The guid of the cloudfoundry user the role is assigned to for filtering

### Read-Only

- `roles` (Attributes List) The list of space roles (see [below for nested schema](#nestedatt--roles))

<a id="nestedatt--roles"></a>
### Nested Schema for `roles`

Read-Only:

- `created_at` (String) The date and time when the resource was created in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format.
- `id` (String) The guid for the role
- `space` (String) The guid of the organization the role is assigned to
- `type` (String) role type
- `updated_at` (String) The date and time when the resource was updated in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format.
- `user` (String) The guid of the cloudfoundry user the role is assigned to
7 changes: 7 additions & 0 deletions examples/data-sources/cloudfoundry_space_roles/data-source.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
data "cloudfoundry_space_roles" "roles" {
space = "02c0cc92-6ecc-44b1-b7b2-096ca19ee143"
}

output "role_objects" {
value = data.cloudfoundry_space_roles.roles
}
12 changes: 6 additions & 6 deletions internal/provider/datasource_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,13 +97,13 @@ func (d *DomainDataSource) Read(ctx context.Context, req datasource.ReadRequest,
return
}

domains, err := d.cfClient.Domains.ListAll(ctx, &client.DomainListOptions{
Names: client.Filter{
Values: []string{
data.Name.ValueString(),
},
domainListOptions := client.NewDomainListOptions()
domainListOptions.Names = client.Filter{
Values: []string{
data.Name.ValueString(),
},
})
}
domains, err := d.cfClient.Domains.ListAll(ctx, domainListOptions)
if err != nil {
resp.Diagnostics.AddError(
"API Error Fetching Domain",
Expand Down
11 changes: 5 additions & 6 deletions internal/provider/datasource_isolation_segment.go
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,14 @@ func (d *IsolationSegmentDataSource) Read(ctx context.Context, req datasource.Re
return
}

getOptions := cfv3client.IsolationSegmentListOptions{
Names: cfv3client.Filter{
Values: []string{
data.Name.ValueString(),
},
getOptions := cfv3client.NewIsolationSegmentOptions()
getOptions.Names = cfv3client.Filter{
Values: []string{
data.Name.ValueString(),
},
}

isolationSegments, err := d.cfClient.IsolationSegments.ListAll(ctx, &getOptions)
isolationSegments, err := d.cfClient.IsolationSegments.ListAll(ctx, getOptions)
if err != nil {
resp.Diagnostics.AddError(
"API Error Fetching Isolation Segment.",
Expand Down
13 changes: 7 additions & 6 deletions internal/provider/datasource_org.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,14 @@ func (d *OrgDataSource) Read(ctx context.Context, req datasource.ReadRequest, re
if resp.Diagnostics.HasError() {
return
}
orgs, err := d.cfClient.Organizations.ListAll(ctx, &cfv3client.OrganizationListOptions{
Names: cfv3client.Filter{
Values: []string{
data.Name.ValueString(),
},

getOptions := cfv3client.NewOrganizationListOptions()
getOptions.Names = cfv3client.Filter{
Values: []string{
data.Name.ValueString(),
},
})
}
orgs, err := d.cfClient.Organizations.ListAll(ctx, getOptions)
if err != nil {
resp.Diagnostics.AddError(
"Unable to fetch org data.",
Expand Down
11 changes: 7 additions & 4 deletions internal/provider/datasource_org_quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,11 +116,14 @@ func (d *OrgQuotaDataSource) Read(ctx context.Context, req datasource.ReadReques
if resp.Diagnostics.HasError() {
return
}
orgsQuotas, err := d.cfClient.OrganizationQuotas.ListAll(ctx, &cfv3client.OrganizationQuotaListOptions{
Names: cfv3client.Filter{
Values: []string{orgQuotaType.Name.ValueString()},

getOptions := cfv3client.NewOrganizationQuotaListOptions()
getOptions.Names = cfv3client.Filter{
Values: []string{
orgQuotaType.Name.ValueString(),
},
})
}
orgsQuotas, err := d.cfClient.OrganizationQuotas.ListAll(ctx, getOptions)
if err != nil {
resp.Diagnostics.AddError(
"Unable to fetch org quota data.",
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/datasource_orgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (d *OrgsDataSource) Read(ctx context.Context, req datasource.ReadRequest, r
return
}

orgsListOptions := &cfv3client.OrganizationListOptions{}
orgsListOptions := cfv3client.NewOrganizationListOptions()
if !data.Name.IsNull() {
orgsListOptions.Names = cfv3client.Filter{
Values: []string{
Expand Down
13 changes: 7 additions & 6 deletions internal/provider/datasource_security_group.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,14 @@ func (d *SecurityGroupDataSource) Read(ctx context.Context, req datasource.ReadR
return
}

securityGroups, err := d.cfClient.SecurityGroups.ListAll(ctx, &client.SecurityGroupListOptions{
Names: client.Filter{
Values: []string{
data.Name.ValueString(),
},
getOptions := client.NewSecurityGroupListOptions()
getOptions.Names = client.Filter{
Values: []string{
data.Name.ValueString(),
},
})
}

securityGroups, err := d.cfClient.SecurityGroups.ListAll(ctx, getOptions)
if err != nil {
resp.Diagnostics.AddError(
"API Error Fetching Security Group",
Expand Down
11 changes: 5 additions & 6 deletions internal/provider/datasource_service_credential_binding.go
Original file line number Diff line number Diff line change
Expand Up @@ -113,11 +113,10 @@ func (d *ServiceCredentialBindingDataSource) Read(ctx context.Context, req datas
return
}

getOptions := cfv3client.ServiceCredentialBindingListOptions{
ServiceInstanceGUIDs: cfv3client.Filter{
Values: []string{
data.ServiceInstance.ValueString(),
},
getOptions := cfv3client.NewServiceCredentialBindingListOptions()
getOptions.ServiceInstanceGUIDs = cfv3client.Filter{
Values: []string{
data.ServiceInstance.ValueString(),
},
}

Expand All @@ -136,7 +135,7 @@ func (d *ServiceCredentialBindingDataSource) Read(ctx context.Context, req datas
}
}

svcCredentialBindings, err := d.cfClient.ServiceCredentialBindings.ListAll(ctx, &getOptions)
svcCredentialBindings, err := d.cfClient.ServiceCredentialBindings.ListAll(ctx, getOptions)
if err != nil {
resp.Diagnostics.AddError(
"API Error Fetching Service Credential Binding.",
Expand Down
17 changes: 11 additions & 6 deletions internal/provider/datasource_service_instance.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,14 +117,19 @@ func (d *ServiceInstanceDataSource) Read(ctx context.Context, req datasource.Rea
return
}

svcInstances, err := d.cfClient.ServiceInstances.ListAll(ctx, &cfv3client.ServiceInstanceListOptions{
Names: cfv3client.Filter{
Values: []string{data.Name.ValueString()},
getOptions := cfv3client.NewServiceInstanceListOptions()
getOptions.Names = cfv3client.Filter{
Values: []string{
data.Name.ValueString(),
},
SpaceGUIDs: cfv3client.Filter{
Values: []string{data.Space.ValueString()},
}
getOptions.SpaceGUIDs = cfv3client.Filter{
Values: []string{
data.Space.ValueString(),
},
})
}

svcInstances, err := d.cfClient.ServiceInstances.ListAll(ctx, getOptions)
if err != nil {
resp.Diagnostics.AddError(
"API Error to fetch service instance data.",
Expand Down
2 changes: 1 addition & 1 deletion internal/provider/datasource_service_plans.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ func (d *ServicePlansDataSource) Read(ctx context.Context, req datasource.ReadRe
return
}

svcPlanOpts := &cfv3client.ServicePlanListOptions{}
svcPlanOpts := cfv3client.NewServicePlanListOptions()

if !data.Name.IsNull() {
svcPlanOpts.Names = cfv3client.Filter{
Expand Down
22 changes: 11 additions & 11 deletions internal/provider/datasource_space.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,19 @@ func (d *SpaceDataSource) Read(ctx context.Context, req datasource.ReadRequest,
return
}

//Filtering for spaces under the org with GUID
spaces, err := d.cfClient.Spaces.ListAll(ctx, &client.SpaceListOptions{
OrganizationGUIDs: client.Filter{
Values: []string{
data.OrgId.ValueString(),
},
splo := client.NewSpaceListOptions()
splo.OrganizationGUIDs = client.Filter{
Values: []string{
data.OrgId.ValueString(),
},
Names: client.Filter{
Values: []string{
data.Name.ValueString(),
},
}
splo.Names = client.Filter{
Values: []string{
data.Name.ValueString(),
},
})
}
//Filtering for spaces under the org with GUID
spaces, err := d.cfClient.Spaces.ListAll(ctx, splo)

if err != nil {
resp.Diagnostics.AddError(
Expand Down
8 changes: 5 additions & 3 deletions internal/provider/datasource_space_quota.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,13 @@ func (d *SpaceQuotaDataSource) Read(ctx context.Context, req datasource.ReadRequ
if resp.Diagnostics.HasError() {
return
}
sqlo := &cfv3client.SpaceQuotaListOptions{
Names: cfv3client.Filter{
Values: []string{spaceQuotaType.Name.ValueString()},
sqlo := cfv3client.NewSpaceQuotaListOptions()
sqlo.Names = cfv3client.Filter{
Values: []string{
spaceQuotaType.Name.ValueString(),
},
}

if !spaceQuotaType.Org.IsNull() {
sqlo.OrganizationGUIDs = cfv3client.Filter{
Values: []string{spaceQuotaType.Org.ValueString()},
Expand Down
Loading

0 comments on commit 3dd83bb

Please sign in to comment.