From a52f7ab98a0d8c2c41c29ff2fcf51fb5ee9b958d Mon Sep 17 00:00:00 2001 From: Debaditya Ray <65864761+Dray56@users.noreply.github.com> Date: Tue, 5 Nov 2024 12:27:19 +0530 Subject: [PATCH] Added service brokers datasource (#62) Signed-off-by: Ray --- docs/data-sources/service_brokers.md | 54 ++ .../data-source.tf | 7 + .../provider/datasource_service_brokers.go | 126 +++ .../datasource_service_brokers_test.go | 102 +++ .../fixtures/datasource_service_brokers.yaml | 747 ++++++++++++++++++ .../datasource_service_brokers_invalid.yaml | 127 +++ internal/provider/provider.go | 1 + internal/provider/provider_test.go | 1 + internal/provider/types_service_broker.go | 21 + migration-guide/Readme.md | 4 +- 10 files changed, 1188 insertions(+), 2 deletions(-) create mode 100644 docs/data-sources/service_brokers.md create mode 100644 examples/data-sources/cloudfoundry_service_brokers/data-source.tf create mode 100644 internal/provider/datasource_service_brokers.go create mode 100644 internal/provider/datasource_service_brokers_test.go create mode 100644 internal/provider/fixtures/datasource_service_brokers.yaml create mode 100644 internal/provider/fixtures/datasource_service_brokers_invalid.yaml diff --git a/docs/data-sources/service_brokers.md b/docs/data-sources/service_brokers.md new file mode 100644 index 0000000..9962429 --- /dev/null +++ b/docs/data-sources/service_brokers.md @@ -0,0 +1,54 @@ +--- +page_title: "cloudfoundry_service_brokers Data Source - terraform-provider-cloudfoundry" +subcategory: "" +description: |- + Gets information of Service brokers user has access to. +--- + +# cloudfoundry_service_brokers (Data Source) + +Gets information of Service brokers user has access to. + +## Example Usage + +```terraform +data "cloudfoundry_service_brokers" "brokers" { + space = "02c0cc92-6ecc-44b1-b7b2-096ca19ee143" +} + +output "se_brs" { + value = data.cloudfoundry_service_brokers.brokers +} +``` + + +## Schema + +### Optional + +- `name` (String) Name of the service broker to filter by +- `space` (String) GUID of the space to filter by + +### Read-Only + +- `service_brokers` (Attributes List) List of service brokers (see [below for nested schema](#nestedatt--service_brokers)) + + +### Nested Schema for `service_brokers` + +Required: + +- `name` (String) Name of the service broker + +Optional: + +- `annotations` (Map of String) The annotations associated with Cloud Foundry resources. Add as described [here](https://docs.cloudfoundry.org/adminguide/metadata.html#-view-metadata-for-an-object). +- `labels` (Map of String) The labels associated with Cloud Foundry resources. Add as described [here](https://docs.cloudfoundry.org/adminguide/metadata.html#-view-metadata-for-an-object). + +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 of the object. +- `space` (String) The GUID of the space the service broker is restricted to; omitted for globally available service brokers +- `updated_at` (String) The date and time when the resource was updated in [RFC3339](https://www.ietf.org/rfc/rfc3339.txt) format. +- `url` (String) URL of the service broker \ No newline at end of file diff --git a/examples/data-sources/cloudfoundry_service_brokers/data-source.tf b/examples/data-sources/cloudfoundry_service_brokers/data-source.tf new file mode 100644 index 0000000..303fcce --- /dev/null +++ b/examples/data-sources/cloudfoundry_service_brokers/data-source.tf @@ -0,0 +1,7 @@ +data "cloudfoundry_service_brokers" "brokers" { + space = "02c0cc92-6ecc-44b1-b7b2-096ca19ee143" +} + +output "se_brs" { + value = data.cloudfoundry_service_brokers.brokers +} diff --git a/internal/provider/datasource_service_brokers.go b/internal/provider/datasource_service_brokers.go new file mode 100644 index 0000000..982fb08 --- /dev/null +++ b/internal/provider/datasource_service_brokers.go @@ -0,0 +1,126 @@ +package provider + +import ( + "context" + "fmt" + + cfv3client "github.com/cloudfoundry/go-cfclient/v3/client" + "github.com/cloudfoundry/terraform-provider-cloudfoundry/internal/provider/managers" + "github.com/hashicorp/terraform-plugin-framework/datasource" + "github.com/hashicorp/terraform-plugin-framework/datasource/schema" +) + +func NewServiceBrokersDataSource() datasource.DataSource { + return &ServiceBrokersDataSource{} +} + +type ServiceBrokersDataSource struct { + cfClient *cfv3client.Client +} + +func (d *ServiceBrokersDataSource) Metadata(ctx context.Context, req datasource.MetadataRequest, resp *datasource.MetadataResponse) { + resp.TypeName = req.ProviderTypeName + "_service_brokers" +} + +func (d *ServiceBrokersDataSource) Schema(ctx context.Context, req datasource.SchemaRequest, resp *datasource.SchemaResponse) { + resp.Schema = schema.Schema{ + MarkdownDescription: "Gets information of Service brokers user has access to.", + Attributes: map[string]schema.Attribute{ + "space": schema.StringAttribute{ + MarkdownDescription: "GUID of the space to filter by", + Optional: true, + }, + "name": schema.StringAttribute{ + MarkdownDescription: "Name of the service broker to filter by", + Optional: true, + }, + "service_brokers": schema.ListNestedAttribute{ + MarkdownDescription: "List of service brokers", + Computed: true, + NestedObject: schema.NestedAttributeObject{ + Attributes: map[string]schema.Attribute{ + "name": schema.StringAttribute{ + MarkdownDescription: "Name of the service broker", + Required: true, + }, + "url": schema.StringAttribute{ + MarkdownDescription: "URL of the service broker", + Computed: true, + }, + "space": schema.StringAttribute{ + MarkdownDescription: "The GUID of the space the service broker is restricted to; omitted for globally available service brokers", + Computed: true, + }, + idKey: guidSchema(), + labelsKey: resourceLabelsSchema(), + annotationsKey: resourceAnnotationsSchema(), + createdAtKey: createdAtSchema(), + updatedAtKey: updatedAtSchema(), + }, + }, + }, + }, + } +} + +func (d *ServiceBrokersDataSource) Configure(ctx context.Context, req datasource.ConfigureRequest, resp *datasource.ConfigureResponse) { + // Prevent panic if the provider has not been configured. + if req.ProviderData == nil { + return + } + session, ok := req.ProviderData.(*managers.Session) + if !ok { + resp.Diagnostics.AddError( + "Unexpected Data Source Configure Type", + fmt.Sprintf("Expected *managers.Session, got: %T. Please report this issue to the provider developers.", req.ProviderData), + ) + return + } + d.cfClient = session.CFClient +} + +func (d *ServiceBrokersDataSource) Read(ctx context.Context, req datasource.ReadRequest, resp *datasource.ReadResponse) { + + var data datasourceServiceBrokersType + + diags := req.Config.Get(ctx, &data) + resp.Diagnostics.Append(diags...) + if resp.Diagnostics.HasError() { + return + } + + getOptions := cfv3client.NewServiceBrokerListOptions() + if !data.Name.IsNull() { + getOptions.Names = cfv3client.Filter{ + Values: []string{ + data.Name.ValueString(), + }, + } + } + if !data.Space.IsNull() { + getOptions.SpaceGUIDs = cfv3client.Filter{ + Values: []string{ + data.Space.ValueString(), + }, + } + } + svcBrokers, err := d.cfClient.ServiceBrokers.ListAll(ctx, getOptions) + if err != nil { + resp.Diagnostics.AddError( + "API Error in fetching service broker data.", + fmt.Sprintf("Request failed with %s.", err.Error()), + ) + return + } + if len(svcBrokers) == 0 { + resp.Diagnostics.AddError( + "Unable to find any service broker in list", + "No service brokers present with mentioned criteria", + ) + return + } + + data.ServiceBrokers, diags = mapDataSourceServiceBrokersValuesToType(ctx, svcBrokers) + resp.Diagnostics.Append(diags...) + resp.Diagnostics.Append(resp.State.Set(ctx, &data)...) +} diff --git a/internal/provider/datasource_service_brokers_test.go b/internal/provider/datasource_service_brokers_test.go new file mode 100644 index 0000000..9455b43 --- /dev/null +++ b/internal/provider/datasource_service_brokers_test.go @@ -0,0 +1,102 @@ +package provider + +import ( + "bytes" + "regexp" + "testing" + "text/template" + + "github.com/hashicorp/terraform-plugin-testing/helper/resource" +) + +type ServiceBrokersModelPtr struct { + HclType string + HclObjectName string + Name *string + Space *string + ServiceBrokers *string +} + +func hclServiceBrokers(sbmp *ServiceBrokersModelPtr) string { + if sbmp != nil { + s := ` + {{.HclType}} "cloudfoundry_service_brokers" {{.HclObjectName}} { + {{- if .Name}} + name = "{{.Name}}" + {{- end -}} + {{if .Space}} + space = "{{.Space}}" + {{- end -}} + {{if .ServiceBrokers}} + service_brokers = "{{.ServiceBrokers}}" + {{- end }} + }` + tmpl, err := template.New("datasource_service_brokers").Parse(s) + if err != nil { + panic(err) + } + buf := new(bytes.Buffer) + err = tmpl.Execute(buf, sbmp) + if err != nil { + panic(err) + } + return buf.String() + } + return sbmp.HclType + ` "cloudfoundry_service_brokers" ` + sbmp.HclObjectName + ` {}` +} + +func TestServiceBrokersDataSource(t *testing.T) { + t.Parallel() + t.Run("happy path - read service brokers", func(t *testing.T) { + cfg := getCFHomeConf() + dataSourceName := "data.cloudfoundry_service_brokers.ds" + rec := cfg.SetupVCR(t, "fixtures/datasource_service_brokers") + defer stopQuietly(rec) + resource.Test(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: getProviders(rec.GetDefaultClient()), + Steps: []resource.TestStep{ + { + Config: hclProvider(nil) + hclServiceBrokers(&ServiceBrokersModelPtr{ + HclType: hclObjectDataSource, + HclObjectName: "ds", + }), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(dataSourceName, "service_brokers.#", "3"), + ), + }, + { + Config: hclProvider(nil) + hclServiceBrokers(&ServiceBrokersModelPtr{ + HclType: hclObjectDataSource, + HclObjectName: "ds", + Name: strtostrptr("hi"), + }), + Check: resource.ComposeAggregateTestCheckFunc( + resource.TestCheckResourceAttr(dataSourceName, "service_brokers.#", "1"), + ), + }, + }, + }) + }) + t.Run("error path - get unavailable service brokers", func(t *testing.T) { + cfg := getCFHomeConf() + rec := cfg.SetupVCR(t, "fixtures/datasource_service_brokers_invalid") + defer stopQuietly(rec) + // Create a Terraform configuration that uses the data source + // and run `terraform apply`. The data source should not be found. + resource.UnitTest(t, resource.TestCase{ + IsUnitTest: true, + ProtoV6ProviderFactories: getProviders(rec.GetDefaultClient()), + Steps: []resource.TestStep{ + { + Config: hclProvider(nil) + hclServiceBrokers(&ServiceBrokersModelPtr{ + HclType: hclObjectDataSource, + HclObjectName: "ds", + Name: strtostrptr("invalid-service-broker-name"), + }), + ExpectError: regexp.MustCompile(`Unable to find any service broker in list`), + }, + }, + }) + }) +} diff --git a/internal/provider/fixtures/datasource_service_brokers.yaml b/internal/provider/fixtures/datasource_service_brokers.yaml new file mode 100644 index 0000000..981ce33 --- /dev/null +++ b/internal/provider/fixtures/datasource_service_brokers.yaml @@ -0,0 +1,747 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 73 + transfer_encoding: [] + trailer: {} + host: uaa.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: grant_type=refresh_token&refresh_token=bacbee5af0514e12bec2abcee6437dbb-r + form: + grant_type: + - refresh_token + refresh_token: + - bacbee5af0514e12bec2abcee6437dbb-r + headers: + Authorization: + - Basic Y2Y6 + Content-Type: + - application/x-www-form-urlencoded + url: https://uaa.x.x.x.x.com/oauth/token + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: false + body: '{"access_token":"redacted","token_type":"bearer","id_token":"redacted","refresh_token":"bacbee5af0514e12bec2abcee6437dbb-r","expires_in":1199,"scope":"cloud_controller.read password.write cloud_controller.write openid uaa.user","jti":"c20b74ad641840b58270c1f41d294cd7"}' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - script-src 'self' + Content-Type: + - application/json;charset=UTF-8 + Date: + - Tue, 05 Nov 2024 06:36:56 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - eca14bf4-65a7-4074-66cc-4ef9bb2a096f + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 918.6075ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Authorization: + - Bearer redacted + User-Agent: + - Terraform/1.5.7 terraform-provider-cloudfoundry/dev + url: https://api.x.x.x.x.com/v3/service_brokers?page=1&per_page=50 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2376 + uncompressed: false + body: '{"pagination":{"total_results":3,"total_pages":1,"first":{"href":"https://api.x.x.x.x.com/v3/service_brokers?page=1\u0026per_page=50"},"last":{"href":"https://api.x.x.x.x.com/v3/service_brokers?page=1\u0026per_page=50"},"next":null,"previous":null},"resources":[{"guid":"44faadbe-f56b-4ee2-bf40-e31113aa7324","created_at":"2020-08-25T14:10:06Z","updated_at":"2023-02-16T01:46:29Z","name":"url-broker","url":"https://sb-i513578.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"dd457c79-f7c9-4828-862b-35843d3b646d"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/44faadbe-f56b-4ee2-bf40-e31113aa7324"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=44faadbe-f56b-4ee2-bf40-e31113aa7324"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/dd457c79-f7c9-4828-862b-35843d3b646d"}}},{"guid":"71203fb7-558a-4dd7-b87d-ddc289c5c85f","created_at":"2024-06-24T04:53:36Z","updated_at":"2024-06-24T04:53:36Z","name":"hi","url":"https://tf-test-do-not-delete-nodejs.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}},{"guid":"3e19acc4-95dc-44b7-aa2c-4eac5057504c","created_at":"2024-10-25T05:59:29Z","updated_at":"2024-10-25T05:59:31Z","name":"hdb-dumm","url":"https://hana-dummy-sb.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"dd457c79-f7c9-4828-862b-35843d3b646d"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/3e19acc4-95dc-44b7-aa2c-4eac5057504c"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=3e19acc4-95dc-44b7-aa2c-4eac5057504c"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/dd457c79-f7c9-4828-862b-35843d3b646d"}}}]}' + headers: + Content-Length: + - "2376" + Content-Type: + - application/json; charset=utf-8 + Date: + - Tue, 05 Nov 2024 06:36:57 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-B3-Spanid: + - 764f0b1cb105f582 + X-B3-Traceid: + - aa991fb80f7b471d764f0b1cb105f582 + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Ratelimit-Limit: + - "20000" + X-Ratelimit-Remaining: + - "18000" + X-Ratelimit-Reset: + - "1730790188" + X-Runtime: + - "0.042893" + X-Vcap-Request-Id: + - aa991fb8-0f7b-471d-764f-0b1cb105f582::d18afc1e-6baa-40f4-a2ef-1808f6749916 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 806.555541ms + - id: 2 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 73 + transfer_encoding: [] + trailer: {} + host: uaa.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: grant_type=refresh_token&refresh_token=bacbee5af0514e12bec2abcee6437dbb-r + form: + grant_type: + - refresh_token + refresh_token: + - bacbee5af0514e12bec2abcee6437dbb-r + headers: + Authorization: + - Basic Y2Y6 + Content-Type: + - application/x-www-form-urlencoded + url: https://uaa.x.x.x.x.com/oauth/token + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: false + body: '{"access_token":"redacted","token_type":"bearer","id_token":"redacted","refresh_token":"bacbee5af0514e12bec2abcee6437dbb-r","expires_in":1199,"scope":"cloud_controller.read password.write cloud_controller.write openid uaa.user","jti":"806a2969fa9746abb7ee62db362e87c7"}' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - script-src 'self' + Content-Type: + - application/json;charset=UTF-8 + Date: + - Tue, 05 Nov 2024 06:36:57 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 9b8a05d8-1257-4100-63aa-4102f5e3520b + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 289.844459ms + - id: 3 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Authorization: + - Bearer redacted + User-Agent: + - Terraform/1.5.7 terraform-provider-cloudfoundry/dev + url: https://api.x.x.x.x.com/v3/service_brokers?page=1&per_page=50 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2376 + uncompressed: false + body: '{"pagination":{"total_results":3,"total_pages":1,"first":{"href":"https://api.x.x.x.x.com/v3/service_brokers?page=1\u0026per_page=50"},"last":{"href":"https://api.x.x.x.x.com/v3/service_brokers?page=1\u0026per_page=50"},"next":null,"previous":null},"resources":[{"guid":"44faadbe-f56b-4ee2-bf40-e31113aa7324","created_at":"2020-08-25T14:10:06Z","updated_at":"2023-02-16T01:46:29Z","name":"url-broker","url":"https://sb-i513578.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"dd457c79-f7c9-4828-862b-35843d3b646d"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/44faadbe-f56b-4ee2-bf40-e31113aa7324"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=44faadbe-f56b-4ee2-bf40-e31113aa7324"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/dd457c79-f7c9-4828-862b-35843d3b646d"}}},{"guid":"71203fb7-558a-4dd7-b87d-ddc289c5c85f","created_at":"2024-06-24T04:53:36Z","updated_at":"2024-06-24T04:53:36Z","name":"hi","url":"https://tf-test-do-not-delete-nodejs.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}},{"guid":"3e19acc4-95dc-44b7-aa2c-4eac5057504c","created_at":"2024-10-25T05:59:29Z","updated_at":"2024-10-25T05:59:31Z","name":"hdb-dumm","url":"https://hana-dummy-sb.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"dd457c79-f7c9-4828-862b-35843d3b646d"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/3e19acc4-95dc-44b7-aa2c-4eac5057504c"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=3e19acc4-95dc-44b7-aa2c-4eac5057504c"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/dd457c79-f7c9-4828-862b-35843d3b646d"}}}]}' + headers: + Content-Length: + - "2376" + Content-Type: + - application/json; charset=utf-8 + Date: + - Tue, 05 Nov 2024 06:36:57 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-B3-Spanid: + - 64314cf036feefcd + X-B3-Traceid: + - 9eafdc30f2994f7864314cf036feefcd + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Ratelimit-Limit: + - "20000" + X-Ratelimit-Remaining: + - "18000" + X-Ratelimit-Reset: + - "1730790188" + X-Runtime: + - "0.057529" + X-Vcap-Request-Id: + - 9eafdc30-f299-4f78-6431-4cf036feefcd::945b84da-8bce-41be-b6e8-870ab2728e10 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 289.991833ms + - id: 4 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 73 + transfer_encoding: [] + trailer: {} + host: uaa.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: grant_type=refresh_token&refresh_token=bacbee5af0514e12bec2abcee6437dbb-r + form: + grant_type: + - refresh_token + refresh_token: + - bacbee5af0514e12bec2abcee6437dbb-r + headers: + Authorization: + - Basic Y2Y6 + Content-Type: + - application/x-www-form-urlencoded + url: https://uaa.x.x.x.x.com/oauth/token + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: false + body: '{"access_token":"redacted","token_type":"bearer","id_token":"redacted","refresh_token":"bacbee5af0514e12bec2abcee6437dbb-r","expires_in":1199,"scope":"cloud_controller.read password.write cloud_controller.write openid uaa.user","jti":"e119e90c271249f7be81e476ecbed4c6"}' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - script-src 'self' + Content-Type: + - application/json;charset=UTF-8 + Date: + - Tue, 05 Nov 2024 06:36:57 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 704a877b-d887-451d-7c17-5f6d7aaf2655 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 269.375333ms + - id: 5 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Authorization: + - Bearer redacted + User-Agent: + - Terraform/1.5.7 terraform-provider-cloudfoundry/dev + url: https://api.x.x.x.x.com/v3/service_brokers?page=1&per_page=50 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 2376 + uncompressed: false + body: '{"pagination":{"total_results":3,"total_pages":1,"first":{"href":"https://api.x.x.x.x.com/v3/service_brokers?page=1\u0026per_page=50"},"last":{"href":"https://api.x.x.x.x.com/v3/service_brokers?page=1\u0026per_page=50"},"next":null,"previous":null},"resources":[{"guid":"44faadbe-f56b-4ee2-bf40-e31113aa7324","created_at":"2020-08-25T14:10:06Z","updated_at":"2023-02-16T01:46:29Z","name":"url-broker","url":"https://sb-i513578.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"dd457c79-f7c9-4828-862b-35843d3b646d"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/44faadbe-f56b-4ee2-bf40-e31113aa7324"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=44faadbe-f56b-4ee2-bf40-e31113aa7324"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/dd457c79-f7c9-4828-862b-35843d3b646d"}}},{"guid":"71203fb7-558a-4dd7-b87d-ddc289c5c85f","created_at":"2024-06-24T04:53:36Z","updated_at":"2024-06-24T04:53:36Z","name":"hi","url":"https://tf-test-do-not-delete-nodejs.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}},{"guid":"3e19acc4-95dc-44b7-aa2c-4eac5057504c","created_at":"2024-10-25T05:59:29Z","updated_at":"2024-10-25T05:59:31Z","name":"hdb-dumm","url":"https://hana-dummy-sb.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"dd457c79-f7c9-4828-862b-35843d3b646d"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/3e19acc4-95dc-44b7-aa2c-4eac5057504c"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=3e19acc4-95dc-44b7-aa2c-4eac5057504c"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/dd457c79-f7c9-4828-862b-35843d3b646d"}}}]}' + headers: + Content-Length: + - "2376" + Content-Type: + - application/json; charset=utf-8 + Date: + - Tue, 05 Nov 2024 06:36:58 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-B3-Spanid: + - 68acd941aed404a4 + X-B3-Traceid: + - 3be7c660accf49b068acd941aed404a4 + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Ratelimit-Limit: + - "20000" + X-Ratelimit-Remaining: + - "18000" + X-Ratelimit-Reset: + - "1730790188" + X-Runtime: + - "0.036159" + X-Vcap-Request-Id: + - 3be7c660-accf-49b0-68ac-d941aed404a4::01b38eb0-a835-46f2-92cd-c280372b00fc + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 279.360334ms + - id: 6 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 73 + transfer_encoding: [] + trailer: {} + host: uaa.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: grant_type=refresh_token&refresh_token=bacbee5af0514e12bec2abcee6437dbb-r + form: + grant_type: + - refresh_token + refresh_token: + - bacbee5af0514e12bec2abcee6437dbb-r + headers: + Authorization: + - Basic Y2Y6 + Content-Type: + - application/x-www-form-urlencoded + url: https://uaa.x.x.x.x.com/oauth/token + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: false + body: '{"access_token":"redacted","token_type":"bearer","id_token":"redacted","refresh_token":"bacbee5af0514e12bec2abcee6437dbb-r","expires_in":1199,"scope":"cloud_controller.read password.write cloud_controller.write openid uaa.user","jti":"22e8fbca0e724c3b95ba586e7d619d11"}' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - script-src 'self' + Content-Type: + - application/json;charset=UTF-8 + Date: + - Tue, 05 Nov 2024 06:36:58 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 7bd03913-e82a-4369-78bc-cf835e4b64ce + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 306.721583ms + - id: 7 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Authorization: + - Bearer redacted + User-Agent: + - Terraform/1.5.7 terraform-provider-cloudfoundry/dev + url: https://api.x.x.x.x.com/v3/service_brokers?names=hi&page=1&per_page=50 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 1019 + uncompressed: false + body: '{"pagination":{"total_results":1,"total_pages":1,"first":{"href":"https://api.x.x.x.x.com/v3/service_brokers?names=hi\u0026page=1\u0026per_page=50"},"last":{"href":"https://api.x.x.x.x.com/v3/service_brokers?names=hi\u0026page=1\u0026per_page=50"},"next":null,"previous":null},"resources":[{"guid":"71203fb7-558a-4dd7-b87d-ddc289c5c85f","created_at":"2024-06-24T04:53:36Z","updated_at":"2024-06-24T04:53:36Z","name":"hi","url":"https://tf-test-do-not-delete-nodejs.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}}]}' + headers: + Content-Length: + - "1019" + Content-Type: + - application/json; charset=utf-8 + Date: + - Tue, 05 Nov 2024 06:36:59 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-B3-Spanid: + - 52ac750314a6850a + X-B3-Traceid: + - 20610896b6ca4e9c52ac750314a6850a + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Ratelimit-Limit: + - "20000" + X-Ratelimit-Remaining: + - "18000" + X-Ratelimit-Reset: + - "1730790188" + X-Runtime: + - "0.031734" + X-Vcap-Request-Id: + - 20610896-b6ca-4e9c-52ac-750314a6850a::c53ca2e9-7db3-4dda-958f-4f4128a0514d + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 305.930083ms + - id: 8 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 73 + transfer_encoding: [] + trailer: {} + host: uaa.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: grant_type=refresh_token&refresh_token=bacbee5af0514e12bec2abcee6437dbb-r + form: + grant_type: + - refresh_token + refresh_token: + - bacbee5af0514e12bec2abcee6437dbb-r + headers: + Authorization: + - Basic Y2Y6 + Content-Type: + - application/x-www-form-urlencoded + url: https://uaa.x.x.x.x.com/oauth/token + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: false + body: '{"access_token":"redacted","token_type":"bearer","id_token":"redacted","refresh_token":"bacbee5af0514e12bec2abcee6437dbb-r","expires_in":1199,"scope":"cloud_controller.read password.write cloud_controller.write openid uaa.user","jti":"ce4a410502ff4b678646501dda373b38"}' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - script-src 'self' + Content-Type: + - application/json;charset=UTF-8 + Date: + - Tue, 05 Nov 2024 06:36:58 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 03dcece1-2345-4eda-7324-e5d1b9411a8d + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 256.644125ms + - id: 9 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Authorization: + - Bearer redacted + User-Agent: + - Terraform/1.5.7 terraform-provider-cloudfoundry/dev + url: https://api.x.x.x.x.com/v3/service_brokers?names=hi&page=1&per_page=50 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 1019 + uncompressed: false + body: '{"pagination":{"total_results":1,"total_pages":1,"first":{"href":"https://api.x.x.x.x.com/v3/service_brokers?names=hi\u0026page=1\u0026per_page=50"},"last":{"href":"https://api.x.x.x.x.com/v3/service_brokers?names=hi\u0026page=1\u0026per_page=50"},"next":null,"previous":null},"resources":[{"guid":"71203fb7-558a-4dd7-b87d-ddc289c5c85f","created_at":"2024-06-24T04:53:36Z","updated_at":"2024-06-24T04:53:36Z","name":"hi","url":"https://tf-test-do-not-delete-nodejs.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}}]}' + headers: + Content-Length: + - "1019" + Content-Type: + - application/json; charset=utf-8 + Date: + - Tue, 05 Nov 2024 06:36:59 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-B3-Spanid: + - 7d67e25dbd63c764 + X-B3-Traceid: + - bea8fe69f5f244f27d67e25dbd63c764 + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Ratelimit-Limit: + - "20000" + X-Ratelimit-Remaining: + - "18000" + X-Ratelimit-Reset: + - "1730790188" + X-Runtime: + - "0.033440" + X-Vcap-Request-Id: + - bea8fe69-f5f2-44f2-7d67-e25dbd63c764::0e69321f-4ebd-49de-93cd-ae047110dbcb + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 263.978166ms + - id: 10 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 73 + transfer_encoding: [] + trailer: {} + host: uaa.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: grant_type=refresh_token&refresh_token=bacbee5af0514e12bec2abcee6437dbb-r + form: + grant_type: + - refresh_token + refresh_token: + - bacbee5af0514e12bec2abcee6437dbb-r + headers: + Authorization: + - Basic Y2Y6 + Content-Type: + - application/x-www-form-urlencoded + url: https://uaa.x.x.x.x.com/oauth/token + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: false + body: '{"access_token":"redacted","token_type":"bearer","id_token":"redacted","refresh_token":"bacbee5af0514e12bec2abcee6437dbb-r","expires_in":1199,"scope":"cloud_controller.read password.write cloud_controller.write openid uaa.user","jti":"26ea2cb53eb247eb80a928fc99dcc80d"}' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - script-src 'self' + Content-Type: + - application/json;charset=UTF-8 + Date: + - Tue, 05 Nov 2024 06:36:59 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 6bad8ed4-1e98-44ec-7fd0-c2bf6ff56d28 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 268.128792ms + - id: 11 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Authorization: + - Bearer redacted + User-Agent: + - Terraform/1.5.7 terraform-provider-cloudfoundry/dev + url: https://api.x.x.x.x.com/v3/service_brokers?names=hi&page=1&per_page=50 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 1019 + uncompressed: false + body: '{"pagination":{"total_results":1,"total_pages":1,"first":{"href":"https://api.x.x.x.x.com/v3/service_brokers?names=hi\u0026page=1\u0026per_page=50"},"last":{"href":"https://api.x.x.x.x.com/v3/service_brokers?names=hi\u0026page=1\u0026per_page=50"},"next":null,"previous":null},"resources":[{"guid":"71203fb7-558a-4dd7-b87d-ddc289c5c85f","created_at":"2024-06-24T04:53:36Z","updated_at":"2024-06-24T04:53:36Z","name":"hi","url":"https://tf-test-do-not-delete-nodejs.cfapps.sap.hana.ondemand.com","relationships":{"space":{"data":{"guid":"02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}},"metadata":{"labels":{},"annotations":{}},"links":{"self":{"href":"https://api.x.x.x.x.com/v3/service_brokers/71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"service_offerings":{"href":"https://api.x.x.x.x.com/v3/service_offerings?service_broker_guids=71203fb7-558a-4dd7-b87d-ddc289c5c85f"},"space":{"href":"https://api.x.x.x.x.com/v3/spaces/02c0cc92-6ecc-44b1-b7b2-096ca19ee143"}}}]}' + headers: + Content-Length: + - "1019" + Content-Type: + - application/json; charset=utf-8 + Date: + - Tue, 05 Nov 2024 06:37:00 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-B3-Spanid: + - 7b54e3b654220f25 + X-B3-Traceid: + - 3dfdfcc8e0c24c6c7b54e3b654220f25 + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Ratelimit-Limit: + - "20000" + X-Ratelimit-Remaining: + - "18000" + X-Ratelimit-Reset: + - "1730790188" + X-Runtime: + - "0.034227" + X-Vcap-Request-Id: + - 3dfdfcc8-e0c2-4c6c-7b54-e3b654220f25::78a2eaaa-f045-42d4-a98c-047f2a1d209f + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 298.132ms diff --git a/internal/provider/fixtures/datasource_service_brokers_invalid.yaml b/internal/provider/fixtures/datasource_service_brokers_invalid.yaml new file mode 100644 index 0000000..334dd75 --- /dev/null +++ b/internal/provider/fixtures/datasource_service_brokers_invalid.yaml @@ -0,0 +1,127 @@ +--- +version: 2 +interactions: + - id: 0 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 73 + transfer_encoding: [] + trailer: {} + host: uaa.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: grant_type=refresh_token&refresh_token=bacbee5af0514e12bec2abcee6437dbb-r + form: + grant_type: + - refresh_token + refresh_token: + - bacbee5af0514e12bec2abcee6437dbb-r + headers: + Authorization: + - Basic Y2Y6 + Content-Type: + - application/x-www-form-urlencoded + url: https://uaa.x.x.x.x.com/oauth/token + method: POST + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: -1 + uncompressed: false + body: '{"access_token":"redacted","token_type":"bearer","id_token":"redacted","refresh_token":"bacbee5af0514e12bec2abcee6437dbb-r","expires_in":1199,"scope":"cloud_controller.read password.write cloud_controller.write openid uaa.user","jti":"910333542c8d4167b41bab2ecb86a4d0"}' + headers: + Cache-Control: + - no-store + Content-Security-Policy: + - script-src 'self' + Content-Type: + - application/json;charset=UTF-8 + Date: + - Tue, 05 Nov 2024 06:37:01 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - DENY + X-Vcap-Request-Id: + - 356dcda6-7c31-4093-68e9-f91b13e05cb2 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 267.307958ms + - id: 1 + request: + proto: HTTP/1.1 + proto_major: 1 + proto_minor: 1 + content_length: 0 + transfer_encoding: [] + trailer: {} + host: api.x.x.x.x.com + remote_addr: "" + request_uri: "" + body: "" + form: {} + headers: + Authorization: + - Bearer redacted + User-Agent: + - Terraform/1.5.7 terraform-provider-cloudfoundry/dev + url: https://api.x.x.x.x.com/v3/service_brokers?names=invalid-service-broker-name&page=1&per_page=50 + method: GET + response: + proto: HTTP/2.0 + proto_major: 2 + proto_minor: 0 + transfer_encoding: [] + trailer: {} + content_length: 368 + uncompressed: false + body: '{"pagination":{"total_results":0,"total_pages":1,"first":{"href":"https://api.x.x.x.x.com/v3/service_brokers?names=invalid-service-broker-name\u0026page=1\u0026per_page=50"},"last":{"href":"https://api.x.x.x.x.com/v3/service_brokers?names=invalid-service-broker-name\u0026page=1\u0026per_page=50"},"next":null,"previous":null},"resources":[]}' + headers: + Content-Length: + - "368" + Content-Type: + - application/json; charset=utf-8 + Date: + - Tue, 05 Nov 2024 06:37:01 GMT + Referrer-Policy: + - strict-origin-when-cross-origin + Strict-Transport-Security: + - max-age=31536000; includeSubDomains; preload; + X-B3-Spanid: + - 4a1871c45d6b49a8 + X-B3-Traceid: + - ff1057497d6c448c4a1871c45d6b49a8 + X-Content-Type-Options: + - nosniff + X-Download-Options: + - noopen + X-Frame-Options: + - SAMEORIGIN + X-Permitted-Cross-Domain-Policies: + - none + X-Ratelimit-Limit: + - "20000" + X-Ratelimit-Remaining: + - "18000" + X-Ratelimit-Reset: + - "1730790188" + X-Runtime: + - "0.025781" + X-Vcap-Request-Id: + - ff105749-7d6c-448c-4a18-71c45d6b49a8::eaf641b0-4e3d-4970-848a-b6caf1d4b078 + X-Xss-Protection: + - 1; mode=block + status: 200 OK + code: 200 + duration: 285.098958ms diff --git a/internal/provider/provider.go b/internal/provider/provider.go index 1e1e9b0..07616a1 100644 --- a/internal/provider/provider.go +++ b/internal/provider/provider.go @@ -345,6 +345,7 @@ func (p *CloudFoundryProvider) DataSources(ctx context.Context) []func() datasou NewRoutesDataSource, NewServiceBrokerDataSource, NewServiceRouteBindingsDataSource, + NewServiceBrokersDataSource, } } diff --git a/internal/provider/provider_test.go b/internal/provider/provider_test.go index 3808bc7..6b4383c 100644 --- a/internal/provider/provider_test.go +++ b/internal/provider/provider_test.go @@ -324,6 +324,7 @@ func TestProvider_HasDataSources(t *testing.T) { "cloudfoundry_routes", "cloudfoundry_service_broker", "cloudfoundry_service_route_bindings", + "cloudfoundry_service_brokers", } ctx := context.Background() diff --git a/internal/provider/types_service_broker.go b/internal/provider/types_service_broker.go index 41c7789..47a0e35 100644 --- a/internal/provider/types_service_broker.go +++ b/internal/provider/types_service_broker.go @@ -33,6 +33,12 @@ type datasourceServiceBrokerType struct { UpdatedAt types.String `tfsdk:"updated_at"` } +type datasourceServiceBrokersType struct { + Name types.String `tfsdk:"name"` + Space types.String `tfsdk:"space"` + ServiceBrokers []datasourceServiceBrokerType `tfsdk:"service_brokers"` +} + func (a *serviceBrokerType) Reduce() datasourceServiceBrokerType { var reduced datasourceServiceBrokerType copyFields(&reduced, a) @@ -60,6 +66,21 @@ func mapServiceBrokerValuesToType(ctx context.Context, value *resource.ServiceBr return serviceBrokerType, diagnostics } +func mapDataSourceServiceBrokersValuesToType(ctx context.Context, svcBrokers []*resource.ServiceBroker) ([]datasourceServiceBrokerType, diag.Diagnostics) { + var diagnostics diag.Diagnostics + + svcBrokersList := []datasourceServiceBrokerType{} + for _, svcBroker := range svcBrokers { + svcBrokerValue, diags := mapServiceBrokerValuesToType(ctx, svcBroker) + diagnostics.Append(diags...) + svcBrokerReduced := svcBrokerValue.Reduce() + svcBrokersList = append(svcBrokersList, svcBrokerReduced) + } + + return svcBrokersList, diagnostics + +} + func (data *serviceBrokerType) mapCreateServiceBrokerTypeToValues(ctx context.Context) (resource.ServiceBrokerCreate, diag.Diagnostics) { var diagnostics diag.Diagnostics diff --git a/migration-guide/Readme.md b/migration-guide/Readme.md index f839a63..459196f 100644 --- a/migration-guide/Readme.md +++ b/migration-guide/Readme.md @@ -195,7 +195,7 @@ Few resources required a major change in functionality or the way the resources The below mentioned dataSources have been newly added in the current provider. - [Applications](../docs/data-sources/apps.md) -- [Multi Target Applications](../docs/data-sources/mta.md) +- [Multi Target Application](../docs/data-sources/mta.md) - [Multi Target Applications](../docs/data-sources/mtas.md) - [Isolation Segment Entitlement](../docs/data-sources/isolation_segment_entitlement.md) - [Org Role](../docs/data-sources/org_role.md) @@ -203,13 +203,13 @@ The below mentioned dataSources have been newly added in the current provider. - [Organizations](../docs/data-sources/orgs.md) - [Routes](../docs/data-sources/routes.md) - [Service Broker](../docs/data-sources/service_broker.md) +- [Service Brokers](../docs/data-sources/service_brokers.md) - [Service Instances](../docs/data-sources/service_instances.md) - [Service Plans](../docs/data-sources/service_plans.md) - [Service Route Bindings](../docs/data-sources/service_route_bindings.md) - [Space Role](../docs/data-sources/space_role.md) - [Spaces](../docs/data-sources/spaces.md) - [Space Roles](../docs/data-sources/space_roles.md) -- [Spaces](./data-sources/spaces.md) - [Users](../docs/data-sources/users.md) While most dataSources have maintained the same structure, some dataSources needed minor changes in schema to follow the V3 API structure. Following is a list of datasources whose schema have changed