package Google::Cloud::Compute::V1::ProjectsClient;

use strict;
use warnings;
use Moo;
use Google::gRPC::Client;
use Google::Cloud::REST::Client;
use Google::Auth;
use Carp qw(croak);

use Protobuf;
use Google::Api::Common;
use Google::Cloud::Compute::V1::Compute;

our $VERSION = '0.02';

has credentials => ( is => 'ro', required => 0 );
has transport   => ( is => 'rw' );

sub BUILD {
    my ($self) = @_;

    # Resolve credentials: use passed credentials object if it implements get_token, or default to ADC
    my $auth = $self->credentials;
    if (!$auth || !eval { $auth->can('get_token') }) {
        $auth = Google::Auth->default();
    }
    my $token = $auth->get_token();

    my $target = 'localhost:50051';
    my $t = $self->transport || 'grpc';

    if (ref($t) && eval { $t->can('call') }) {
        # Already a transport object
    } elsif (lc($t) eq 'rest') {
        my $client = Google::Cloud::REST::Client->new(
            target     => $target,
            auth_token => $token,
        );
        $self->transport($client);
    } else {
        # Default high-performance HTTP/2 gRPC client
        my $client = Google::gRPC::Client->new(
            target     => $target,
            auth_token => $token,
        );
        $self->transport($client);
    }
}

sub disable_xpn_host {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::DisableXpnHostProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'DisableXpnHost',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub disable_xpn_resource {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::DisableXpnResourceProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'DisableXpnResource',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub enable_xpn_host {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::EnableXpnHostProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'EnableXpnHost',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub enable_xpn_resource {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::EnableXpnResourceProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'EnableXpnResource',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub get {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::GetProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Project';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'Get',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub get_xpn_host {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::GetXpnHostProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Project';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'GetXpnHost',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub get_xpn_resources {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::GetXpnResourcesProjectsRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::ProjectsGetXpnResources';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'GetXpnResources',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub list_xpn_hosts {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::ListXpnHostsProjectsRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::XpnHostList';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'ListXpnHosts',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub move_disk {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::MoveDiskProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'MoveDisk',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub move_instance {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::MoveInstanceProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'MoveInstance',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub set_cloud_armor_tier {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::SetCloudArmorTierProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'SetCloudArmorTier',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub set_common_instance_metadata {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::SetCommonInstanceMetadataProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'SetCommonInstanceMetadata',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub set_default_network_tier {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::SetDefaultNetworkTierProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'SetDefaultNetworkTier',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}

sub set_usage_export_bucket {
    my ($self, %params) = @_;

    my $request_class = 'Google::Cloud::Compute::V1::Compute::SetUsageExportBucketProjectRequest';
    my $request = eval { $request_class->new(\%params) } || eval { $request_class->new(%params) } || ($request_class->can('encode') ? $request_class->encode(\%params) : \%params);

    my $response_class = 'Google::Cloud::Compute::V1::Compute::Operation';
    my $response = $self->transport->call({
        service        => 'google.cloud.compute.v1.Projects',
        method         => 'SetUsageExportBucket',
        request        => $request,
        response_class => $response_class,
    });

    return $response;
}
1; # End of Google::Cloud::Compute::V1::ProjectsClient

__END__

=head1 NAME

Google::Cloud::Compute::V1::ProjectsClient - Client library for Google Cloud Services

=head1 SYNOPSIS

    use Google::Cloud::Compute::V1::ProjectsClient;
    use Google::Auth;

    my $auth = Google::Auth->default();

    # 1. High-performance gRPC Transport (Default)
    my $grpc_client = Google::Cloud::Compute::V1::ProjectsClient->new(
        credentials => $auth,
        transport   => 'grpc', # Optional: 'grpc' is default
    );

    # 2. HTTP/REST Transport
    my $rest_client = Google::Cloud::Compute::V1::ProjectsClient->new(
        credentials => $auth,
        transport   => 'rest',
    );

    # Execute service methods
    my $res = $grpc_client->some_method( %params );

=head1 DESCRIPTION

C<Google::Cloud::Compute::V1::ProjectsClient> is an auto-generated client library for Google Cloud Services.

It provides a unified client interface supporting both high-performance HTTP/2 gRPC and HTTP/REST transports, with automatic Google Cloud Application Default Credentials (ADC) resolution and typed Protocol Buffers message handling.

=head1 SOURCE

Generated from the following Protocol Buffers schemas:

=over 4

=item * C<google/cloud/compute/v1/compute.proto>



=back

=head1 CONSTRUCTOR

=head2 new

    my $client = Google::Cloud::Compute::V1::ProjectsClient->new(
        credentials => $auth,   # Optional: Google::Auth object (defaults to ADC)
        transport   => 'grpc', # Optional: 'grpc' (default) or 'rest'
    );

=head1 ATTRIBUTES

=head2 credentials

Returns or accepts the L<Google::Auth> credentials object.

=head2 transport

Returns or accepts the active transport object (L<Google::gRPC::Client> or L<Google::Cloud::REST::Client>).

=head1 METHODS

=head2 METHODS

The following RPC methods are available in this client:

=over 4

=item * B<disable_xpn_host>

Calls the RPC method C<DisableXpnHost> on the service. Takes a hash of parameters representing the request.

=item * B<disable_xpn_resource>

Calls the RPC method C<DisableXpnResource> on the service. Takes a hash of parameters representing the request.

=item * B<enable_xpn_host>

Calls the RPC method C<EnableXpnHost> on the service. Takes a hash of parameters representing the request.

=item * B<enable_xpn_resource>

Calls the RPC method C<EnableXpnResource> on the service. Takes a hash of parameters representing the request.

=item * B<get>

Calls the RPC method C<Get> on the service. Takes a hash of parameters representing the request.

=item * B<get_xpn_host>

Calls the RPC method C<GetXpnHost> on the service. Takes a hash of parameters representing the request.

=item * B<get_xpn_resources>

Calls the RPC method C<GetXpnResources> on the service. Takes a hash of parameters representing the request.

=item * B<list_xpn_hosts>

Calls the RPC method C<ListXpnHosts> on the service. Takes a hash of parameters representing the request.

=item * B<move_disk>

Calls the RPC method C<MoveDisk> on the service. Takes a hash of parameters representing the request.

=item * B<move_instance>

Calls the RPC method C<MoveInstance> on the service. Takes a hash of parameters representing the request.

=item * B<set_cloud_armor_tier>

Calls the RPC method C<SetCloudArmorTier> on the service. Takes a hash of parameters representing the request.

=item * B<set_common_instance_metadata>

Calls the RPC method C<SetCommonInstanceMetadata> on the service. Takes a hash of parameters representing the request.

=item * B<set_default_network_tier>

Calls the RPC method C<SetDefaultNetworkTier> on the service. Takes a hash of parameters representing the request.

=item * B<set_usage_export_bucket>

Calls the RPC method C<SetUsageExportBucket> on the service. Takes a hash of parameters representing the request.

=back



=head1 LICENSE AND COPYRIGHT

Copyright (C) 2026 Google LLC

This program is released under the Apache 2.0 license.

=cut
