// Copyright 2020 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.retail.v2alpha;

import "google/api/annotations.proto";
import "google/api/client.proto";
import "google/api/field_behavior.proto";
import "google/api/resource.proto";
import "google/cloud/retail/v2alpha/catalog.proto";
import "google/protobuf/field_mask.proto";

option csharp_namespace = "Google.Cloud.Retail.V2Alpha";
option go_package = "google.golang.org/genproto/googleapis/cloud/retail/v2alpha;retail";
option java_multiple_files = true;
option java_outer_classname = "CatalogServiceProto";
option java_package = "com.google.cloud.retail.v2alpha";
option objc_class_prefix = "RETAIL";
option php_namespace = "Google\\Cloud\\Retail\\V2alpha";
option ruby_package = "Google::Cloud::Retail::V2alpha";

// Service for managing catalog configuration.
service CatalogService {
  option (google.api.default_host) = "retail.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/cloud-platform";

  // Lists all the [Catalog][google.cloud.retail.v2alpha.Catalog]s associated
  // with the project.
  rpc ListCatalogs(ListCatalogsRequest) returns (ListCatalogsResponse) {
    option (google.api.http) = {
      get: "/v2alpha/{parent=projects/*/locations/*}/catalogs"
    };
    option (google.api.method_signature) = "parent";
  }

  // Updates the [Catalog][google.cloud.retail.v2alpha.Catalog]s.
  rpc UpdateCatalog(UpdateCatalogRequest) returns (Catalog) {
    option (google.api.http) = {
      patch: "/v2alpha/{catalog.name=projects/*/locations/*/catalogs/*}"
      body: "catalog"
    };
    option (google.api.method_signature) = "catalog,update_mask";
  }
}

// Request for
// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs]
// method.
message ListCatalogsRequest {
  // Required. The account resource name with an associated location.
  //
  // If the caller does not have permission to list
  // [Catalog][google.cloud.retail.v2alpha.Catalog]s under this location,
  // regardless of whether or not this location exists, a PERMISSION_DENIED
  // error is returned.
  string parent = 1 [
    (google.api.field_behavior) = REQUIRED,
    (google.api.resource_reference) = { type: "locations.googleapis.com/Location" }
  ];

  // Maximum number of [Catalog][google.cloud.retail.v2alpha.Catalog]s to
  // return. If unspecified, defaults to 50. The maximum allowed value is 1000.
  // Values above 1000 will be coerced to 1000.
  //
  // If this field is negative, an INVALID_ARGUMENT is returned.
  int32 page_size = 2;

  // A page token
  // [ListCatalogsResponse.next_page_token][google.cloud.retail.v2alpha.ListCatalogsResponse.next_page_token],
  // received from a previous
  // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs]
  // call. Provide this to retrieve the subsequent page.
  //
  // When paginating, all other parameters provided to
  // [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs]
  // must match the call that provided the page token. Otherwise, an
  // INVALID_ARGUMENT error is returned.
  string page_token = 3;
}

// Response for
// [CatalogService.ListCatalogs][google.cloud.retail.v2alpha.CatalogService.ListCatalogs]
// method.
message ListCatalogsResponse {
  // All the customer's [Catalog][google.cloud.retail.v2alpha.Catalog]s.
  repeated Catalog catalogs = 1;

  // A token that can be sent as
  // [ListCatalogsRequest.page_token][google.cloud.retail.v2alpha.ListCatalogsRequest.page_token]
  // to retrieve the next page. If this field is omitted, there are no
  // subsequent pages.
  string next_page_token = 2;
}

// Request for
// [CatalogService.UpdateCatalog][google.cloud.retail.v2alpha.CatalogService.UpdateCatalog]
// method.
message UpdateCatalogRequest {
  // Required. The [Catalog][google.cloud.retail.v2alpha.Catalog] to update.
  //
  // If the caller does not have permission to update the
  // [Catalog][google.cloud.retail.v2alpha.Catalog], regardless of whether or
  // not it exists, a PERMISSION_DENIED error is returned.
  //
  // If the [Catalog][google.cloud.retail.v2alpha.Catalog] to update does not
  // exist, a NOT_FOUND error is returned.
  Catalog catalog = 1 [(google.api.field_behavior) = REQUIRED];

  // Indicates which fields in the provided
  // [Catalog][google.cloud.retail.v2alpha.Catalog] to update. If not set, will
  // only update the
  // [Catalog.product_level_config][google.cloud.retail.v2alpha.Catalog.product_level_config]
  // field, which is also the only currently supported field to update.
  //
  // If an unsupported or unknown field is provided, an INVALID_ARGUMENT error
  // is returned.
  google.protobuf.FieldMask update_mask = 2;
}
