- release_tracks: [ALPHA, GA]

  help_text:
    brief: |
      Update a Looker instance.
    description: |
      Update the metadata and/or configuration parameters of a Looker instance.

      This command can fail for the following reasons:
        * The instance specified does not exist.
        * The active account does not have permission to update the given
          instance.
    examples: |
      To update the maintenance window to Sunday at 11:00 PM for a Looker instance with the name
      `my-looker-instance`, run:

        $ {command} my-looker-instance  --maintenance-window-day=sunday --maintenance-window-time='23:00' --async

  arguments:
    resource:
      spec: !REF googlecloudsdk.command_lib.looker.resources:instance
      help_text: |
        Arguments and flags that specify the Looker instance you want
        to update.
    params:
    # Public Enabled Flags
    - arg_name: public-ip-enabled
      api_field: instance.publicIpEnabled
      type: bool
      help_text: |
        This specifies whether public IP is enabled on the Looker instance.
    - arg_name: linked-lsp-project-number
      required: false
      api_field: instance.linkedLspProjectNumber
      type: long
      help_text: |
        The Looker Studio Pro project number to be linked.
    # Class Type for PD SSD
    - arg_name: class-type
      required: false
      api_field: instance.classType
      help_text: |
        The class type of the Looker instance.
      choices:
      - arg_value: r1
        enum_value: R1
      - arg_value: p1
        enum_value: P1
    # Group for Maintanence Windows
    - group:
        required: false
        help_text: |
          Maintenance Window - Maintenance typically only takes place once every few months, and requires your instance
          to be restarted while updates are made, which disrupts service briefly.
        params:
        - api_field: instance.maintenanceWindow.dayOfWeek
          required: true
          arg_name: maintenance-window-day
          choices:
          - arg_value: monday
            enum_value: MONDAY
          - arg_value: tuesday
            enum_value: TUESDAY
          - arg_value: wednesday
            enum_value: WEDNESDAY
          - arg_value: thursday
            enum_value: THURSDAY
          - arg_value: friday
            enum_value: FRIDAY
          - arg_value: saturday
            enum_value: SATURDAY
          - arg_value: sunday
            enum_value: SUNDAY
          help_text: |
            Day of the week for the maintenance window, in UTC time zone.
        - api_field: instance.maintenanceWindow.startTime
          arg_name: maintenance-window-time
          required: true
          ALPHA:
            processor: googlecloudsdk.command_lib.looker.instances_util:ParseTimeOfDayMainWindowV1Alpha
          GA:
            processor: googlecloudsdk.command_lib.looker.instances_util:ParseTimeOfDayMainWindowV1
          help_text: |
            Hour of day for maintenance window, in UTC time zone. A valid time of day must be
            specified in 24hr format (ex: 13:00, 17:30, 23:45). Maintenance will be scheduled
            within 60 minutes. To set the maintenance-window-time* attribute:
            * provide the argument *--maintenance-window-time* on the command line.
    # Group for Deny Maintanence period
    - group:
        required: false
        help_text: |
              Deny Maintanence Period - You must allow at least 48 hours of maintenance availability in
              a 60-day rolling window. Only contiguous availability windows of at least two hours are
              considered. When setting a maintenance exclusion please be aware that excluding
              application upgrades cannot exceed 60-days and excluding infrastructure upgrades cannot
              exceed 90-days.
        params:
        - api_field: instance.denyMaintenancePeriod.startDate
          arg_name: deny-maintenance-period-start-date
          required: true
          GA:
            processor: googlecloudsdk.command_lib.looker.instances_util:ParseToDateTypeV1
          ALPHA:
            processor: googlecloudsdk.command_lib.looker.instances_util:ParseToDateTypeV1Alpha
          help_text: |
                Start date of the deny maintenance period in format: YYYY-MM-DD
        - api_field: instance.denyMaintenancePeriod.endDate
          arg_name: deny-maintenance-period-end-date
          required: true
          GA:
            processor: googlecloudsdk.command_lib.looker.instances_util:ParseToDateTypeV1
          ALPHA:
            processor: googlecloudsdk.command_lib.looker.instances_util:ParseToDateTypeV1Alpha
          help_text: |
                End date of the deny maintenance period in format: YYYY-MM-DD
        - api_field: instance.denyMaintenancePeriod.time
          required: true
          arg_name: deny-maintenance-period-time
          GA:
            processor: googlecloudsdk.command_lib.looker.instances_util:ParseTimeOfDayDenyPeriodV1
          ALPHA:
            processor: googlecloudsdk.command_lib.looker.instances_util:ParseTimeOfDayDenyPeriodV1Alpha
          help_text: |
                Time in UTC when the period starts and ends.  A valid time of day must be
                specified in 24hr format (ex: 13:00, 17:30, 23:45).
    # Group for Admin Setting
    - group:
        required: false
        help_text: |
          Email Domain Allowlist for Scheduled Content - Define the email domains to which your
          users can deliver Looker (Google Cloud core) content.
        params:
        - arg_name: allowed-email-domains
          api_field: instance.adminSettings.allowedEmailDomains
          required: true
          help_text: |
            This specifies the entire allowed email domain list.
    # Group for Oauth configuration
    - group:
        required: false
        help_text: |
          OAuth Application Credentials - Looker Instance OAuth login settings. Setup an OAuth
          app that will allow users to authenticate and access the instance. For more
          information see: https://developers.google.com/identity/protocols/oauth2/web-server#creatingcred
        params:
        - arg_name: oauth-client-id
          api_field: instance.oauthConfig.clientId
          required: true
          help_text: |
            The client ID from an external OAuth application.
        - arg_name: oauth-client-secret
          api_field: instance.oauthConfig.clientSecret
          required: true
          help_text: |
            The client secret from an external OAuth application.
    # Group for Users Allocations
    - group:
        required: false
        help_text: |
          User Allocations - There are ten Standard and two Developer users included in the cost of
          the product. You can allocate additional Standard, Viewer, and Developer users for this
          instance. It is an optional step and can be modified later.

          With the Standard edition of Looker (Google Cloud core), you can provision up to 50 total
          users, distributed across Viewer, Standard, and Developer.
        params:
        - arg_name: add-viewer-users
          api_field: instance.userMetadata.additionalViewerUserCount
          help_text: |
            Number of additional Viewer Users to allocate to the Looker Instance.
        - arg_name: add-standard-users
          api_field: instance.userMetadata.additionalStandardUserCount
          help_text: |
            Number of additional Standard Users to allocate to the Looker Instance.
        - arg_name: add-developer-users
          api_field: instance.userMetadata.additionalDeveloperUserCount
          help_text: |
            Number of additional Developer Users to allocate to the Looker Instance.
    # Group for Gemini AI
    - group:
        required: false
        release_tracks: [ALPHA]
        help_text: |
          Gemini AI - Gemini AI is a powerful AI model that can be used to answer questions,
          generate content, and perform a variety of other tasks.
        params:
        - arg_name: gemini-enabled
          api_field: instance.geminiEnabled
          type: bool
          required: true
          help_text: |
            This specifies whether Gemini AI is enabled on the Looker instance. To disable Gemini AI,
            use the `--no-gemini-enabled` flag.
        - arg_name: gemini-preview-tester-enabled
          api_field: instance.geminiAiConfig.trustedTester
          required: true
          type: bool
          help_text: |
            This specifies whether user opts in for Gemini AI public preview for the Looker instance. To disable Gemini AI public preview,
            use the `--no-gemini-preview-tester-enabled` flag.
        - arg_name: gemini-prompt-log-enabled
          api_field: instance.geminiAiConfig.promptLogging
          required: true
          type: bool
          help_text: |
            This specifies whether user opts in for Gemini AI prompt logging for the Looker instance. To disable Gemini AI prompt logging,
            use the `--no-gemini-prompt-log-enabled` flag.
    # Group for Custom Domain
    - group:
        required: false
        help_text: |
          Custom Domains - Looker (Google Cloud core) lets you serve your application through a custom
          domain. If you use a custom domain, Google will provide a managed auto-renewing SSL
          certificate for security.

          DNS changes can take up to 24 hours to take effect. Your SSL certificate will take several
          minutes to activate. Note that you must get the Type A DNS Record from the Google Cloud
          Console and update with your domain registrar for your custom domain to work properly.
        params:
        - arg_name: custom-domain
          api_field: instance.customDomain.domain
          help_text: |
            Domain name wanted to serve the Looker instance.
    # Group for PSC
    - group:
        required: false
        help_text: |
          Private Service Connect - Private Service Connect allows the Looker Instance to be
          reached via a private connection from inside a VPC network, and for the Looker Instance
          to connect to managed services via private connections.
        params:
        - group:
            mutex: true
            params:
            - api_field: instance.pscConfig.allowedVpcs
              arg_name: psc-allowed-vpcs
              help_text: |
                List of VPCs that are allowed ingress into the Looker instance.
            - arg_name: clear-psc-allowed-vpcs
              action: store_true
              help_text: |
                Remove all service attachments from the PSC config of the instance.
        - group:
            mutex: true
            params:
            - api_field: instance.pscConfig.serviceAttachments
              arg_name: psc-service-attachment
              help_text: |
                Service attachments representing egress connections for the Looker instance.
                This flag can be repeated.
                (Example: --psc-service-attachment domain="mydomain.com",attachment="projects/my-project/regions/us-east1/serviceAttachments/sa" --psc-service-attachments domain="mydomain2.com",attachment="projects/my-project/regions/us-east1/serviceAttachments/sa2")

                You can also assign multiple domains to a single service attachment.
                (Example: --psc-service-attachment multiple-domains="mydomain.com;mydomain2.com",attachment="projects/my-project/regions/us-east1/serviceAttachments/sa")
              type:
                arg_dict:
                  flatten: false
                  spec:
                  - api_field: localFqdn
                    arg_name: domain
                    required: false
                    type: str
                  - api_field: targetServiceAttachmentUri
                    arg_name: attachment
                    type: str
                  - api_field: localFqdns
                    required: false
                    arg_name: multiple-domains
                    type: 'googlecloudsdk.calliope.arg_parsers:ArgList:custom_delim_char=;'
            - arg_name: clear-psc-service-attachments
              action: store_true
              help_text: |
                Remove all allowed VPCs from the PSC config of the instance.

  request:
    ALPHA:
      api_version: v1alpha2
      modify_request_hooks:
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateOauthClient
      - googlecloudsdk.command_lib.looker.instances_update_util:ModifyAllowedEmailDomains
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateMaintenanceWindow
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateUserMetadata
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateDenyMaintenancePeriod
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdatePublicIPEnabled
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateCustomDomain
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdatePscAllowedVpcs
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdatePscServiceAttachments
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateGeminiAiConfig
    GA:
      api_version: v1
      modify_request_hooks:
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateOauthClient
      - googlecloudsdk.command_lib.looker.instances_update_util:ModifyAllowedEmailDomains
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateMaintenanceWindow
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateUserMetadata
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateDenyMaintenancePeriod
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdatePublicIPEnabled
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdateCustomDomain
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdatePscAllowedVpcs
      - googlecloudsdk.command_lib.looker.instances_update_util:UpdatePscServiceAttachments
    collection: looker.projects.locations.instances

  update:
    disable_auto_field_mask: true

  async:
    collection: looker.projects.locations.operations

  output:
    format: none
