=begin comment

Agent Push Kit API

The complete Agent Push Kit REST API. Application event ingestion uses an organization key beginning with `apk_`. Authenticated user operations accept either an Agent Push Kit login JWT or an agent access token beginning with `apt_`.

The version of the OpenAPI document: 0.1.0

Generated by: https://openapi-generator.tech

=end comment

=cut

#
# NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
# Do not edit the class manually.
# Ref: https://openapi-generator.tech
#
package AgentPushKit::Client::AgentTokensApi;

require 5.6.0;
use strict;
use warnings;
use utf8;
use Exporter;
use Carp qw( croak );
use Log::Any qw($log);

use AgentPushKit::Client::ApiClient;

use base "Class::Data::Inheritable";

__PACKAGE__->mk_classdata('method_documentation' => {});

sub new {
    my $class = shift;
    my $api_client;

    if ($_[0] && ref $_[0] && ref $_[0] eq 'AgentPushKit::Client::ApiClient' ) {
        $api_client = $_[0];
    } else {
        $api_client = AgentPushKit::Client::ApiClient->new(@_);
    }

    bless { api_client => $api_client }, $class;

}


#
# call_mcp
#
# Connect through stateless MCP Streamable HTTP
#
# @param HASH[string,object] $request_body  (required)
{
    my $params = {
    'request_body' => {
        data_type => 'HASH[string,object]',
        description => '',
        required => '1',
    },
    };
    __PACKAGE__->method_documentation->{ 'call_mcp' } = {
        summary => 'Connect through stateless MCP Streamable HTTP',
        params => $params,
        returns => undef,
        };
}
# @return void
#
sub call_mcp {
    my ($self, %args) = @_;

    # verify the required parameter 'request_body' is set
    unless (exists $args{'request_body'}) {
      croak("Missing the required parameter 'request_body' when calling call_mcp");
    }

    # parse inputs
    my $_resource_path = '/mcp';

    my $_method = 'POST';
    my $query_params = {};
    my $header_params = {};
    my $form_params = {};

    # 'Accept' and 'Content-Type' header
    my $_header_accept = $self->{api_client}->select_header_accept('application/json');
    if ($_header_accept) {
        $header_params->{'Accept'} = $_header_accept;
    }
    $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');

    my $_body_data;
    # body params
    if ( exists $args{'request_body'}) {
        $_body_data = $args{'request_body'};
    }

    # authentication setting, if any
    my $auth_settings = [qw(AgentToken )];

    # make the API Call
    $self->{api_client}->call_api($_resource_path, $_method,
                                           $query_params, $form_params,
                                           $header_params, $_body_data, $auth_settings);
    return;
}

#
# create_agent_token
#
# Create a named non-expiring agent token
#
# @param CreateAgentTokenInput $create_agent_token_input  (required)
{
    my $params = {
    'create_agent_token_input' => {
        data_type => 'CreateAgentTokenInput',
        description => '',
        required => '1',
    },
    };
    __PACKAGE__->method_documentation->{ 'create_agent_token' } = {
        summary => 'Create a named non-expiring agent token',
        params => $params,
        returns => 'AgentTokenCreated',
        };
}
# @return AgentTokenCreated
#
sub create_agent_token {
    my ($self, %args) = @_;

    # verify the required parameter 'create_agent_token_input' is set
    unless (exists $args{'create_agent_token_input'}) {
      croak("Missing the required parameter 'create_agent_token_input' when calling create_agent_token");
    }

    # parse inputs
    my $_resource_path = '/agent-tokens';

    my $_method = 'POST';
    my $query_params = {};
    my $header_params = {};
    my $form_params = {};

    # 'Accept' and 'Content-Type' header
    my $_header_accept = $self->{api_client}->select_header_accept('application/json');
    if ($_header_accept) {
        $header_params->{'Accept'} = $_header_accept;
    }
    $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type('application/json');

    my $_body_data;
    # body params
    if ( exists $args{'create_agent_token_input'}) {
        $_body_data = $args{'create_agent_token_input'};
    }

    # authentication setting, if any
    my $auth_settings = [qw(UserOrAgent )];

    # make the API Call
    my $response = $self->{api_client}->call_api($_resource_path, $_method,
                                           $query_params, $form_params,
                                           $header_params, $_body_data, $auth_settings);
    if (!$response) {
        return;
    }
    my $_response_object = $self->{api_client}->deserialize('AgentTokenCreated', $response);
    return $_response_object;
}

#
# list_agent_tokens
#
# List agent access tokens without their secrets
#
{
    my $params = {
    };
    __PACKAGE__->method_documentation->{ 'list_agent_tokens' } = {
        summary => 'List agent access tokens without their secrets',
        params => $params,
        returns => 'ARRAY[AgentToken]',
        };
}
# @return ARRAY[AgentToken]
#
sub list_agent_tokens {
    my ($self, %args) = @_;

    # parse inputs
    my $_resource_path = '/agent-tokens';

    my $_method = 'GET';
    my $query_params = {};
    my $header_params = {};
    my $form_params = {};

    # 'Accept' and 'Content-Type' header
    my $_header_accept = $self->{api_client}->select_header_accept('application/json');
    if ($_header_accept) {
        $header_params->{'Accept'} = $_header_accept;
    }
    $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();

    my $_body_data;
    # authentication setting, if any
    my $auth_settings = [qw(UserOrAgent )];

    # make the API Call
    my $response = $self->{api_client}->call_api($_resource_path, $_method,
                                           $query_params, $form_params,
                                           $header_params, $_body_data, $auth_settings);
    if (!$response) {
        return;
    }
    my $_response_object = $self->{api_client}->deserialize('ARRAY[AgentToken]', $response);
    return $_response_object;
}

#
# revoke_agent_token
#
# Revoke one of the current user's agent tokens
#
# @param string $token_id  (required)
{
    my $params = {
    'token_id' => {
        data_type => 'string',
        description => '',
        required => '1',
    },
    };
    __PACKAGE__->method_documentation->{ 'revoke_agent_token' } = {
        summary => 'Revoke one of the current user&#39;s agent tokens',
        params => $params,
        returns => 'RevokedResponse',
        };
}
# @return RevokedResponse
#
sub revoke_agent_token {
    my ($self, %args) = @_;

    # verify the required parameter 'token_id' is set
    unless (exists $args{'token_id'}) {
      croak("Missing the required parameter 'token_id' when calling revoke_agent_token");
    }

    # parse inputs
    my $_resource_path = '/agent-tokens/{tokenId}';

    my $_method = 'DELETE';
    my $query_params = {};
    my $header_params = {};
    my $form_params = {};

    # 'Accept' and 'Content-Type' header
    my $_header_accept = $self->{api_client}->select_header_accept('application/json');
    if ($_header_accept) {
        $header_params->{'Accept'} = $_header_accept;
    }
    $header_params->{'Content-Type'} = $self->{api_client}->select_header_content_type();

    # path params
    if ( exists $args{'token_id'}) {
        my $_base_variable = "{" . "tokenId" . "}";
        my $_base_value = $self->{api_client}->to_path_value($args{'token_id'});
        $_resource_path =~ s/$_base_variable/$_base_value/g;
    }

    my $_body_data;
    # authentication setting, if any
    my $auth_settings = [qw(UserOrAgent )];

    # make the API Call
    my $response = $self->{api_client}->call_api($_resource_path, $_method,
                                           $query_params, $form_params,
                                           $header_params, $_body_data, $auth_settings);
    if (!$response) {
        return;
    }
    my $_response_object = $self->{api_client}->deserialize('RevokedResponse', $response);
    return $_response_object;
}

1;
