# Copyright 2025 Google Inc.
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

---
name: 'LogicalView'
kind: 'bigtable#logicalView'
description: |
  A logical view object that can be referenced in SQL queries.
references:
  guides:
  api: 'https://cloud.google.com/bigtable/docs/reference/admin/rest/v2/projects.instances.logicalViews'
docs:
id_format: 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
base_url: 'projects/{{project}}/instances/{{instance}}/logicalViews?logicalViewId={{logical_view_id}}'
self_link: 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
create_url: 'projects/{{project}}/instances/{{instance}}/logicalViews?logicalViewId={{logical_view_id}}'
update_url: 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
update_verb: 'PATCH'
update_mask: true
delete_url: 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
import_format:
  - 'projects/{{project}}/instances/{{instance}}/logicalViews/{{logical_view_id}}'
timeouts:
  insert_minutes: 120
  update_minutes: 20
  delete_minutes: 20
exclude_sweeper: true
examples:
  - name: 'bigtable_logical_view'
    primary_resource_id: 'logical_view'
    vars:
      instance_name: 'bt-instance'
      table_name: 'bt-table'
      logical_view_name: 'bt-logical-view'
    # bigtable instance does not use the shared HTTP client, this test creates an instance
    skip_vcr: true
parameters:
  - name: 'logicalViewId'
    type: String
    description:
      'The unique name of the logical view in the form
      `[_a-zA-Z0-9][-_.a-zA-Z0-9]*`.'
    url_param_only: true
    required: true
    immutable: true
  - name: 'instance'
    type: String
    description: 'The name of the instance to create the logical view within.'
    url_param_only: true
    immutable: true
    diff_suppress_func: 'tpgresource.CompareResourceNames'
properties:
  - name: 'name'
    type: String
    description:
      'The unique name of the requested logical view. Values are of the form
      `projects/<project>/instances/<instance>/logicalViews/<logicalViewId>`.'
    output: true
  - name: 'query'
    type: String
    description:
      'The logical view''s select query.'
    required: true
