Google-RestApi
view release on metacpan or search on metacpan
lib/Google/RestApi/DriveApi3/File.pm view on Meta::CPAN
drive => HasApi,
id => StrMatch[qr/$qr_id/],
],
);
return bless $check->(@_), $class;
}
sub _uri_base { 'files' }
sub _parent_accessor { 'drive' }
sub copy {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
name => Str, { optional => 1 },
title => Str, { optional => 1 },
_extra_ => slurpy HashRef,
],
);
my $p = named_extra($check->(@_));
$p->{name} //= $p->{title};
$p->{content}->{name} = $p->{name} if defined $p->{name};
delete @$p{qw(name title)};
$p->{uri} = 'copy';
$p->{method} = 'post';
my $copy = $self->api(%$p);
DEBUG(sprintf("Copied file '%s' to '%s'", $self->file_id(), $copy->{id}));
return ref($self)->new(
drive => $self->drive(),
id => $copy->{id},
);
}
sub delete {
my $self = shift;
DEBUG(sprintf("Deleting file '%s'", $self->file_id()));
return $self->api(method => 'delete');
}
sub get {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
fields => Str, { optional => 1 },
params => HashRef, { default => {} },
],
);
my $p = $check->(@_);
my $params = $p->{params};
$params->{fields} = $p->{fields} if defined $p->{fields};
return $self->api(params => $params);
}
sub update {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
name => Str, { optional => 1 },
description => Str, { optional => 1 },
mime_type => Str, { optional => 1 },
add_parents => Str, { optional => 1 },
remove_parents => Str, { optional => 1 },
_extra_ => slurpy HashRef,
],
);
my $p = named_extra($check->(@_));
my %params;
$params{addParents} = delete $p->{add_parents} if defined $p->{add_parents};
$params{removeParents} = delete $p->{remove_parents} if defined $p->{remove_parents};
my %content;
$content{name} = delete $p->{name} if defined $p->{name};
$content{description} = delete $p->{description} if defined $p->{description};
$content{mimeType} = delete $p->{mime_type} if defined $p->{mime_type};
DEBUG(sprintf("Updating file '%s'", $self->file_id()));
return $self->api(
method => 'patch',
params => \%params,
content => \%content,
);
}
sub export {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
mime_type => Str,
],
);
my $p = $check->(@_);
DEBUG(sprintf("Exporting file '%s' as '%s'", $self->file_id(), $p->{mime_type}));
return $self->api(
uri => 'export',
params => { mimeType => $p->{mime_type} },
);
}
sub watch {
my $self = shift;
state $check = signature(
bless => !!0,
named => [
id => Str,
type => Str, { default => 'web_hook' },
address => Str,
expiration => Int, { optional => 1 },
_extra_ => slurpy HashRef,
],
);
( run in 2.026 seconds using v1.01-cache-2.11-cpan-5a3173703d6 )