-
Notifications
You must be signed in to change notification settings - Fork 478
feat: Listing data source #4205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
0cc4b3a
wip
sfc-gh-jcieslak 45bdd0a
Changes after review
sfc-gh-jcieslak 651250e
wip
sfc-gh-jcieslak d916e42
Adjust task documentation
sfc-gh-jcieslak 66cbe46
Merge branch 'refs/heads/dev' into listing-data-source
sfc-gh-jcieslak 7b1fd0b
Adjust after review
sfc-gh-jcieslak 7c633a5
Merge branch 'refs/heads/dev' into listing-data-source
sfc-gh-jcieslak 0e9fcf0
Merge branch 'dev' into listing-data-source
sfc-gh-jcieslak a5aa26d
Merge branch 'dev' into listing-data-source
sfc-gh-jcieslak f4e4773
Merge branch 'dev' into listing-data-source
sfc-gh-jcieslak File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,234 @@ | ||
| --- | ||
| page_title: "snowflake_listings Data Source - terraform-provider-snowflake" | ||
| subcategory: "Preview" | ||
| description: |- | ||
| Data source used to get details of filtered listings. Filtering is aligned with the current possibilities for SHOW LISTINGS query (like, starts_with, and limit are supported). The results of SHOW and DESCRIBE are encapsulated in one output collection. | ||
| --- | ||
|
|
||
| !> **Preview Feature** This data source is a preview feature and is subject to breaking changes, even without bumping the major version. To use this feature, add `snowflake_listings_datasource` to `preview_features_enabled` field in the provider configuration. Read more about preview features in our [documentation](../#preview-features). | ||
|
|
||
| -> **Note** This data source focuses on base query commands (SHOW LISTINGS and DESCRIBE LISTING). Other query commands like SHOW AVAILABLE LISTINGS, DESCRIBE AVAILABLE LISTING, SHOW LISTING OFFERS, SHOW OFFERS, SHOW PRICING PLANS, and SHOW VERSIONS IN LISTING are not included and will be added depending on demand. | ||
|
|
||
| # snowflake_listings (Data Source) | ||
|
|
||
| Data source used to get details of filtered listings. Filtering is aligned with the current possibilities for SHOW LISTINGS query (`like`, `starts_with`, and `limit` are supported). The results of SHOW and DESCRIBE are encapsulated in one output collection. | ||
|
|
||
| ## Example Usage | ||
|
|
||
| ```terraform | ||
| # Simple usage | ||
| data "snowflake_listings" "simple" { | ||
| } | ||
|
|
||
| output "simple_output" { | ||
| value = data.snowflake_listings.simple.listings | ||
| } | ||
|
|
||
| # Filtering (like) | ||
| data "snowflake_listings" "like" { | ||
| like = "listing-name" | ||
| } | ||
|
|
||
| output "like_output" { | ||
| value = data.snowflake_listings.like.listings | ||
| } | ||
|
|
||
| # Filtering by prefix (like) | ||
| data "snowflake_listings" "like_prefix" { | ||
| like = "prefix%" | ||
| } | ||
|
|
||
| output "like_prefix_output" { | ||
| value = data.snowflake_listings.like_prefix.listings | ||
| } | ||
|
|
||
| # Filtering (starts_with) | ||
| data "snowflake_listings" "starts_with" { | ||
| starts_with = "prefix-" | ||
| } | ||
|
|
||
| output "starts_with_output" { | ||
| value = data.snowflake_listings.starts_with.listings | ||
| } | ||
|
|
||
| # Filtering (limit) | ||
| data "snowflake_listings" "limit" { | ||
| limit { | ||
| rows = 10 | ||
| from = "prefix-" | ||
| } | ||
| } | ||
|
|
||
| output "limit_output" { | ||
| value = data.snowflake_listings.limit.listings | ||
| } | ||
|
|
||
| # Without additional data (to limit the number of calls make for every found listing) | ||
| data "snowflake_listings" "only_show" { | ||
| # with_describe is turned on by default and it calls DESCRIBE LISTING for every listing found and attaches its output to listings.*.describe_output field | ||
| with_describe = false | ||
| } | ||
|
|
||
| output "only_show_output" { | ||
| value = data.snowflake_listings.only_show.listings | ||
| } | ||
|
|
||
| # Ensure the number of listings is equal to at least one element (with the use of postcondition) | ||
| data "snowflake_listings" "assert_with_postcondition" { | ||
| like = "listing-name%" | ||
| lifecycle { | ||
| postcondition { | ||
| condition = length(self.listings) > 0 | ||
| error_message = "there should be at least one listing" | ||
| } | ||
| } | ||
| } | ||
|
|
||
| # Ensure the number of listings is equal to exactly one element (with the use of check block) | ||
| check "listing_check" { | ||
| data "snowflake_listings" "assert_with_check_block" { | ||
| like = "listing-name" | ||
| } | ||
|
|
||
| assert { | ||
| condition = length(data.snowflake_listings.assert_with_check_block.listings) == 1 | ||
| error_message = "listings filtered by '${data.snowflake_listings.assert_with_check_block.like}' returned ${length(data.snowflake_listings.assert_with_check_block.listings)} listings where one was expected" | ||
| } | ||
| } | ||
| ``` | ||
|
|
||
| -> **Note** If a field has a default value, it is shown next to the type in the schema. | ||
|
|
||
| <!-- schema generated by tfplugindocs --> | ||
| ## Schema | ||
|
|
||
| ### Optional | ||
|
|
||
| - `like` (String) Filters the output with **case-insensitive** pattern, with support for SQL wildcard characters (`%` and `_`). | ||
| - `limit` (Block List, Max: 1) Limits the number of rows returned. If the `limit.from` is set, then the limit will start from the first element matched by the expression. The expression is only used to match with the first element, later on the elements are not matched by the prefix, but you can enforce a certain pattern with `starts_with` or `like`. (see [below for nested schema](#nestedblock--limit)) | ||
| - `starts_with` (String) Filters the output with **case-sensitive** characters indicating the beginning of the object name. | ||
| - `with_describe` (Boolean) (Default: `true`) Runs DESC LISTING for each listing returned by SHOW LISTINGS. The output of describe is saved to the description field. By default this value is set to true. | ||
|
|
||
| ### Read-Only | ||
|
|
||
| - `id` (String) The ID of this resource. | ||
| - `listings` (List of Object) Holds the aggregated output of all listings details queries. (see [below for nested schema](#nestedatt--listings)) | ||
|
|
||
| <a id="nestedblock--limit"></a> | ||
| ### Nested Schema for `limit` | ||
|
|
||
| Required: | ||
|
|
||
| - `rows` (Number) The maximum number of rows to return. | ||
|
|
||
| Optional: | ||
|
|
||
| - `from` (String) Specifies a **case-sensitive** pattern that is used to match object name. After the first match, the limit on the number of rows will be applied. | ||
|
|
||
|
|
||
| <a id="nestedatt--listings"></a> | ||
| ### Nested Schema for `listings` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `describe_output` (List of Object) (see [below for nested schema](#nestedobjatt--listings--describe_output)) | ||
| - `show_output` (List of Object) (see [below for nested schema](#nestedobjatt--listings--show_output)) | ||
|
|
||
| <a id="nestedobjatt--listings--describe_output"></a> | ||
| ### Nested Schema for `listings.describe_output` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `application_package` (String) | ||
| - `approver_contact` (String) | ||
| - `business_needs` (String) | ||
| - `categories` (String) | ||
| - `comment` (String) | ||
| - `created_on` (String) | ||
| - `customized_contact_info` (String) | ||
| - `data_attributes` (String) | ||
| - `data_dictionary` (String) | ||
| - `data_preview` (String) | ||
| - `description` (String) | ||
| - `distribution` (String) | ||
| - `global_name` (String) | ||
| - `is_application` (Boolean) | ||
| - `is_by_request` (Boolean) | ||
| - `is_limited_trial` (Boolean) | ||
| - `is_monetized` (Boolean) | ||
| - `is_mountless_queryable` (Boolean) | ||
| - `is_share` (Boolean) | ||
| - `is_targeted` (Boolean) | ||
| - `last_committed_version_alias` (String) | ||
| - `last_committed_version_name` (String) | ||
| - `last_committed_version_uri` (String) | ||
| - `legacy_uniform_listing_locators` (String) | ||
| - `limited_trial_plan` (String) | ||
| - `listing_terms` (String) | ||
| - `live_version_uri` (String) | ||
| - `manifest_yaml` (String) | ||
| - `monetization_display_order` (String) | ||
| - `name` (String) | ||
| - `organization_profile_name` (String) | ||
| - `owner` (String) | ||
| - `owner_role_type` (String) | ||
| - `profile` (String) | ||
| - `published_on` (String) | ||
| - `published_version_alias` (String) | ||
| - `published_version_name` (String) | ||
| - `published_version_uri` (String) | ||
| - `refresh_schedule` (String) | ||
| - `refresh_type` (String) | ||
| - `regions` (String) | ||
| - `rejection_reason` (String) | ||
| - `request_approval_type` (String) | ||
| - `resources` (String) | ||
| - `retried_on` (String) | ||
| - `review_state` (String) | ||
| - `revisions` (String) | ||
| - `scheduled_drop_time` (String) | ||
| - `share` (String) | ||
| - `state` (String) | ||
| - `subtitle` (String) | ||
| - `support_contact` (String) | ||
| - `target_accounts` (String) | ||
| - `title` (String) | ||
| - `trial_details` (String) | ||
| - `uniform_listing_locator` (String) | ||
| - `unpublished_by_admin_reasons` (String) | ||
| - `updated_on` (String) | ||
| - `usage_examples` (String) | ||
|
|
||
|
|
||
| <a id="nestedobjatt--listings--show_output"></a> | ||
| ### Nested Schema for `listings.show_output` | ||
|
|
||
| Read-Only: | ||
|
|
||
| - `comment` (String) | ||
| - `created_on` (String) | ||
| - `detailed_target_accounts` (String) | ||
| - `distribution` (String) | ||
| - `global_name` (String) | ||
| - `is_application` (Boolean) | ||
| - `is_by_request` (Boolean) | ||
| - `is_limited_trial` (Boolean) | ||
| - `is_monetized` (Boolean) | ||
| - `is_mountless_queryable` (Boolean) | ||
| - `is_targeted` (Boolean) | ||
| - `name` (String) | ||
| - `organization_profile_name` (String) | ||
| - `owner` (String) | ||
| - `owner_role_type` (String) | ||
| - `profile` (String) | ||
| - `published_on` (String) | ||
| - `regions` (String) | ||
| - `rejected_on` (String) | ||
| - `review_state` (String) | ||
| - `state` (String) | ||
| - `subtitle` (String) | ||
| - `target_accounts` (String) | ||
| - `title` (String) | ||
| - `uniform_listing_locator` (String) | ||
| - `updated_on` (String) | ||
|
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.