package Google::Iam::V1::IamPolicy;

use strict;
use warnings;

our $VERSION = '0.04';

use Protobuf::Message;
use Protobuf::DescriptorPool;
use Protobuf::Internal qw(:all);
use MIME::Base64;

BEGIN {
    eval { require Google::Api::Annotations };
    eval { require Google::Api::Client };
    eval { require Google::Api::FieldBehavior };
    eval { require Google::Api::Resource };
    eval { require Google::Iam::V1::Options };
    eval { require Google::Iam::V1::Policy };
    eval { require Google::Protobuf::FieldMask };
    my $descriptor_b64 = <<'EOF';
[encoded data, 8529 characters]
EOF
    Protobuf::DescriptorPool->generated_pool->add_serialized_file(MIME::Base64::decode_base64($descriptor_b64));
}

# Message definitions

# === Message: Google::Iam::V1::IamPolicy::SetIamPolicyRequest ===
    # Fields for SetIamPolicyRequest
    # Field: resource Type: 9 ()
    # Field: policy Type: 11 (.google.iam.v1.Policy)
    # Field: update_mask Type: 11 (.google.protobuf.FieldMask)

=pod

=head1 NAME

Google::Iam::V1::IamPolicy::SetIamPolicyRequest - Compiled Protocol Buffers message class

=head1 SYNOPSIS

    use Google::Iam::V1::IamPolicy;

    my $msg = Google::Iam::V1::IamPolicy::SetIamPolicyRequest->new(
        resource => $value,
    );

=head1 FIELDS

=over 4

=item * B<resource>

Type: String

=item * B<policy>

Type: Message (.google.iam.v1.Policy)

=item * B<update_mask>

Type: Message (.google.protobuf.FieldMask)

=back

=cut

# === Message: Google::Iam::V1::IamPolicy::GetIamPolicyRequest ===
    # Fields for GetIamPolicyRequest
    # Field: resource Type: 9 ()
    # Field: options Type: 11 (.google.iam.v1.GetPolicyOptions)

=pod

=head1 NAME

Google::Iam::V1::IamPolicy::GetIamPolicyRequest - Compiled Protocol Buffers message class

=head1 SYNOPSIS

    use Google::Iam::V1::IamPolicy;

    my $msg = Google::Iam::V1::IamPolicy::GetIamPolicyRequest->new(
        resource => $value,
    );

=head1 FIELDS

=over 4

=item * B<resource>

Type: String

=item * B<options>

Type: Message (.google.iam.v1.GetPolicyOptions)

=back

=cut

# === Message: Google::Iam::V1::IamPolicy::TestIamPermissionsRequest ===
    # Fields for TestIamPermissionsRequest
    # Field: resource Type: 9 ()
    # Field: permissions Type: 9 ()

=pod

=head1 NAME

Google::Iam::V1::IamPolicy::TestIamPermissionsRequest - Compiled Protocol Buffers message class

=head1 SYNOPSIS

    use Google::Iam::V1::IamPolicy;

    my $msg = Google::Iam::V1::IamPolicy::TestIamPermissionsRequest->new(
        resource => $value,
    );

=head1 FIELDS

=over 4

=item * B<resource>

Type: String

=item * B<permissions>

Type: String

=back

=cut

# === Message: Google::Iam::V1::IamPolicy::TestIamPermissionsResponse ===
    # Fields for TestIamPermissionsResponse
    # Field: permissions Type: 9 ()

=pod

=head1 NAME

Google::Iam::V1::IamPolicy::TestIamPermissionsResponse - Compiled Protocol Buffers message class

=head1 SYNOPSIS

    use Google::Iam::V1::IamPolicy;

    my $msg = Google::Iam::V1::IamPolicy::TestIamPermissionsResponse->new(
        permissions => $value,
    );

=head1 FIELDS

=over 4

=item * B<permissions>

Type: String

=back

=cut

# === Service Client: Google::Iam::V1::IamPolicy::IamPolicyClient ===
package Google::Iam::V1::IamPolicy::IamPolicyClient;

=pod

=head1 NAME

Google::Iam::V1::IamPolicy::IamPolicyClient - Client stub representing the remote IAMPolicy service

=head1 DESCRIPTION

This class acts as a local client stub for the remote gRPC service.
It delegates call dispatching to an underlying L<Google::gRPC::Client>
instance, ensuring type-safe request parsing and response mapping.

=head1 CONFIGURATION AND ENVIRONMENT

=head2 target

The endpoint target address. Defaults to C<iam.googleapis.com:443>.

=head2 credentials

The authentication credentials provider. Defaults to application default credentials via L<Google::Auth>.

=cut

use Moo;
use Google::Auth;
use Google::gRPC::Client;

has credentials => ( is => 'ro', default => sub { Google::Auth->default() } );
has target      => ( is => 'ro', default => 'iam.googleapis.com:443' );

has _grpc_client => (
    is => 'ro',
    lazy => 1,
    builder => sub {
        my $self = shift;
        return Google::gRPC::Client->new(
            target     => $self->target,
            auth_token => $self->credentials->get_token(),
        );
    }
);

sub set_iam_policy {
    my ($self, $args) = @_;
    my $req = ref($args) eq 'HASH'
        ? Google::Iam::V1::IamPolicy::SetIamPolicyRequest->new($args)
        : $args;
    return $self->_grpc_client->call({
        service        => 'google.iam.v1.IAMPolicy',
        method         => 'SetIamPolicy',
        request        => $req,
        response_class => 'Google::Iam::V1::Policy::Policy',
    });
}

sub get_iam_policy {
    my ($self, $args) = @_;
    my $req = ref($args) eq 'HASH'
        ? Google::Iam::V1::IamPolicy::GetIamPolicyRequest->new($args)
        : $args;
    return $self->_grpc_client->call({
        service        => 'google.iam.v1.IAMPolicy',
        method         => 'GetIamPolicy',
        request        => $req,
        response_class => 'Google::Iam::V1::Policy::Policy',
    });
}

sub test_iam_permissions {
    my ($self, $args) = @_;
    my $req = ref($args) eq 'HASH'
        ? Google::Iam::V1::IamPolicy::TestIamPermissionsRequest->new($args)
        : $args;
    return $self->_grpc_client->call({
        service        => 'google.iam.v1.IAMPolicy',
        method         => 'TestIamPermissions',
        request        => $req,
        response_class => 'Google::Iam::V1::IamPolicy::TestIamPermissionsResponse',
    });
}

1;

__END__

=head1 NAME

Google::Iam::V1::IamPolicy - Protocol Buffers schema definition

=head1 DESCRIPTION

Auto-generated Protocol Buffers schema definition class.

=head1 LICENSE AND COPYRIGHT

Copyright (C) 2026 Google LLC

This program is released under the Apache 2.0 license.

=cut
