serviceusage.proto 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301
  1. // Copyright 2021 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.api.serviceusage.v1;
  16. import "google/api/annotations.proto";
  17. import "google/api/serviceusage/v1/resources.proto";
  18. import "google/longrunning/operations.proto";
  19. import "google/api/client.proto";
  20. option csharp_namespace = "Google.Cloud.ServiceUsage.V1";
  21. option go_package = "google.golang.org/genproto/googleapis/api/serviceusage/v1;serviceusage";
  22. option java_multiple_files = true;
  23. option java_outer_classname = "ServiceUsageProto";
  24. option java_package = "com.google.api.serviceusage.v1";
  25. option php_namespace = "Google\\Cloud\\ServiceUsage\\V1";
  26. option ruby_package = "Google::Cloud::ServiceUsage::V1";
  27. // Enables services that service consumers want to use on Google Cloud Platform,
  28. // lists the available or enabled services, or disables services that service
  29. // consumers no longer use.
  30. //
  31. // See [Service Usage API](https://cloud.google.com/service-usage/docs/overview)
  32. service ServiceUsage {
  33. option (google.api.default_host) = "serviceusage.googleapis.com";
  34. option (google.api.oauth_scopes) =
  35. "https://www.googleapis.com/auth/cloud-platform,"
  36. "https://www.googleapis.com/auth/cloud-platform.read-only,"
  37. "https://www.googleapis.com/auth/service.management";
  38. // Enable a service so that it can be used with a project.
  39. rpc EnableService(EnableServiceRequest) returns (google.longrunning.Operation) {
  40. option (google.api.http) = {
  41. post: "/v1/{name=*/*/services/*}:enable"
  42. body: "*"
  43. };
  44. option (google.longrunning.operation_info) = {
  45. response_type: "EnableServiceResponse"
  46. metadata_type: "OperationMetadata"
  47. };
  48. }
  49. // Disable a service so that it can no longer be used with a project.
  50. // This prevents unintended usage that may cause unexpected billing
  51. // charges or security leaks.
  52. //
  53. // It is not valid to call the disable method on a service that is not
  54. // currently enabled. Callers will receive a `FAILED_PRECONDITION` status if
  55. // the target service is not currently enabled.
  56. rpc DisableService(DisableServiceRequest) returns (google.longrunning.Operation) {
  57. option (google.api.http) = {
  58. post: "/v1/{name=*/*/services/*}:disable"
  59. body: "*"
  60. };
  61. option (google.longrunning.operation_info) = {
  62. response_type: "DisableServiceResponse"
  63. metadata_type: "OperationMetadata"
  64. };
  65. }
  66. // Returns the service configuration and enabled state for a given service.
  67. rpc GetService(GetServiceRequest) returns (Service) {
  68. option (google.api.http) = {
  69. get: "/v1/{name=*/*/services/*}"
  70. };
  71. }
  72. // List all services available to the specified project, and the current
  73. // state of those services with respect to the project. The list includes
  74. // all public services, all services for which the calling user has the
  75. // `servicemanagement.services.bind` permission, and all services that have
  76. // already been enabled on the project. The list can be filtered to
  77. // only include services in a specific state, for example to only include
  78. // services enabled on the project.
  79. //
  80. // WARNING: If you need to query enabled services frequently or across
  81. // an organization, you should use
  82. // [Cloud Asset Inventory
  83. // API](https://cloud.google.com/asset-inventory/docs/apis), which provides
  84. // higher throughput and richer filtering capability.
  85. rpc ListServices(ListServicesRequest) returns (ListServicesResponse) {
  86. option (google.api.http) = {
  87. get: "/v1/{parent=*/*}/services"
  88. };
  89. }
  90. // Enable multiple services on a project. The operation is atomic: if enabling
  91. // any service fails, then the entire batch fails, and no state changes occur.
  92. // To enable a single service, use the `EnableService` method instead.
  93. rpc BatchEnableServices(BatchEnableServicesRequest) returns (google.longrunning.Operation) {
  94. option (google.api.http) = {
  95. post: "/v1/{parent=*/*}/services:batchEnable"
  96. body: "*"
  97. };
  98. option (google.longrunning.operation_info) = {
  99. response_type: "BatchEnableServicesResponse"
  100. metadata_type: "OperationMetadata"
  101. };
  102. }
  103. // Returns the service configurations and enabled states for a given list of
  104. // services.
  105. rpc BatchGetServices(BatchGetServicesRequest) returns (BatchGetServicesResponse) {
  106. option (google.api.http) = {
  107. get: "/v1/{parent=*/*}/services:batchGet"
  108. };
  109. }
  110. }
  111. // Request message for the `EnableService` method.
  112. message EnableServiceRequest {
  113. // Name of the consumer and service to enable the service on.
  114. //
  115. // The `EnableService` and `DisableService` methods currently only support
  116. // projects.
  117. //
  118. // Enabling a service requires that the service is public or is shared with
  119. // the user enabling the service.
  120. //
  121. // An example name would be:
  122. // `projects/123/services/serviceusage.googleapis.com` where `123` is the
  123. // project number.
  124. string name = 1;
  125. }
  126. // Response message for the `EnableService` method.
  127. // This response message is assigned to the `response` field of the returned
  128. // Operation when that operation is done.
  129. message EnableServiceResponse {
  130. // The new state of the service after enabling.
  131. Service service = 1;
  132. }
  133. // Request message for the `DisableService` method.
  134. message DisableServiceRequest {
  135. // Enum to determine if service usage should be checked when disabling a
  136. // service.
  137. enum CheckIfServiceHasUsage {
  138. // When unset, the default behavior is used, which is SKIP.
  139. CHECK_IF_SERVICE_HAS_USAGE_UNSPECIFIED = 0;
  140. // If set, skip checking service usage when disabling a service.
  141. SKIP = 1;
  142. // If set, service usage is checked when disabling the service. If a
  143. // service, or its dependents, has usage in the last 30 days, the request
  144. // returns a FAILED_PRECONDITION error.
  145. CHECK = 2;
  146. }
  147. // Name of the consumer and service to disable the service on.
  148. //
  149. // The enable and disable methods currently only support projects.
  150. //
  151. // An example name would be:
  152. // `projects/123/services/serviceusage.googleapis.com` where `123` is the
  153. // project number.
  154. string name = 1;
  155. // Indicates if services that are enabled and which depend on this service
  156. // should also be disabled. If not set, an error will be generated if any
  157. // enabled services depend on the service to be disabled. When set, the
  158. // service, and any enabled services that depend on it, will be disabled
  159. // together.
  160. bool disable_dependent_services = 2;
  161. // Defines the behavior for checking service usage when disabling a service.
  162. CheckIfServiceHasUsage check_if_service_has_usage = 3;
  163. }
  164. // Response message for the `DisableService` method.
  165. // This response message is assigned to the `response` field of the returned
  166. // Operation when that operation is done.
  167. message DisableServiceResponse {
  168. // The new state of the service after disabling.
  169. Service service = 1;
  170. }
  171. // Request message for the `GetService` method.
  172. message GetServiceRequest {
  173. // Name of the consumer and service to get the `ConsumerState` for.
  174. //
  175. // An example name would be:
  176. // `projects/123/services/serviceusage.googleapis.com` where `123` is the
  177. // project number.
  178. string name = 1;
  179. }
  180. // Request message for the `ListServices` method.
  181. message ListServicesRequest {
  182. // Parent to search for services on.
  183. //
  184. // An example name would be:
  185. // `projects/123` where `123` is the project number.
  186. string parent = 1;
  187. // Requested size of the next page of data.
  188. // Requested page size cannot exceed 200.
  189. // If not set, the default page size is 50.
  190. int32 page_size = 2;
  191. // Token identifying which result to start with, which is returned by a
  192. // previous list call.
  193. string page_token = 3;
  194. // Only list services that conform to the given filter.
  195. // The allowed filter strings are `state:ENABLED` and `state:DISABLED`.
  196. string filter = 4;
  197. }
  198. // Response message for the `ListServices` method.
  199. message ListServicesResponse {
  200. // The available services for the requested project.
  201. repeated Service services = 1;
  202. // Token that can be passed to `ListServices` to resume a paginated
  203. // query.
  204. string next_page_token = 2;
  205. }
  206. // Request message for the `BatchEnableServices` method.
  207. message BatchEnableServicesRequest {
  208. // Parent to enable services on.
  209. //
  210. // An example name would be:
  211. // `projects/123` where `123` is the project number.
  212. //
  213. // The `BatchEnableServices` method currently only supports projects.
  214. string parent = 1;
  215. // The identifiers of the services to enable on the project.
  216. //
  217. // A valid identifier would be:
  218. // serviceusage.googleapis.com
  219. //
  220. // Enabling services requires that each service is public or is shared with
  221. // the user enabling the service.
  222. //
  223. // A single request can enable a maximum of 20 services at a time. If more
  224. // than 20 services are specified, the request will fail, and no state changes
  225. // will occur.
  226. repeated string service_ids = 2;
  227. }
  228. // Response message for the `BatchEnableServices` method.
  229. // This response message is assigned to the `response` field of the returned
  230. // Operation when that operation is done.
  231. message BatchEnableServicesResponse {
  232. // Provides error messages for the failing services.
  233. message EnableFailure {
  234. // The service id of a service that could not be enabled.
  235. string service_id = 1;
  236. // An error message describing why the service could not be enabled.
  237. string error_message = 2;
  238. }
  239. // The new state of the services after enabling.
  240. repeated Service services = 1;
  241. // If allow_partial_success is true, and one or more services could not be
  242. // enabled, this field contains the details about each failure.
  243. repeated EnableFailure failures = 2;
  244. }
  245. // Request message for the `BatchGetServices` method.
  246. message BatchGetServicesRequest {
  247. // Parent to retrieve services from.
  248. // If this is set, the parent of all of the services specified in `names` must
  249. // match this field. An example name would be: `projects/123` where `123` is
  250. // the project number. The `BatchGetServices` method currently only supports
  251. // projects.
  252. string parent = 1;
  253. // Names of the services to retrieve.
  254. //
  255. // An example name would be:
  256. // `projects/123/services/serviceusage.googleapis.com` where `123` is the
  257. // project number.
  258. // A single request can get a maximum of 30 services at a time.
  259. repeated string names = 2;
  260. }
  261. // Response message for the `BatchGetServices` method.
  262. message BatchGetServicesResponse {
  263. // The requested Service states.
  264. repeated Service services = 1;
  265. }