artifacts_api.py 1.4 KB

123456789101112131415161718192021222324252627282930313233
  1. # Copyright Materialize, Inc. and contributors. All rights reserved.
  2. #
  3. # Use of this software is governed by the Business Source License
  4. # included in the LICENSE file at the root of this repository.
  5. #
  6. # As of the Change Date specified in that file, in accordance with
  7. # the Business Source License, use of this software will be governed
  8. # by the Apache License, Version 2.0.
  9. from typing import Any
  10. from materialize.buildkite_insights.buildkite_api import generic_api
  11. def get_build_job_artifact_list(
  12. pipeline_slug: str, build_number: int, job_id: str
  13. ) -> list[Any]:
  14. request_path = f"organizations/materialize/pipelines/{pipeline_slug}/builds/{build_number}/jobs/{job_id}/artifacts"
  15. return generic_api.get(request_path, {})
  16. def download_artifact(
  17. pipeline_slug: str, build_number: int, job_id: str, artifact_id: str
  18. ) -> str:
  19. request_path = f"organizations/materialize/pipelines/{pipeline_slug}/builds/{build_number}/jobs/{job_id}/artifacts/{artifact_id}/download"
  20. return generic_api.get(request_path, {}, as_json=False)
  21. def download_artifact_to_file(
  22. pipeline_slug: str, build_number: int, job_id: str, artifact_id: str, file_path: str
  23. ) -> str:
  24. request_path = f"organizations/materialize/pipelines/{pipeline_slug}/builds/{build_number}/jobs/{job_id}/artifacts/{artifact_id}/download"
  25. return generic_api.get_and_download_to_file(request_path, {}, file_path)