// Copyright 2026 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.

syntax = "proto3";

package google.devtools.artifactregistry.v1;

import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/devtools/artifactregistry/v1/file.proto";
import "google/devtools/artifactregistry/v1/version.proto";

option csharp_namespace = "Google.Cloud.ArtifactRegistry.V1";
option go_package = "cloud.google.com/go/artifactregistry/apiv1/artifactregistrypb;artifactregistrypb";
option java_multiple_files = true;
option java_outer_classname = "ExportProto";
option java_package = "com.google.devtools.artifactregistry.v1";
option php_namespace = "Google\\Cloud\\ArtifactRegistry\\V1";
option ruby_package = "Google::Cloud::ArtifactRegistry::V1";

// The request for exporting an artifact to a destination.
message ExportArtifactRequest {
  // The artifact to be exported.
  oneof source_artifact {
    // The artifact version to export.
    // Format:
    // projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/versions/{version}
    string source_version = 2 [(google.api.resource_reference) = {
      type: "artifactregistry.googleapis.com/Version"
    }];

    // The artifact tag to export.
    // Format:projects/{project}/locations/{location}/repositories/{repository}/packages/{package}/tags/{tag}
    string source_tag = 4 [(google.api.resource_reference) = {
      type: "artifactregistry.googleapis.com/Tag"
    }];
  }

  // The destination to export the artifact to.
  oneof destination {
    // The Cloud Storage path to export the artifact to. Should start with the
    // bucket name, and optionally have a directory path. Examples:
    // `dst_bucket`, `dst_bucket/sub_dir`.
    // Existing objects with the same path will be overwritten.
    string gcs_path = 3;
  }

  // Required. The repository of the artifact to export.
  // Format: projects/{project}/locations/{location}/repositories/{repository}
  string repository = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "artifactregistry.googleapis.com/Repository"
    }
  ];
}

// The response for exporting an artifact to a destination.
message ExportArtifactResponse {
  // The exported version. Should be the same as the request version with
  // fingerprint resource name.
  Version exported_version = 1;
}

// The LRO metadata for exporting an artifact.
message ExportArtifactMetadata {
  // The exported artifact file.
  message ExportedFile {
    // The destination the file was exported to.
    oneof destination {
      // Cloud Storage Object path of the exported file. Examples:
      // `dst_bucket/file1`, `dst_bucket/sub_dir/file1`
      string gcs_object_path = 2;
    }

    // Name of the exported artifact file.
    // Format: `projects/p1/locations/us/repositories/repo1/files/file1`
    string name = 1 [(google.api.resource_reference) = {
      type: "artifactregistry.googleapis.com/File"
    }];

    // The hashes of the file content.
    repeated Hash hashes = 3;
  }

  // The exported artifact files.
  repeated ExportedFile exported_files = 1;
}
