google-cloud-org_policy-v2 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,51 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+ require "googleauth"
20
+
21
+ module Google
22
+ module Cloud
23
+ module OrgPolicy
24
+ module V2
25
+ module OrgPolicy
26
+ # Credentials for the OrgPolicy API.
27
+ class Credentials < ::Google::Auth::Credentials
28
+ self.scope = [
29
+ "https://www.googleapis.com/auth/cloud-platform"
30
+ ]
31
+ self.env_vars = [
32
+ "ORG_POLICY_CREDENTIALS",
33
+ "ORG_POLICY_KEYFILE",
34
+ "GOOGLE_CLOUD_CREDENTIALS",
35
+ "GOOGLE_CLOUD_KEYFILE",
36
+ "GCLOUD_KEYFILE",
37
+ "ORG_POLICY_CREDENTIALS_JSON",
38
+ "ORG_POLICY_KEYFILE_JSON",
39
+ "GOOGLE_CLOUD_CREDENTIALS_JSON",
40
+ "GOOGLE_CLOUD_KEYFILE_JSON",
41
+ "GCLOUD_KEYFILE_JSON"
42
+ ]
43
+ self.paths = [
44
+ "~/.config/google_cloud/application_default_credentials.json"
45
+ ]
46
+ end
47
+ end
48
+ end
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,127 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+
20
+ module Google
21
+ module Cloud
22
+ module OrgPolicy
23
+ module V2
24
+ module OrgPolicy
25
+ # Path helper methods for the OrgPolicy API.
26
+ module Paths
27
+ ##
28
+ # Create a fully-qualified Folder resource string.
29
+ #
30
+ # The resource will be in the following format:
31
+ #
32
+ # `folders/{folder}`
33
+ #
34
+ # @param folder [String]
35
+ #
36
+ # @return [::String]
37
+ def folder_path folder:
38
+ "folders/#{folder}"
39
+ end
40
+
41
+ ##
42
+ # Create a fully-qualified Organization resource string.
43
+ #
44
+ # The resource will be in the following format:
45
+ #
46
+ # `organizations/{organization}`
47
+ #
48
+ # @param organization [String]
49
+ #
50
+ # @return [::String]
51
+ def organization_path organization:
52
+ "organizations/#{organization}"
53
+ end
54
+
55
+ ##
56
+ # Create a fully-qualified Policy resource string.
57
+ #
58
+ # @overload policy_path(project:, policy:)
59
+ # The resource will be in the following format:
60
+ #
61
+ # `projects/{project}/policies/{policy}`
62
+ #
63
+ # @param project [String]
64
+ # @param policy [String]
65
+ #
66
+ # @overload policy_path(folder:, policy:)
67
+ # The resource will be in the following format:
68
+ #
69
+ # `folders/{folder}/policies/{policy}`
70
+ #
71
+ # @param folder [String]
72
+ # @param policy [String]
73
+ #
74
+ # @overload policy_path(organization:, policy:)
75
+ # The resource will be in the following format:
76
+ #
77
+ # `organizations/{organization}/policies/{policy}`
78
+ #
79
+ # @param organization [String]
80
+ # @param policy [String]
81
+ #
82
+ # @return [::String]
83
+ def policy_path **args
84
+ resources = {
85
+ "policy:project" => (proc do |project:, policy:|
86
+ raise ::ArgumentError, "project cannot contain /" if project.to_s.include? "/"
87
+
88
+ "projects/#{project}/policies/#{policy}"
89
+ end),
90
+ "folder:policy" => (proc do |folder:, policy:|
91
+ raise ::ArgumentError, "folder cannot contain /" if folder.to_s.include? "/"
92
+
93
+ "folders/#{folder}/policies/#{policy}"
94
+ end),
95
+ "organization:policy" => (proc do |organization:, policy:|
96
+ raise ::ArgumentError, "organization cannot contain /" if organization.to_s.include? "/"
97
+
98
+ "organizations/#{organization}/policies/#{policy}"
99
+ end)
100
+ }
101
+
102
+ resource = resources[args.keys.sort.join(":")]
103
+ raise ::ArgumentError, "no resource found for values #{args.keys}" if resource.nil?
104
+ resource.call(**args)
105
+ end
106
+
107
+ ##
108
+ # Create a fully-qualified Project resource string.
109
+ #
110
+ # The resource will be in the following format:
111
+ #
112
+ # `projects/{project}`
113
+ #
114
+ # @param project [String]
115
+ #
116
+ # @return [::String]
117
+ def project_path project:
118
+ "projects/#{project}"
119
+ end
120
+
121
+ extend self
122
+ end
123
+ end
124
+ end
125
+ end
126
+ end
127
+ end
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Copyright 2021 Google LLC
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # https://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+
17
+ # Auto-generated by gapic-generator-ruby. DO NOT EDIT!
18
+
19
+
20
+ module Google
21
+ module Cloud
22
+ module OrgPolicy
23
+ module V2
24
+ VERSION = "0.1.0"
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,45 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/orgpolicy/v2/constraint.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/field_behavior_pb'
7
+ require 'google/api/resource_pb'
8
+ Google::Protobuf::DescriptorPool.generated_pool.build do
9
+ add_file("google/cloud/orgpolicy/v2/constraint.proto", :syntax => :proto3) do
10
+ add_message "google.cloud.orgpolicy.v2.Constraint" do
11
+ optional :name, :string, 1
12
+ optional :display_name, :string, 2
13
+ optional :description, :string, 3
14
+ optional :constraint_default, :enum, 4, "google.cloud.orgpolicy.v2.Constraint.ConstraintDefault"
15
+ oneof :constraint_type do
16
+ optional :list_constraint, :message, 5, "google.cloud.orgpolicy.v2.Constraint.ListConstraint"
17
+ optional :boolean_constraint, :message, 6, "google.cloud.orgpolicy.v2.Constraint.BooleanConstraint"
18
+ end
19
+ end
20
+ add_message "google.cloud.orgpolicy.v2.Constraint.ListConstraint" do
21
+ optional :supports_in, :bool, 1
22
+ optional :supports_under, :bool, 2
23
+ end
24
+ add_message "google.cloud.orgpolicy.v2.Constraint.BooleanConstraint" do
25
+ end
26
+ add_enum "google.cloud.orgpolicy.v2.Constraint.ConstraintDefault" do
27
+ value :CONSTRAINT_DEFAULT_UNSPECIFIED, 0
28
+ value :ALLOW, 1
29
+ value :DENY, 2
30
+ end
31
+ end
32
+ end
33
+
34
+ module Google
35
+ module Cloud
36
+ module OrgPolicy
37
+ module V2
38
+ Constraint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.Constraint").msgclass
39
+ Constraint::ListConstraint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.Constraint.ListConstraint").msgclass
40
+ Constraint::BooleanConstraint = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.Constraint.BooleanConstraint").msgclass
41
+ Constraint::ConstraintDefault = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.Constraint.ConstraintDefault").enummodule
42
+ end
43
+ end
44
+ end
45
+ end
@@ -0,0 +1,103 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # source: google/cloud/orgpolicy/v2/orgpolicy.proto
3
+
4
+ require 'google/protobuf'
5
+
6
+ require 'google/api/annotations_pb'
7
+ require 'google/api/client_pb'
8
+ require 'google/api/field_behavior_pb'
9
+ require 'google/api/resource_pb'
10
+ require 'google/cloud/orgpolicy/v2/constraint_pb'
11
+ require 'google/protobuf/empty_pb'
12
+ require 'google/protobuf/timestamp_pb'
13
+ require 'google/type/expr_pb'
14
+ Google::Protobuf::DescriptorPool.generated_pool.build do
15
+ add_file("google/cloud/orgpolicy/v2/orgpolicy.proto", :syntax => :proto3) do
16
+ add_message "google.cloud.orgpolicy.v2.Policy" do
17
+ optional :name, :string, 1
18
+ optional :spec, :message, 2, "google.cloud.orgpolicy.v2.PolicySpec"
19
+ optional :alternate, :message, 3, "google.cloud.orgpolicy.v2.AlternatePolicySpec"
20
+ end
21
+ add_message "google.cloud.orgpolicy.v2.AlternatePolicySpec" do
22
+ optional :launch, :string, 1
23
+ optional :spec, :message, 2, "google.cloud.orgpolicy.v2.PolicySpec"
24
+ end
25
+ add_message "google.cloud.orgpolicy.v2.PolicySpec" do
26
+ optional :etag, :string, 1
27
+ optional :update_time, :message, 2, "google.protobuf.Timestamp"
28
+ repeated :rules, :message, 3, "google.cloud.orgpolicy.v2.PolicySpec.PolicyRule"
29
+ optional :inherit_from_parent, :bool, 4
30
+ optional :reset, :bool, 5
31
+ end
32
+ add_message "google.cloud.orgpolicy.v2.PolicySpec.PolicyRule" do
33
+ optional :condition, :message, 5, "google.type.Expr"
34
+ oneof :kind do
35
+ optional :values, :message, 1, "google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues"
36
+ optional :allow_all, :bool, 2
37
+ optional :deny_all, :bool, 3
38
+ optional :enforce, :bool, 4
39
+ end
40
+ end
41
+ add_message "google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues" do
42
+ repeated :allowed_values, :string, 1
43
+ repeated :denied_values, :string, 2
44
+ end
45
+ add_message "google.cloud.orgpolicy.v2.ListConstraintsRequest" do
46
+ optional :parent, :string, 1
47
+ optional :page_size, :int32, 2
48
+ optional :page_token, :string, 3
49
+ end
50
+ add_message "google.cloud.orgpolicy.v2.ListConstraintsResponse" do
51
+ repeated :constraints, :message, 1, "google.cloud.orgpolicy.v2.Constraint"
52
+ optional :next_page_token, :string, 2
53
+ end
54
+ add_message "google.cloud.orgpolicy.v2.ListPoliciesRequest" do
55
+ optional :parent, :string, 1
56
+ optional :page_size, :int32, 2
57
+ optional :page_token, :string, 3
58
+ end
59
+ add_message "google.cloud.orgpolicy.v2.ListPoliciesResponse" do
60
+ repeated :policies, :message, 1, "google.cloud.orgpolicy.v2.Policy"
61
+ optional :next_page_token, :string, 2
62
+ end
63
+ add_message "google.cloud.orgpolicy.v2.GetPolicyRequest" do
64
+ optional :name, :string, 1
65
+ end
66
+ add_message "google.cloud.orgpolicy.v2.GetEffectivePolicyRequest" do
67
+ optional :name, :string, 1
68
+ end
69
+ add_message "google.cloud.orgpolicy.v2.CreatePolicyRequest" do
70
+ optional :parent, :string, 1
71
+ optional :policy, :message, 3, "google.cloud.orgpolicy.v2.Policy"
72
+ end
73
+ add_message "google.cloud.orgpolicy.v2.UpdatePolicyRequest" do
74
+ optional :policy, :message, 1, "google.cloud.orgpolicy.v2.Policy"
75
+ end
76
+ add_message "google.cloud.orgpolicy.v2.DeletePolicyRequest" do
77
+ optional :name, :string, 1
78
+ end
79
+ end
80
+ end
81
+
82
+ module Google
83
+ module Cloud
84
+ module OrgPolicy
85
+ module V2
86
+ Policy = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.Policy").msgclass
87
+ AlternatePolicySpec = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.AlternatePolicySpec").msgclass
88
+ PolicySpec = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.PolicySpec").msgclass
89
+ PolicySpec::PolicyRule = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.PolicySpec.PolicyRule").msgclass
90
+ PolicySpec::PolicyRule::StringValues = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.PolicySpec.PolicyRule.StringValues").msgclass
91
+ ListConstraintsRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.ListConstraintsRequest").msgclass
92
+ ListConstraintsResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.ListConstraintsResponse").msgclass
93
+ ListPoliciesRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.ListPoliciesRequest").msgclass
94
+ ListPoliciesResponse = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.ListPoliciesResponse").msgclass
95
+ GetPolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.GetPolicyRequest").msgclass
96
+ GetEffectivePolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.GetEffectivePolicyRequest").msgclass
97
+ CreatePolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.CreatePolicyRequest").msgclass
98
+ UpdatePolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.UpdatePolicyRequest").msgclass
99
+ DeletePolicyRequest = ::Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.orgpolicy.v2.DeletePolicyRequest").msgclass
100
+ end
101
+ end
102
+ end
103
+ end
@@ -0,0 +1,101 @@
1
+ # Generated by the protocol buffer compiler. DO NOT EDIT!
2
+ # Source: google/cloud/orgpolicy/v2/orgpolicy.proto for package 'Google.Cloud.OrgPolicy.V2'
3
+ # Original file comments:
4
+ # Copyright 2020 Google LLC
5
+ #
6
+ # Licensed under the Apache License, Version 2.0 (the "License");
7
+ # you may not use this file except in compliance with the License.
8
+ # You may obtain a copy of the License at
9
+ #
10
+ # http://www.apache.org/licenses/LICENSE-2.0
11
+ #
12
+ # Unless required by applicable law or agreed to in writing, software
13
+ # distributed under the License is distributed on an "AS IS" BASIS,
14
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
+ # See the License for the specific language governing permissions and
16
+ # limitations under the License.
17
+ #
18
+
19
+ require 'grpc'
20
+ require 'google/cloud/orgpolicy/v2/orgpolicy_pb'
21
+
22
+ module Google
23
+ module Cloud
24
+ module OrgPolicy
25
+ module V2
26
+ module OrgPolicy
27
+ # An interface for managing organization policies.
28
+ #
29
+ # The Cloud Org Policy service provides a simple mechanism for organizations to
30
+ # restrict the allowed configurations across their entire Cloud Resource
31
+ # hierarchy.
32
+ #
33
+ # You can use a `policy` to configure restrictions in Cloud resources. For
34
+ # example, you can enforce a `policy` that restricts which Google
35
+ # Cloud Platform APIs can be activated in a certain part of your resource
36
+ # hierarchy, or prevents serial port access to VM instances in a particular
37
+ # folder.
38
+ #
39
+ # `Policies` are inherited down through the resource hierarchy. A `policy`
40
+ # applied to a parent resource automatically applies to all its child resources
41
+ # unless overridden with a `policy` lower in the hierarchy.
42
+ #
43
+ # A `constraint` defines an aspect of a resource's configuration that can be
44
+ # controlled by an organization's policy administrator. `Policies` are a
45
+ # collection of `constraints` that defines their allowable configuration on a
46
+ # particular resource and its child resources.
47
+ class Service
48
+
49
+ include GRPC::GenericService
50
+
51
+ self.marshal_class_method = :encode
52
+ self.unmarshal_class_method = :decode
53
+ self.service_name = 'google.cloud.orgpolicy.v2.OrgPolicy'
54
+
55
+ # Lists `Constraints` that could be applied on the specified resource.
56
+ rpc :ListConstraints, ::Google::Cloud::OrgPolicy::V2::ListConstraintsRequest, ::Google::Cloud::OrgPolicy::V2::ListConstraintsResponse
57
+ # Retrieves all of the `Policies` that exist on a particular resource.
58
+ rpc :ListPolicies, ::Google::Cloud::OrgPolicy::V2::ListPoliciesRequest, ::Google::Cloud::OrgPolicy::V2::ListPoliciesResponse
59
+ # Gets a `Policy` on a resource.
60
+ #
61
+ # If no `Policy` is set on the resource, NOT_FOUND is returned. The
62
+ # `etag` value can be used with `UpdatePolicy()` to update a
63
+ # `Policy` during read-modify-write.
64
+ rpc :GetPolicy, ::Google::Cloud::OrgPolicy::V2::GetPolicyRequest, ::Google::Cloud::OrgPolicy::V2::Policy
65
+ # Gets the effective `Policy` on a resource. This is the result of merging
66
+ # `Policies` in the resource hierarchy and evaluating conditions. The
67
+ # returned `Policy` will not have an `etag` or `condition` set because it is
68
+ # a computed `Policy` across multiple resources.
69
+ # Subtrees of Resource Manager resource hierarchy with 'under:' prefix will
70
+ # not be expanded.
71
+ rpc :GetEffectivePolicy, ::Google::Cloud::OrgPolicy::V2::GetEffectivePolicyRequest, ::Google::Cloud::OrgPolicy::V2::Policy
72
+ # Creates a Policy.
73
+ #
74
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
75
+ # constraint does not exist.
76
+ # Returns a `google.rpc.Status` with `google.rpc.Code.ALREADY_EXISTS` if the
77
+ # policy already exists on the given Cloud resource.
78
+ rpc :CreatePolicy, ::Google::Cloud::OrgPolicy::V2::CreatePolicyRequest, ::Google::Cloud::OrgPolicy::V2::Policy
79
+ # Updates a Policy.
80
+ #
81
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
82
+ # constraint or the policy do not exist.
83
+ # Returns a `google.rpc.Status` with `google.rpc.Code.ABORTED` if the etag
84
+ # supplied in the request does not match the persisted etag of the policy
85
+ #
86
+ # Note: the supplied policy will perform a full overwrite of all
87
+ # fields.
88
+ rpc :UpdatePolicy, ::Google::Cloud::OrgPolicy::V2::UpdatePolicyRequest, ::Google::Cloud::OrgPolicy::V2::Policy
89
+ # Deletes a Policy.
90
+ #
91
+ # Returns a `google.rpc.Status` with `google.rpc.Code.NOT_FOUND` if the
92
+ # constraint or Org Policy does not exist.
93
+ rpc :DeletePolicy, ::Google::Cloud::OrgPolicy::V2::DeletePolicyRequest, ::Google::Protobuf::Empty
94
+ end
95
+
96
+ Stub = Service.rpc_stub_class
97
+ end
98
+ end
99
+ end
100
+ end
101
+ end