# Copyright 2021 Google LLC
#
# 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.

---

steps:

# See https://cloud.google.com/filestore/docs/troubleshooting#api_cannot_be_disabled
- name: us-central1-docker.pkg.dev/$PROJECT_ID/hpc-toolkit-repo/hpc-toolkit-builder
  entrypoint: /bin/bash
  args:
  - -c
  - |
    curl -X POST \
    "https://serviceusage.googleapis.com/v1/projects/${PROJECT_ID}/services/file.googleapis.com:disable" \
    --header "Content-Type: application/json" \
    --header "Authorization: Bearer "$(gcloud auth print-access-token) \
    --data '{"checkIfServiceHasUsage": "SKIP", "disableDependentServices": false}'

# previous call is async, give time for it to resolve
- name: us-central1-docker.pkg.dev/$PROJECT_ID/hpc-toolkit-repo/hpc-toolkit-builder
  entrypoint: sleep
  args:
  - "60"

- name: us-central1-docker.pkg.dev/$PROJECT_ID/hpc-toolkit-repo/hpc-toolkit-builder
  entrypoint: gcloud
  args:
  - services
  - enable
  - --project=${PROJECT_ID}
  - file.googleapis.com

- name: us-central1-docker.pkg.dev/$PROJECT_ID/hpc-toolkit-repo/hpc-toolkit-builder
  entrypoint: /bin/bash
  env:
  - "PROJECT_ID=${PROJECT_ID}"
  args:
  - -c
  - |
    set -e
    /workspace/tools/clean-resource-policies.sh

# Copyright 2021 Google LLC
#
# 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.

---

steps:
- name: us-central1-docker.pkg.dev/$PROJECT_ID/hpc-toolkit-repo/hpc-toolkit-builder
  entrypoint: /bin/bash
  env:
  - "PROJECT_ID=${PROJECT_ID}"
  args:
  - -c
  - |
    set -e
    /workspace/tools/clean-resource-policies.sh

Revert "Toggle filestore api as part of nightly cleanup"
Revert "Toggle filestore api as part of nightly cleanup"

This reverts commit db998396ba6438979e065a3a940178f6af965d05.
This reverts commit 67b2dc90e595bd1c8a52afa29aa4fabc460e706e.
