reports_service.proto 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425
  1. // Copyright 2022 Google LLC
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. syntax = "proto3";
  15. package google.cloud.channel.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/client.proto";
  18. import "google/api/field_behavior.proto";
  19. import "google/api/resource.proto";
  20. import "google/longrunning/operations.proto";
  21. import "google/protobuf/timestamp.proto";
  22. import "google/type/date.proto";
  23. import "google/type/datetime.proto";
  24. import "google/type/decimal.proto";
  25. import "google/type/money.proto";
  26. option go_package = "google.golang.org/genproto/googleapis/cloud/channel/v1;channel";
  27. option java_multiple_files = true;
  28. option java_outer_classname = "ReportsServiceProto";
  29. option java_package = "com.google.cloud.channel.v1";
  30. // CloudChannelReportsService lets Google Cloud resellers and
  31. // distributors retrieve and combine a variety of data in Cloud Channel for
  32. // multiple products (Google Cloud Platform (GCP), Google Voice, and
  33. // Google Workspace.)
  34. service CloudChannelReportsService {
  35. option (google.api.default_host) = "cloudchannel.googleapis.com";
  36. option (google.api.oauth_scopes) = "https://www.googleapis.com/auth/apps.reports.usage.readonly";
  37. // Begins generation of data for a given report. The report
  38. // identifier is a UID (for example, `613bf59q`).
  39. //
  40. // Possible error codes:
  41. //
  42. // * PERMISSION_DENIED: The user doesn't have access to this report.
  43. // * INVALID_ARGUMENT: Required request parameters are missing
  44. // or invalid.
  45. // * NOT_FOUND: The report identifier was not found.
  46. // * INTERNAL: Any non-user error related to a technical issue
  47. // in the backend. Contact Cloud Channel support.
  48. // * UNKNOWN: Any non-user error related to a technical issue
  49. // in the backend. Contact Cloud Channel support.
  50. //
  51. // Return value:
  52. // The ID of a long-running operation.
  53. //
  54. // To get the results of the operation, call the GetOperation method of
  55. // CloudChannelOperationsService. The Operation metadata contains an
  56. // instance of [OperationMetadata][google.cloud.channel.v1.OperationMetadata].
  57. //
  58. // To get the results of report generation, call
  59. // [CloudChannelReportsService.FetchReportResults][google.cloud.channel.v1.CloudChannelReportsService.FetchReportResults] with the
  60. // [RunReportJobResponse.report_job][google.cloud.channel.v1.RunReportJobResponse.report_job].
  61. rpc RunReportJob(RunReportJobRequest) returns (google.longrunning.Operation) {
  62. option (google.api.http) = {
  63. post: "/v1/{name=accounts/*/reports/*}:run"
  64. body: "*"
  65. };
  66. option (google.longrunning.operation_info) = {
  67. response_type: "RunReportJobResponse"
  68. metadata_type: "OperationMetadata"
  69. };
  70. }
  71. // Retrieves data generated by [CloudChannelReportsService.RunReportJob][google.cloud.channel.v1.CloudChannelReportsService.RunReportJob].
  72. rpc FetchReportResults(FetchReportResultsRequest) returns (FetchReportResultsResponse) {
  73. option (google.api.http) = {
  74. post: "/v1/{report_job=accounts/*/reportJobs/*}:fetchReportResults"
  75. body: "*"
  76. };
  77. option (google.api.method_signature) = "report_job";
  78. }
  79. // Lists the reports that RunReportJob can run. These reports include an ID,
  80. // a description, and the list of columns that will be in the result.
  81. rpc ListReports(ListReportsRequest) returns (ListReportsResponse) {
  82. option (google.api.http) = {
  83. get: "/v1/{parent=accounts/*}/reports"
  84. };
  85. option (google.api.method_signature) = "parent";
  86. }
  87. }
  88. // Request message for [CloudChannelReportsService.RunReportJob][google.cloud.channel.v1.CloudChannelReportsService.RunReportJob].
  89. message RunReportJobRequest {
  90. // Required. The report's resource name. Specifies the account and report used to
  91. // generate report data. The report_id identifier is a UID (for example,
  92. // `613bf59q`).
  93. // Name uses the format:
  94. // accounts/{account_id}/reports/{report_id}
  95. string name = 1 [
  96. (google.api.field_behavior) = REQUIRED,
  97. (google.api.resource_reference) = {
  98. type: "cloudchannel.googleapis.com/Report"
  99. }
  100. ];
  101. // Optional. The range of usage or invoice dates to include in the result.
  102. DateRange date_range = 2 [(google.api.field_behavior) = OPTIONAL];
  103. // Optional. A structured string that defines conditions on dimension columns to
  104. // restrict the report output.
  105. //
  106. // Filters support logical operators (AND, OR, NOT) and conditional operators
  107. // (=, !=, <, >, <=, and >=) using `column_id` as keys.
  108. //
  109. // For example:
  110. // `(customer:"accounts/C123abc/customers/S456def" OR
  111. // customer:"accounts/C123abc/customers/S789ghi") AND
  112. // invoice_start_date.year >= 2022`
  113. string filter = 3 [(google.api.field_behavior) = OPTIONAL];
  114. // Optional. The BCP-47 language code, such as "en-US". If specified, the
  115. // response is localized to the corresponding language code if the
  116. // original data sources support it.
  117. // Default is "en-US".
  118. string language_code = 4 [(google.api.field_behavior) = OPTIONAL];
  119. }
  120. // Response message for [CloudChannelReportsService.RunReportJob][google.cloud.channel.v1.CloudChannelReportsService.RunReportJob].
  121. message RunReportJobResponse {
  122. // Pass `report_job.name` to [FetchReportResultsRequest.report_job][google.cloud.channel.v1.FetchReportResultsRequest.report_job]
  123. // to retrieve the report's results.
  124. ReportJob report_job = 1;
  125. // The metadata for the report's results (display name, columns, row count,
  126. // and date range). If you view this before the operation finishes,
  127. // you may see incomplete data.
  128. ReportResultsMetadata report_metadata = 2;
  129. }
  130. // Request message for [CloudChannelReportsService.FetchReportResults][google.cloud.channel.v1.CloudChannelReportsService.FetchReportResults].
  131. message FetchReportResultsRequest {
  132. // Required. The report job created by [CloudChannelReportsService.RunReportJob][google.cloud.channel.v1.CloudChannelReportsService.RunReportJob].
  133. // Report_job uses the format:
  134. // accounts/{account_id}/reportJobs/{report_job_id}
  135. string report_job = 1 [
  136. (google.api.field_behavior) = REQUIRED,
  137. (google.api.resource_reference) = {
  138. type: "cloudchannel.googleapis.com/ReportJob"
  139. }
  140. ];
  141. // Optional. Requested page size of the report. The server may return fewer results than
  142. // requested. If you don't specify a page size, the server uses a sensible
  143. // default (may change over time).
  144. //
  145. // The maximum value is 30,000; the server will change larger values to
  146. // 30,000.
  147. int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
  148. // Optional. A token that specifies a page of results beyond the first page.
  149. // Obtained through
  150. // [FetchReportResultsResponse.next_page_token][google.cloud.channel.v1.FetchReportResultsResponse.next_page_token] of the previous
  151. // [CloudChannelReportsService.FetchReportResults][google.cloud.channel.v1.CloudChannelReportsService.FetchReportResults] call.
  152. string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
  153. }
  154. // Response message for [CloudChannelReportsService.FetchReportResults][google.cloud.channel.v1.CloudChannelReportsService.FetchReportResults].
  155. // Contains a tabular representation of the report results.
  156. message FetchReportResultsResponse {
  157. // The metadata for the report results (display name, columns, row count, and
  158. // date ranges).
  159. ReportResultsMetadata report_metadata = 1;
  160. // The report's lists of values. Each row follows the settings and ordering
  161. // of the columns from `report_metadata`.
  162. repeated Row rows = 2;
  163. // Pass this token to [FetchReportResultsRequest.page_token][google.cloud.channel.v1.FetchReportResultsRequest.page_token] to retrieve
  164. // the next page of results.
  165. string next_page_token = 3;
  166. }
  167. // Request message for [CloudChannelReportsService.ListReports][google.cloud.channel.v1.CloudChannelReportsService.ListReports].
  168. message ListReportsRequest {
  169. // Required. The resource name of the partner account to list available reports for.
  170. // Parent uses the format:
  171. // accounts/{account_id}
  172. string parent = 1 [(google.api.field_behavior) = REQUIRED];
  173. // Optional. Requested page size of the report. The server might return fewer results
  174. // than requested. If unspecified, returns 20 reports.
  175. // The maximum value is 100.
  176. int32 page_size = 2 [(google.api.field_behavior) = OPTIONAL];
  177. // Optional. A token that specifies a page of results beyond the first page.
  178. // Obtained through
  179. // [ListReportsResponse.next_page_token][google.cloud.channel.v1.ListReportsResponse.next_page_token] of the previous
  180. // [CloudChannelReportsService.ListReports][google.cloud.channel.v1.CloudChannelReportsService.ListReports] call.
  181. string page_token = 3 [(google.api.field_behavior) = OPTIONAL];
  182. // Optional. The BCP-47 language code, such as "en-US". If specified, the
  183. // response is localized to the corresponding language code if the
  184. // original data sources support it.
  185. // Default is "en-US".
  186. string language_code = 4 [(google.api.field_behavior) = OPTIONAL];
  187. }
  188. // Response message for [CloudChannelReportsService.ListReports][google.cloud.channel.v1.CloudChannelReportsService.ListReports].
  189. message ListReportsResponse {
  190. // The reports available to the partner.
  191. repeated Report reports = 1;
  192. // Pass this token to [FetchReportResultsRequest.page_token][google.cloud.channel.v1.FetchReportResultsRequest.page_token] to retrieve
  193. // the next page of results.
  194. string next_page_token = 2;
  195. }
  196. // The result of a [RunReportJob][] operation. Contains the name to use in
  197. // [FetchReportResultsRequest.report_job][google.cloud.channel.v1.FetchReportResultsRequest.report_job] and the status of the operation.
  198. message ReportJob {
  199. option (google.api.resource) = {
  200. type: "cloudchannel.googleapis.com/ReportJob"
  201. pattern: "accounts/{account}/reportJobs/{report_job}"
  202. };
  203. // Required. The resource name of a report job.
  204. // Name uses the format:
  205. // `accounts/{account_id}/reportJobs/{report_job_id}`
  206. string name = 1 [(google.api.field_behavior) = REQUIRED];
  207. // The current status of report generation.
  208. ReportStatus report_status = 2;
  209. }
  210. // The features describing the data. Returned by
  211. // [CloudChannelReportsService.RunReportJob][google.cloud.channel.v1.CloudChannelReportsService.RunReportJob] and
  212. // [CloudChannelReportsService.FetchReportResults][google.cloud.channel.v1.CloudChannelReportsService.FetchReportResults].
  213. message ReportResultsMetadata {
  214. // Details of the completed report.
  215. Report report = 1;
  216. // The total number of rows of data in the final report.
  217. int64 row_count = 2;
  218. // The date range of reported usage.
  219. DateRange date_range = 3;
  220. // The usage dates immediately preceding `date_range` with the same duration.
  221. // Use this to calculate trending usage and costs. This is only populated if
  222. // you request trending data.
  223. //
  224. // For example, if `date_range` is July 1-15, `preceding_date_range` will be
  225. // June 16-30.
  226. DateRange preceding_date_range = 4;
  227. }
  228. // The definition of a report column. Specifies the data properties
  229. // in the corresponding position of the report rows.
  230. message Column {
  231. // Available data types for columns. Corresponds to the fields in the
  232. // ReportValue `oneof` field.
  233. enum DataType {
  234. // Not used.
  235. DATA_TYPE_UNSPECIFIED = 0;
  236. // ReportValues for this column will use string_value.
  237. STRING = 1;
  238. // ReportValues for this column will use int_value.
  239. INT = 2;
  240. // ReportValues for this column will use decimal_value.
  241. DECIMAL = 3;
  242. // ReportValues for this column will use money_value.
  243. MONEY = 4;
  244. // ReportValues for this column will use date_value.
  245. DATE = 5;
  246. // ReportValues for this column will use date_time_value.
  247. DATE_TIME = 6;
  248. }
  249. // The unique name of the column (for example, customer_domain,
  250. // channel_partner, customer_cost). You can use column IDs in
  251. // [RunReportJobRequest.filter][google.cloud.channel.v1.RunReportJobRequest.filter].
  252. // To see all reports and their columns, call
  253. // [CloudChannelReportsService.ListReports][google.cloud.channel.v1.CloudChannelReportsService.ListReports].
  254. string column_id = 1;
  255. // The column's display name.
  256. string display_name = 2;
  257. // The type of the values for this column.
  258. DataType data_type = 3;
  259. }
  260. // A representation of usage or invoice date ranges.
  261. message DateRange {
  262. // The earliest usage date time (inclusive).
  263. //
  264. // If you use time groupings (daily, weekly, etc), each group uses
  265. // midnight to midnight (Pacific time). The usage start date is
  266. // rounded down to include all usage from the specified date. We recommend
  267. // that clients pass `usage_start_date_time` in Pacific time.
  268. google.type.DateTime usage_start_date_time = 1;
  269. // The latest usage date time (exclusive).
  270. //
  271. // If you use time groupings (daily, weekly, etc), each group uses
  272. // midnight to midnight (Pacific time). The usage end date is
  273. // rounded down to include all usage from the specified date. We recommend
  274. // that clients pass `usage_start_date_time` in Pacific time.
  275. google.type.DateTime usage_end_date_time = 2;
  276. // The earliest invoice date (inclusive).
  277. //
  278. // If your product uses monthly invoices, and this value is not the beginning
  279. // of a month, this will adjust the date to the first day of the given month.
  280. google.type.Date invoice_start_date = 3;
  281. // The latest invoice date (exclusive).
  282. //
  283. // If your product uses monthly invoices, and this value is not the beginning
  284. // of a month, this will adjust the date to the first day of the following
  285. // month.
  286. google.type.Date invoice_end_date = 4;
  287. }
  288. // A row of report values.
  289. message Row {
  290. // The list of values in the row.
  291. repeated ReportValue values = 1;
  292. }
  293. // A single report value.
  294. message ReportValue {
  295. // A single report value.
  296. oneof value {
  297. // A value of type `string`.
  298. string string_value = 1;
  299. // A value of type `int`.
  300. int64 int_value = 2;
  301. // A value of type `google.type.Decimal`, representing non-integer numeric
  302. // values.
  303. google.type.Decimal decimal_value = 3;
  304. // A value of type `google.type.Money` (currency code, whole units, decimal
  305. // units).
  306. google.type.Money money_value = 4;
  307. // A value of type `google.type.Date` (year, month, day).
  308. google.type.Date date_value = 5;
  309. // A value of type `google.type.DateTime` (year, month, day, hour, minute,
  310. // second, and UTC offset or timezone.)
  311. google.type.DateTime date_time_value = 6;
  312. }
  313. }
  314. // Status of a report generation process.
  315. message ReportStatus {
  316. // Available states of report generation.
  317. enum State {
  318. // Not used.
  319. STATE_UNSPECIFIED = 0;
  320. // Report processing started.
  321. STARTED = 1;
  322. // Data generated from the report is being staged.
  323. WRITING = 2;
  324. // Report data is available for access.
  325. AVAILABLE = 3;
  326. // Report failed.
  327. FAILED = 4;
  328. }
  329. // The current state of the report generation process.
  330. State state = 1;
  331. // The report generation's start time.
  332. google.protobuf.Timestamp start_time = 2;
  333. // The report generation's completion time.
  334. google.protobuf.Timestamp end_time = 3;
  335. }
  336. // The ID and description of a report that was used to generate report data.
  337. // For example, "GCP Daily Spend", "Google Workspace License Activity", etc.
  338. message Report {
  339. option (google.api.resource) = {
  340. type: "cloudchannel.googleapis.com/Report"
  341. pattern: "accounts/{account}/reports/{report}"
  342. };
  343. // Required. The report's resource name. Specifies the account and report used to
  344. // generate report data. The report_id identifier is a UID
  345. // (for example, `613bf59q`).
  346. //
  347. // Name uses the format:
  348. // accounts/{account_id}/reports/{report_id}
  349. string name = 1 [(google.api.field_behavior) = REQUIRED];
  350. // A human-readable name for this report.
  351. string display_name = 2;
  352. // The list of columns included in the report. This defines the schema of
  353. // the report results.
  354. repeated Column columns = 3;
  355. // A description of other aspects of the report, such as the products
  356. // it supports.
  357. string description = 4;
  358. }