// 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.cloud.productregistry.v1;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/productregistry/v1/logical_product.proto";
import "google/cloud/productregistry/v1/logical_product_variant.proto";
import "google/cloud/productregistry/v1/product_suite.proto";

option csharp_namespace = "Google.Cloud.ProductRegistry.V1";
option go_package = "cloud.google.com/go/productregistry/apiv1/productregistrypb;productregistrypb";
option java_multiple_files = true;
option java_outer_classname = "CloudProductRegistryReadServiceProto";
option java_package = "com.google.cloud.productregistry.v1";
option php_namespace = "Google\\Cloud\\ProductRegistry\\V1";
option ruby_package = "Google::Cloud::ProductRegistry::V1";

// Cloud Product Registry Read Service provides capabilities to access all first
// and third party Google Cloud products.
service CloudProductRegistryReadService {
  option (google.api.default_host) = "cloudproductregistry.googleapis.com";

  // Get details of a ProductSuite.
  rpc GetProductSuite(GetProductSuiteRequest) returns (ProductSuite) {
    option (google.api.http) = {
      get: "/v1/{name=productSuites/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists ProductSuites.
  rpc ListProductSuites(ListProductSuitesRequest)
      returns (ListProductSuitesResponse) {
    option (google.api.http) = {
      get: "/v1/productSuites"
    };
  }

  // Gets details of a LogicalProduct.
  rpc GetLogicalProduct(GetLogicalProductRequest) returns (LogicalProduct) {
    option (google.api.http) = {
      get: "/v1/{name=logicalProducts/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists LogicalProducts matching given criteria.
  rpc ListLogicalProducts(ListLogicalProductsRequest)
      returns (ListLogicalProductsResponse) {
    option (google.api.http) = {
      get: "/v1/logicalProducts"
    };
  }

  // Get details of a LogicalProductVariant.
  rpc GetLogicalProductVariant(GetLogicalProductVariantRequest)
      returns (LogicalProductVariant) {
    option (google.api.http) = {
      get: "/v1/{name=logicalProducts/*/variants/*}"
    };
    option (google.api.method_signature) = "name";
  }

  // Lists LogicalProductVariants matching given criteria.
  rpc ListLogicalProductVariants(ListLogicalProductVariantsRequest)
      returns (ListLogicalProductVariantsResponse) {
    option (google.api.http) = {
      get: "/v1/{parent=logicalProducts/*}/variants"
    };
    option (google.api.method_signature) = "parent";
  }

  // Look up entities.
  rpc LookupEntity(LookupEntityRequest) returns (LookupEntityResponse) {
    option (google.api.http) = {
      get: "/v1/{lookup_uri=logicalProducts/*}:lookupEntity"
      additional_bindings {
        get: "/v1/{lookup_uri=logicalProducts/*/variants/*}:lookupEntity"
      }
      additional_bindings {
        get: "/v1/{lookup_uri=productSuites/*}:lookupEntity"
      }
    };
  }
}

// Request message for GetProductSuite.
message GetProductSuiteRequest {
  // Required. The name of the ProductSuite to retrieve.
  // Format: productSuites/{product_suite}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudproductregistry.googleapis.com/ProductSuite"
    }
  ];
}

// Request message for GetLogicalProduct.
message GetLogicalProductRequest {
  // Required. The name of the LogicalProduct to retrieve.
  // Format: logicalProducts/{logical_product}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudproductregistry.googleapis.com/LogicalProduct"
    }
  ];
}

// Request message for GetLogicalProductVariant.
message GetLogicalProductVariantRequest {
  // Required. The name of the LogicalProductVariant to retrieve.
  // Format: logicalProducts/{logical_product}/variants/{variant}
  string name = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      type: "cloudproductregistry.googleapis.com/LogicalProductVariant"
    }
  ];
}

// Request message for ListProductSuites.
message ListProductSuitesRequest {
  // Optional. The maximum number of suites to return. The service may return
  // fewer than this value. If unspecified, at most 100 suites will be returned.
  // The maximum value is 500; values above 500 will be coerced to 500.
  int32 page_size = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A page token, received from a previous `ListProductSuites` call.
  // Provide this to retrieve the subsequent page.
  //
  // When paginating, all other parameters provided to `ListProductSuites` must
  // match the call that provided the page token.
  string page_token = 2 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for ListProductSuites.
message ListProductSuitesResponse {
  // Matched ProductSuites
  repeated ProductSuite product_suites = 1;

  // A token, which can be sent as `page_token` to retrieve the next page.
  // If this field is omitted, there are no subsequent pages.
  string next_page_token = 2;
}

// Request message for ListLogicalProducts.
message ListLogicalProductsRequest {
  // Optional. The filter expression for listing logical products.
  // Filter syntax: https://google.aip.dev/160
  // Supported fields: suite_id
  string filter = 1 [(google.api.field_behavior) = OPTIONAL];

  // Optional. The maximum number of logical products to return. The service may
  // return fewer than this value. If unspecified, at most 100 logical products
  // will be returned. The maximum value is 500; values above 500 will be
  // coerced to 500.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A page token, received from a previous `ListLogicalProducts`
  // call. Provide this to retrieve the subsequent page.
  //
  // When paginating, all other parameters provided to `ListLogicalProducts`
  // must match the call that provided the page token.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for ListLogicalProducts.
message ListLogicalProductsResponse {
  // Matched LogicalProducts
  repeated LogicalProduct logical_products = 1;

  // A token, which can be sent as `page_token` to retrieve the next page.
  // If this field is omitted, there are no subsequent pages.
  string next_page_token = 2;
}

// Request message for ListLogicalProductVariants.
message ListLogicalProductVariantsRequest {
  // Required. Parent logical product id.
  // Format: logicalProducts/{logical_product}
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = {
      child_type: "cloudproductregistry.googleapis.com/LogicalProductVariant"
    }
  ];

  // Optional. The maximum number of logical product variants to return. The
  // service may return fewer than this value. If unspecified, at most 100
  // logical product variants will be returned. The maximum value is 500; values
  // above 500 will be coerced to 500.
  int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];

  // Optional. A page token, received from a previous
  // `ListLogicalProductVariants` call. Provide this to retrieve the subsequent
  // page.
  //
  // When paginating, all other parameters provided to
  // `ListLogicalProductVariants` must match the call that provided the page
  // token.
  string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
}

// Response message for ListLogicalProductVariants.
message ListLogicalProductVariantsResponse {
  // Matched LogicalProductVariants
  repeated LogicalProductVariant logical_product_variants = 1;

  // A token, which can be sent as `page_token` to retrieve the next page.
  // If this field is omitted, there are no subsequent pages.
  string next_page_token = 2;
}

// Request message for LookupEntity.
message LookupEntityRequest {
  // Required. Entity uri to look up.
  // Supported Formats:
  // logicalProducts/{logical_product}
  // logicalProducts/{logical_product}/variants/{variant}
  // productSuites/{product_suite}
  string lookup_uri = 1 [(google.api.field_behavior) = REQUIRED];
}

// Response message for LookupEntity.
message LookupEntityResponse {
  // Matched entity.
  oneof entity {
    // Matched LogicalProduct.
    LogicalProduct logical_product = 1;

    // Matched LogicalProductVariant.
    LogicalProductVariant logical_product_variant = 2;

    // Matched ProductSuite.
    ProductSuite product_suite = 3;
  }
}
