// Copyright 2024 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/rpc/status.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 = "YumArtifactProto";
option java_package = "com.google.devtools.artifactregistry.v1";
option php_namespace = "Google\\Cloud\\ArtifactRegistry\\V1";
option ruby_package = "Google::Cloud::ArtifactRegistry::V1";

// A detailed representation of a Yum artifact.
message YumArtifact {
  option (google.api.resource) = {
    type: "artifactregistry.googleapis.com/YumArtifact"
    pattern: "projects/{project}/locations/{location}/repositories/{repository}/yumArtifacts/{yum_artifact}"
  };

  // Package type is either binary or source.
  enum PackageType {
    // Package type is not specified.
    PACKAGE_TYPE_UNSPECIFIED = 0;

    // Binary package (.rpm).
    BINARY = 1;

    // Source package (.srpm).
    SOURCE = 2;
  }

  // Output only. The Artifact Registry resource name of the artifact.
  string name = 1 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. The yum package name of the artifact.
  string package_name = 2 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. An artifact is a binary or source package.
  PackageType package_type = 3 [(google.api.field_behavior) = OUTPUT_ONLY];

  // Output only. Operating system architecture of the artifact.
  string architecture = 4 [(google.api.field_behavior) = OUTPUT_ONLY];
}

// Google Cloud Storage location where the artifacts currently reside.
message ImportYumArtifactsGcsSource {
  // Cloud Storage paths URI (e.g., gs://my_bucket//my_object).
  repeated string uris = 1;

  // Supports URI wildcards for matching multiple objects from a single URI.
  bool use_wildcards = 2;
}

// The request to import new yum artifacts.
message ImportYumArtifactsRequest {
  // The source location of the package binaries.
  oneof source {
    // Google Cloud Storage location where input content is located.
    ImportYumArtifactsGcsSource gcs_source = 2;
  }

  // The name of the parent resource where the artifacts will be imported.
  string parent = 1;
}

// Error information explaining why a package was not imported.
message ImportYumArtifactsErrorInfo {
  // The source that was not imported.
  oneof source {
    // Google Cloud Storage location requested.
    ImportYumArtifactsGcsSource gcs_source = 1;
  }

  // The detailed error status.
  google.rpc.Status error = 2;
}

// The response message from importing YUM artifacts.
message ImportYumArtifactsResponse {
  // The yum artifacts imported.
  repeated YumArtifact yum_artifacts = 1;

  // Detailed error info for packages that were not imported.
  repeated ImportYumArtifactsErrorInfo errors = 2;
}

// The operation metadata for importing artifacts.
message ImportYumArtifactsMetadata {}
