// Copyright 2021 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 ccc.hosted.marketplace.v2;

import "google/api/annotations.proto";
import "google/apps/market/v2/resources.proto";
import "google/api/client.proto";

option go_package = "google.golang.org/genproto/googleapis/ccc/hosted/marketplace/v2;marketplace";
option java_multiple_files = true;
option java_outer_classname = "ServiceProto";
option java_package = "com.google.ccc.hosted.marketplace.v2";
option php_namespace = "Google\\Apps\\Market\\V2";

service CustomerLicenseService {
  option (google.api.default_host) = "appsmarket.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/appsmarketplace.license";

  // Get the status of a license for a customer to determine if they have access
  // for a given app.
  rpc Get(CustomerLicenseGetRequest) returns (CustomerLicense) {
    option (google.api.http) = {
      get: "/appsmarket/v2/customerLicense/{application_id}/{customer_id}"
    };
  }
}

service LicenseNotificationService {
  option (google.api.default_host) = "appsmarket.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/appsmarketplace.license";

  // Get a list of licensing notifications with regards to a given app.
  rpc List(LicenseNotificationListRequest) returns (LicenseNotificationList) {
    option (google.api.http) = {
      get: "/appsmarket/v2/licenseNotification/{application_id}"
      body: "*"
    };
  }
}

service UserLicenseService {
  option (google.api.default_host) = "appsmarket.googleapis.com";
  option (google.api.oauth_scopes) =
      "https://www.googleapis.com/auth/appsmarketplace.license";

  // Get the user's licensing status for their permission to use a given app.
  rpc Get(UserLicenseGetRequest) returns (UserLicense) {
    option (google.api.http) = {
      get: "/appsmarket/v2/userLicense/{application_id}/{user_id}"
    };
  }
}

message CustomerLicenseGetRequest {
  // Application Id
  string application_id = 1;

  // Customer Id
  string customer_id = 2;
}

message LicenseNotificationListRequest {
  // Application Id
  string application_id = 1;

  uint32 max_results = 2;

  string start_token = 3;

  // Timestamp in milliseconds since epoch
  uint64 timestamp = 4;
}

message UserLicenseGetRequest {
  // Application Id
  string application_id = 1;

  // User Id
  string user_id = 2;
}
