text:
package Bio::P3::Workspace::WorkspaceClient;

use POSIX;
use strict;
use Data::Dumper;
use URI;

my $get_time = sub { time, 0 };
eval {
    require Time::HiRes;
    $get_time = sub { Time::HiRes::gettimeofday() };
};

use P3AuthToken;

=head1 NAME

Bio::P3::Workspace::WorkspaceClient

=head1 DESCRIPTION

=cut

sub new
{
    my($class, $url, @args) = @_;

    if (!defined($url))
    {
	$url = 'https://p3.theseed.org/services/Workspace';
    }

    my $self = {
	client => Bio::P3::Workspace::WorkspaceClient::RpcClient->new,
	url => $url,
	headers => [],
    };

    chomp($self->{hostname} = `hostname`);
    $self->{hostname} ||= 'unknown-host';

    #
    # Set up for propagating KBRPC_TAG and KBRPC_METADATA environment variables through
    # to invoked services. If these values are not set, we create a new tag
    # and a metadata field with basic information about the invoking script.
    #
    if ($ENV{KBRPC_TAG})
    {
	$self->{kbrpc_tag} = $ENV{KBRPC_TAG};
    }
    else
    {
	my ($t, $us) = &$get_time();
	$us = sprintf("%06d", $us);
	my $ts = strftime("%Y-%m-%dT%H:%M:%S.${us}Z", gmtime $t);
	$self->{kbrpc_tag} = "C:$0:$self->{hostname}:$$:$ts";
    }
    push(@{$self->{headers}}, 'Kbrpc-Tag', $self->{kbrpc_tag});

    if ($ENV{KBRPC_METADATA})
    {
	$self->{kbrpc_metadata} = $ENV{KBRPC_METADATA};
	push(@{$self->{headers}}, 'Kbrpc-Metadata', $self->{kbrpc_metadata});
    }

    if ($ENV{KBRPC_ERROR_DEST})
    {
	$self->{kbrpc_error_dest} = $ENV{KBRPC_ERROR_DEST};
	push(@{$self->{headers}}, 'Kbrpc-Errordest', $self->{kbrpc_error_dest});
    }

    #
    # This module requires authentication.
    #
    # We create an auth token, passing through the arguments that we were (hopefully) given.

    {
	my $token = P3AuthToken->new(@args);

	if (my $token_str = $token->token())
	{
	    $self->{token} = $token_str;
	    $self->{client}->{token} = $token_str;
	}
    }

    my $ua = $self->{client}->ua;
    my $timeout = $ENV{CDMI_TIMEOUT} || (30 * 60);
    $ua->timeout($timeout);
    $ua->agent("Bio::P3::Workspace::WorkspaceClient UserAgent");
    bless $self, $class;
    return $self;
}

=head2 create

  $output = $obj->create($input)

=over 4

=item Parameter and return types

=begin html

$input is a create_params
$output is a reference to a list where each element is an ObjectMeta
create_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a reference to a list containing 5 items:
	0: a FullObjectPath
	1: an ObjectType
	2: an UserMetadata
	3: an ObjectData
	4: (creation_time) a Timestamp

	permission has a value which is a WorkspacePerm
	createUploadNodes has a value which is a bool
	downloadLinks has a value which is a bool
	overwrite has a value which is a bool
	adminmode has a value which is a bool
	setowner has a value which is a string
FullObjectPath is a string
ObjectType is a string
UserMetadata is a reference to a hash where the key is a string and the value is a string
ObjectData is a string
Timestamp is a string
WorkspacePerm is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectID is a string
Username is a string
ObjectSize is an int
AutoMetadata is a reference to a hash where the key is a string and the value is a string

=end html

=begin text

$input is a create_params
$output is a reference to a list where each element is an ObjectMeta
create_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a reference to a list containing 5 items:
	0: a FullObjectPath
	1: an ObjectType
	2: an UserMetadata
	3: an ObjectData
	4: (creation_time) a Timestamp

	permission has a value which is a WorkspacePerm
	createUploadNodes has a value which is a bool
	downloadLinks has a value which is a bool
	overwrite has a value which is a bool
	adminmode has a value which is a bool
	setowner has a value which is a string
FullObjectPath is a string
ObjectType is a string
UserMetadata is a reference to a hash where the key is a string and the value is a string
ObjectData is a string
Timestamp is a string
WorkspacePerm is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectID is a string
Username is a string
ObjectSize is an int
AutoMetadata is a reference to a hash where the key is a string and the value is a string

=end text

=item Description

=back

=cut

sub create
{
    my($self, @args) = @_;

# Authentication: required

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function create (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to create:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.create",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking create:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method create: " .  $self->{client}->status_line;
    }
}

=head2 update_metadata

  $output = $obj->update_metadata($input)

=over 4

=item Parameter and return types

=begin html

$input is an update_metadata_params
$output is a reference to a list where each element is an ObjectMeta
update_metadata_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a reference to a list containing 4 items:
	0: a FullObjectPath
	1: an UserMetadata
	2: an ObjectType
	3: (creation_time) a Timestamp

	autometadata has a value which is a bool
	append has a value which is a bool
	adminmode has a value which is a bool
FullObjectPath is a string
UserMetadata is a reference to a hash where the key is a string and the value is a string
ObjectType is a string
Timestamp is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectID is a string
Username is a string
ObjectSize is an int
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end html

=begin text

$input is an update_metadata_params
$output is a reference to a list where each element is an ObjectMeta
update_metadata_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a reference to a list containing 4 items:
	0: a FullObjectPath
	1: an UserMetadata
	2: an ObjectType
	3: (creation_time) a Timestamp

	autometadata has a value which is a bool
	append has a value which is a bool
	adminmode has a value which is a bool
FullObjectPath is a string
UserMetadata is a reference to a hash where the key is a string and the value is a string
ObjectType is a string
Timestamp is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectID is a string
Username is a string
ObjectSize is an int
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end text

=item Description

=back

=cut

sub update_metadata
{
    my($self, @args) = @_;

# Authentication: required

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function update_metadata (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to update_metadata:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.update_metadata",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking update_metadata:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method update_metadata: " .  $self->{client}->status_line;
    }
}

=head2 get

  $output = $obj->get($input)

=over 4

=item Parameter and return types

=begin html

$input is a get_params
$output is a reference to a list where each element is a reference to a list containing 2 items:
	0: an ObjectMeta
	1: an ObjectData
get_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	metadata_only has a value which is a bool
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string
ObjectData is a string

=end html

=begin text

$input is a get_params
$output is a reference to a list where each element is a reference to a list containing 2 items:
	0: an ObjectMeta
	1: an ObjectData
get_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	metadata_only has a value which is a bool
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string
ObjectData is a string

=end text

=item Description

=back

=cut

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

# Authentication: optional

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function get (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to get:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.get",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking get:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method get: " .  $self->{client}->status_line;
    }
}

=head2 update_auto_meta

  $output = $obj->update_auto_meta($input)

=over 4

=item Parameter and return types

=begin html

$input is an update_auto_meta_params
$output is a reference to a list where each element is an ObjectMeta
update_auto_meta_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end html

=begin text

$input is an update_auto_meta_params
$output is a reference to a list where each element is an ObjectMeta
update_auto_meta_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end text

=item Description

=back

=cut

sub update_auto_meta
{
    my($self, @args) = @_;

# Authentication: required

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function update_auto_meta (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to update_auto_meta:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.update_auto_meta",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking update_auto_meta:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method update_auto_meta: " .  $self->{client}->status_line;
    }
}

=head2 get_download_url

  $urls = $obj->get_download_url($input)

=over 4

=item Parameter and return types

=begin html

$input is a get_download_url_params
$urls is a reference to a list where each element is a string
get_download_url_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
FullObjectPath is a string

=end html

=begin text

$input is a get_download_url_params
$urls is a reference to a list where each element is a string
get_download_url_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
FullObjectPath is a string

=end text

=item Description

=back

=cut

sub get_download_url
{
    my($self, @args) = @_;

# Authentication: optional

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function get_download_url (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to get_download_url:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.get_download_url",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking get_download_url:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method get_download_url: " .  $self->{client}->status_line;
    }
}

=head2 get_archive_url

  $url, $file_count, $total_size = $obj->get_archive_url($input)

=over 4

=item Parameter and return types

=begin html

$input is a get_archive_url_params
$url is a string
$file_count is an int
$total_size is an int
get_archive_url_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	recursive has a value which is a bool
	archive_name has a value which is a string
	archive_type has a value which is a string
FullObjectPath is a string
bool is an int

=end html

=begin text

$input is a get_archive_url_params
$url is a string
$file_count is an int
$total_size is an int
get_archive_url_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	recursive has a value which is a bool
	archive_name has a value which is a string
	archive_type has a value which is a string
FullObjectPath is a string
bool is an int

=end text

=item Description

=back

=cut

sub get_archive_url
{
    my($self, @args) = @_;

# Authentication: optional

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function get_archive_url (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to get_archive_url:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.get_archive_url",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking get_archive_url:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method get_archive_url: " .  $self->{client}->status_line;
    }
}

=head2 ls

  $output = $obj->ls($input)

=over 4

=item Parameter and return types

=begin html

$input is a list_params
$output is a reference to a hash where the key is a FullObjectPath and the value is a reference to a list where each element is an ObjectMeta
list_params is a reference to a hash where the following keys are defined:
	paths has a value which is a reference to a list where each element is a FullObjectPath
	excludeDirectories has a value which is a bool
	excludeObjects has a value which is a bool
	recursive has a value which is a bool
	fullHierachicalOutput has a value which is a bool
	query has a value which is a reference to a hash where the key is a string and the value is a reference to a list where each element is a string
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end html

=begin text

$input is a list_params
$output is a reference to a hash where the key is a FullObjectPath and the value is a reference to a list where each element is an ObjectMeta
list_params is a reference to a hash where the following keys are defined:
	paths has a value which is a reference to a list where each element is a FullObjectPath
	excludeDirectories has a value which is a bool
	excludeObjects has a value which is a bool
	recursive has a value which is a bool
	fullHierachicalOutput has a value which is a bool
	query has a value which is a reference to a hash where the key is a string and the value is a reference to a list where each element is a string
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end text

=item Description

=back

=cut

sub ls
{
    my($self, @args) = @_;

# Authentication: optional

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function ls (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to ls:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.ls",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking ls:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method ls: " .  $self->{client}->status_line;
    }
}

=head2 copy

  $output = $obj->copy($input)

=over 4

=item Parameter and return types

=begin html

$input is a copy_params
$output is a reference to a list where each element is an ObjectMeta
copy_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a reference to a list containing 2 items:
	0: (source) a FullObjectPath
	1: (destination) a FullObjectPath

	overwrite has a value which is a bool
	recursive has a value which is a bool
	move has a value which is a bool
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end html

=begin text

$input is a copy_params
$output is a reference to a list where each element is an ObjectMeta
copy_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a reference to a list containing 2 items:
	0: (source) a FullObjectPath
	1: (destination) a FullObjectPath

	overwrite has a value which is a bool
	recursive has a value which is a bool
	move has a value which is a bool
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end text

=item Description

=back

=cut

sub copy
{
    my($self, @args) = @_;

# Authentication: required

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function copy (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to copy:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.copy",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking copy:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method copy: " .  $self->{client}->status_line;
    }
}

=head2 delete

  $output = $obj->delete($input)

=over 4

=item Parameter and return types

=begin html

$input is a delete_params
$output is a reference to a list where each element is an ObjectMeta
delete_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	deleteDirectories has a value which is a bool
	force has a value which is a bool
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end html

=begin text

$input is a delete_params
$output is a reference to a list where each element is an ObjectMeta
delete_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	deleteDirectories has a value which is a bool
	force has a value which is a bool
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
ObjectMeta is a reference to a list containing 13 items:
	0: an ObjectName
	1: an ObjectType
	2: a FullObjectPath
	3: (creation_time) a Timestamp
	4: an ObjectID
	5: (object_owner) an Username
	6: an ObjectSize
	7: an UserMetadata
	8: an AutoMetadata
	9: (user_permission) a WorkspacePerm
	10: (global_permission) a WorkspacePerm
	11: (shockurl) a string
	12: (error) a string
ObjectName is a string
ObjectType is a string
Timestamp is a string
ObjectID is a string
Username is a string
ObjectSize is an int
UserMetadata is a reference to a hash where the key is a string and the value is a string
AutoMetadata is a reference to a hash where the key is a string and the value is a string
WorkspacePerm is a string

=end text

=item Description

=back

=cut

sub delete
{
    my($self, @args) = @_;

# Authentication: required

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function delete (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to delete:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.delete",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking delete:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method delete: " .  $self->{client}->status_line;
    }
}

=head2 set_permissions

  $output = $obj->set_permissions($input)

=over 4

=item Parameter and return types

=begin html

$input is a set_permissions_params
$output is a reference to a list where each element is a reference to a list containing 2 items:
	0: an Username
	1: a WorkspacePerm
set_permissions_params is a reference to a hash where the following keys are defined:
	path has a value which is a FullObjectPath
	permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
	0: an Username
	1: a WorkspacePerm

	new_global_permission has a value which is a WorkspacePerm
	adminmode has a value which is a bool
FullObjectPath is a string
Username is a string
WorkspacePerm is a string
bool is an int

=end html

=begin text

$input is a set_permissions_params
$output is a reference to a list where each element is a reference to a list containing 2 items:
	0: an Username
	1: a WorkspacePerm
set_permissions_params is a reference to a hash where the following keys are defined:
	path has a value which is a FullObjectPath
	permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
	0: an Username
	1: a WorkspacePerm

	new_global_permission has a value which is a WorkspacePerm
	adminmode has a value which is a bool
FullObjectPath is a string
Username is a string
WorkspacePerm is a string
bool is an int

=end text

=item Description

=back

=cut

sub set_permissions
{
    my($self, @args) = @_;

# Authentication: required

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function set_permissions (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to set_permissions:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.set_permissions",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking set_permissions:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method set_permissions: " .  $self->{client}->status_line;
    }
}

=head2 list_permissions

  $output = $obj->list_permissions($input)

=over 4

=item Parameter and return types

=begin html

$input is a list_permissions_params
$output is a reference to a hash where the key is a string and the value is a reference to a list where each element is a reference to a list containing 2 items:
	0: an Username
	1: a WorkspacePerm
list_permissions_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
Username is a string
WorkspacePerm is a string

=end html

=begin text

$input is a list_permissions_params
$output is a reference to a hash where the key is a string and the value is a reference to a list where each element is a reference to a list containing 2 items:
	0: an Username
	1: a WorkspacePerm
list_permissions_params is a reference to a hash where the following keys are defined:
	objects has a value which is a reference to a list where each element is a FullObjectPath
	adminmode has a value which is a bool
FullObjectPath is a string
bool is an int
Username is a string
WorkspacePerm is a string

=end text

=item Description

=back

=cut

sub list_permissions
{
    my($self, @args) = @_;

# Authentication: optional

    if ((my $n = @args) != 1)
    {
        die "Invalid argument count for function list_permissions (received $n, expecting 1)";
    }
    {
	my($input) = @args;

	my @_bad_arguments;
        (ref($input) eq 'HASH') or push(@_bad_arguments, "Invalid type for argument 1 \"input\" (value was \"$input\")");
        if (@_bad_arguments) {
	    my $msg = "Invalid arguments passed to list_permissions:\n" . join("", map { "\t$_\n" } @_bad_arguments);
	    die $msg;
	}
    }

    my $result = $self->{client}->call($self->{url}, $self->{headers}, {
	method => "Workspace.list_permissions",
	params => \@args,
    });
    if ($result) {
	if ($result->{error}) {
	    my $msg = $result->{error}->{error} || $result->{error}->{message};
	    $msg =  $self->{client}->json->encode($msg) if ref($msg);
	    die "Error $result->{error}->{code} invoking list_permissions:\n$msg\n";
	} else {
	    return wantarray ? @{$result->{result}} : $result->{result}->[0];
	}
    } else {
	die "Error invoking method list_permissions: " .  $self->{client}->status_line;
    }
}

=head1 TYPES

=head2 WorkspacePerm

=over 4

=item Description

User permission in worksace (e.g. w - write, r - read, a - admin, n - none)

=item Definition

=begin html

a string

=end html

=begin text

a string

=end text

=back

=head2 Username

=over 4

=item Description

Login name for user

=item Definition

=begin html

a string

=end html

=begin text

a string

=end text

=back

=head2 bool

=over 4

=item Definition

=begin html

an int

=end html

=begin text

an int

=end text

=back

=head2 Timestamp

=over 4

=item Description

Indication of a system time

=item Definition

=begin html

a string

=end html

=begin text

a string

=end text

=back

=head2 ObjectName

=over 4

=item Description

Name assigned to an object saved to a workspace

=item Definition

=begin html

a string

=end html

=begin text

a string

=end text

=back

=head2 ObjectID

=over 4

=item Description

Unique UUID assigned to every object in a workspace on save - IDs never reused

=item Definition

=begin html

a string

=end html

=begin text

a string

=end text

=back

=head2 ObjectType

=over 4

=item Description

Specified type of an object (e.g. Genome)

=item Definition

=begin html

a string

=end html

=begin text

a string

=end text

=back

=head2 ObjectSize

=over 4

=item Description

Size of the object

=item Definition

=begin html

an int

=end html

=begin text

an int

=end text

=back

=head2 ObjectData

=over 4

=item Description

Generic type containing object data

=item Definition

=begin html

a string

=end html

=begin text

a string

=end text

=back

=head2 FullObjectPath

=over 4

=item Description

Path to any object in workspace database

=item Definition

=begin html

a string

=end html

=begin text

a string

=end text

=back

=head2 UserMetadata

=over 4

=item Description

This is a key value hash of user-specified metadata

=item Definition

=begin html

a reference to a hash where the key is a string and the value is a string

=end html

=begin text

a reference to a hash where the key is a string and the value is a string

=end text

=back

=head2 AutoMetadata

=over 4

=item Description

This is a key value hash of automated metadata populated based on object type

=item Definition

=begin html

a reference to a hash where the key is a string and the value is a string

=end html

=begin text

a reference to a hash where the key is a string and the value is a string

=end text

=back

=head2 ObjectMeta

=over 4

=item Description

ObjectMeta: tuple containing information about an object in the workspace

       ObjectName - name selected for object in workspace
       ObjectType - type of the object in the workspace
       FullObjectPath - full path to object in workspace, including object name
       Timestamp creation_time - time when the object was created
       ObjectID - a globally unique UUID assigned to every object that will never change even if the object is moved
       Username object_owner - name of object owner
       ObjectSize - size of the object in bytes or if object is directory, the number of objects in directory
       UserMetadata - arbitrary user metadata associated with object
       AutoMetadata - automatically populated metadata generated from object data in automated way
       WorkspacePerm user_permission - permissions for the authenticated user of this workspace.
       WorkspacePerm global_permission - whether this workspace is globally readable.
       string shockurl - shockurl included if object is a reference to a shock node
       string error - set if there was an error on the operation on this object.

=item Definition

=begin html

a reference to a list containing 13 items:
0: an ObjectName
1: an ObjectType
2: a FullObjectPath
3: (creation_time) a Timestamp
4: an ObjectID
5: (object_owner) an Username
6: an ObjectSize
7: an UserMetadata
8: an AutoMetadata
9: (user_permission) a WorkspacePerm
10: (global_permission) a WorkspacePerm
11: (shockurl) a string
12: (error) a string

=end html

=begin text

a reference to a list containing 13 items:
0: an ObjectName
1: an ObjectType
2: a FullObjectPath
3: (creation_time) a Timestamp
4: an ObjectID
5: (object_owner) an Username
6: an ObjectSize
7: an UserMetadata
8: an AutoMetadata
9: (user_permission) a WorkspacePerm
10: (global_permission) a WorkspacePerm
11: (shockurl) a string
12: (error) a string

=end text

=back

=head2 create_params

=over 4

=item Description

********* DATA LOAD FUNCTIONS *******************

=item Definition

=begin html

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a reference to a list containing 5 items:
0: a FullObjectPath
1: an ObjectType
2: an UserMetadata
3: an ObjectData
4: (creation_time) a Timestamp

permission has a value which is a WorkspacePerm
createUploadNodes has a value which is a bool
downloadLinks has a value which is a bool
overwrite has a value which is a bool
adminmode has a value which is a bool
setowner has a value which is a string

=end html

=begin text

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a reference to a list containing 5 items:
0: a FullObjectPath
1: an ObjectType
2: an UserMetadata
3: an ObjectData
4: (creation_time) a Timestamp

permission has a value which is a WorkspacePerm
createUploadNodes has a value which is a bool
downloadLinks has a value which is a bool
overwrite has a value which is a bool
adminmode has a value which is a bool
setowner has a value which is a string

=end text

=back

=head2 update_metadata_params

=over 4

=item Description

"update_metadata" command
        Description:
        This function permits the alteration of metadata associated with an object

        Parameters:
        list<tuple<FullObjectPath,UserMetadata>> objects - list of object paths and new metadatas
        bool autometadata - this flag can only be used by the workspace itself
        bool adminmode - run this command as an admin, meaning you can set permissions on anything anywhere

=item Definition

=begin html

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a reference to a list containing 4 items:
0: a FullObjectPath
1: an UserMetadata
2: an ObjectType
3: (creation_time) a Timestamp

autometadata has a value which is a bool
append has a value which is a bool
adminmode has a value which is a bool

=end html

=begin text

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a reference to a list containing 4 items:
0: a FullObjectPath
1: an UserMetadata
2: an ObjectType
3: (creation_time) a Timestamp

autometadata has a value which is a bool
append has a value which is a bool
adminmode has a value which is a bool

=end text

=back

=head2 get_params

=over 4

=item Description

********* DATA RETRIEVAL FUNCTIONS *******************

=item Definition

=begin html

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
metadata_only has a value which is a bool
adminmode has a value which is a bool

=end html

=begin text

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
metadata_only has a value which is a bool
adminmode has a value which is a bool

=end text

=back

=head2 update_auto_meta_params

=over 4

=item Description

"update_shock_meta" command
        Description:
        Call this function to trigger an immediate update of workspace metadata for an object,
        which should typically take place once the upload of a file into shock has completed

        Parameters:
        list<FullObjectPath> objects - list of full paths to objects for which shock nodes should be updated

=item Definition

=begin html

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
adminmode has a value which is a bool

=end html

=begin text

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
adminmode has a value which is a bool

=end text

=back

=head2 get_download_url_params

=over 4

=item Description

"get_download_url" command
        Description:
        This function returns a URL from which an object may be downloaded
        without any other authentication required. The download URL will only be
        valid for a limited amount of time.

        Parameters:
        list<FullObjectPath> objects - list of full paths to objects for which URLs are to be constructed

=item Definition

=begin html

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath

=end html

=begin text

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath

=end text

=back

=head2 get_archive_url_params

=over 4

=item Description

"get_archive_url" command
        Description:
        This function returns a URL from which an archive of the given
        objects may be downloaded. The download URL will only be valid for a limited
        amount of time.

        Parameters:
        list<FullObjectPath> objects - list of full paths to objects to be archived
        bool recursive - if true, recurse into folders
        string archive_name - name to be given to the archive file
        string archive_type - type of archive, one of "zip", "tar.gz", "tar.bz2"

=item Definition

=begin html

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
recursive has a value which is a bool
archive_name has a value which is a string
archive_type has a value which is a string

=end html

=begin text

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
recursive has a value which is a bool
archive_name has a value which is a string
archive_type has a value which is a string

=end text

=back

=head2 list_params

=over 4

=item Description

"list" command
        Description:
        This function retrieves a list of all objects and directories below the specified paths with optional ability to filter by search

        Parameters:
        list<FullObjectPath> paths - list of full paths for which subobjects should be listed
        bool excludeDirectories - don't return directories with output (optional; default = "0")
        bool excludeObjects - don't return objects with output (optional; default = "0")
        bool recursive - recursively list contents of all subdirectories; will not work above top level directory (optional; default "0")
        bool fullHierachicalOutput - return a hash of all directories with contents of each; only useful with "recursive" (optional; default = "0")
        mapping<string,string> query - filter output object lists by specified key/value query (optional; default = {})
        bool adminmode - run this command as an admin, meaning you can see anything anywhere

=item Definition

=begin html

a reference to a hash where the following keys are defined:
paths has a value which is a reference to a list where each element is a FullObjectPath
excludeDirectories has a value which is a bool
excludeObjects has a value which is a bool
recursive has a value which is a bool
fullHierachicalOutput has a value which is a bool
query has a value which is a reference to a hash where the key is a string and the value is a reference to a list where each element is a string
adminmode has a value which is a bool

=end html

=begin text

a reference to a hash where the following keys are defined:
paths has a value which is a reference to a list where each element is a FullObjectPath
excludeDirectories has a value which is a bool
excludeObjects has a value which is a bool
recursive has a value which is a bool
fullHierachicalOutput has a value which is a bool
query has a value which is a reference to a hash where the key is a string and the value is a reference to a list where each element is a string
adminmode has a value which is a bool

=end text

=back

=head2 copy_params

=over 4

=item Description

********* REORGANIZATION FUNCTIONS ******************

=item Definition

=begin html

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a reference to a list containing 2 items:
0: (source) a FullObjectPath
1: (destination) a FullObjectPath

overwrite has a value which is a bool
recursive has a value which is a bool
move has a value which is a bool
adminmode has a value which is a bool

=end html

=begin text

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a reference to a list containing 2 items:
0: (source) a FullObjectPath
1: (destination) a FullObjectPath

overwrite has a value which is a bool
recursive has a value which is a bool
move has a value which is a bool
adminmode has a value which is a bool

=end text

=back

=head2 delete_params

=over 4

=item Description

********* DELETION FUNCTIONS ******************

=item Definition

=begin html

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
deleteDirectories has a value which is a bool
force has a value which is a bool
adminmode has a value which is a bool

=end html

=begin text

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
deleteDirectories has a value which is a bool
force has a value which is a bool
adminmode has a value which is a bool

=end text

=back

=head2 set_permissions_params

=over 4

=item Description

********* FUNCTIONS RELATED TO SHARING *******************

=item Definition

=begin html

a reference to a hash where the following keys are defined:
path has a value which is a FullObjectPath
permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
0: an Username
1: a WorkspacePerm

new_global_permission has a value which is a WorkspacePerm
adminmode has a value which is a bool

=end html

=begin text

a reference to a hash where the following keys are defined:
path has a value which is a FullObjectPath
permissions has a value which is a reference to a list where each element is a reference to a list containing 2 items:
0: an Username
1: a WorkspacePerm

new_global_permission has a value which is a WorkspacePerm
adminmode has a value which is a bool

=end text

=back

=head2 list_permissions_params

=over 4

=item Description

"list_permissions" command
        Description:
        This function lists permissions for the specified objects

        Parameters:
        list<FullObjectPath> objects - path to objects for which permissions are to be listed
        bool adminmode - run this command as an admin, meaning you can list permissions on anything anywhere

=item Definition

=begin html

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
adminmode has a value which is a bool

=end html

=begin text

a reference to a hash where the following keys are defined:
objects has a value which is a reference to a list where each element is a FullObjectPath
adminmode has a value which is a bool

=end text

=back

=cut

package Bio::P3::Workspace::WorkspaceClient::RpcClient;
use POSIX;
use strict;
use LWP::UserAgent;
use JSON::XS;

BEGIN {
    for my $method (qw/uri ua json content_type version id allow_call status_line/) {
	eval qq|
	    sub $method {
		\$_[0]->{$method} = \$_[1] if defined \$_[1];
		\$_[0]->{$method};
	    }
	    |;
	}
    }

sub new
{
    my($class) = @_;

    my $ua = LWP::UserAgent->new();
    my $json = JSON::XS->new->allow_nonref->utf8;

    my $self = {
	ua => $ua,
	json => $json,
    };
    return bless $self, $class;
}

sub call {
    my ($self, $uri, $headers, $obj) = @_;
    my $result;

    {
	if ($uri =~ /\?/) {
	    $result = $self->_get($uri);
	}
	else {
	    Carp::croak "not hashref." unless (ref $obj eq 'HASH');
	    $result = $self->_post($uri, $headers, $obj);
	}

    }

    my $service = $obj->{method} =~ /^system\./ if ( $obj );

    $self->status_line($result->status_line);

    if ($result->is_success || $result->content_type eq 'application/json') {

	my $txt = $result->content;

        return unless($txt); # notification?

	my $obj = eval { $self->json->decode($txt); };

	if (!$obj)
	{
	    die "Error parsing result: $@";
	}

	return $obj;
    }
    else {
        return;
    }
}

sub _get {
    my ($self, $uri) = @_;
    $self->ua->get(
		   $uri,
		   Accept         => 'application/json',
		  );
}

sub _post {
    my ($self, $uri, $headers, $obj) = @_;
    my $json = $self->json;

    $obj->{version} ||= $self->{version} || '1.1';

    if ($obj->{version} eq '1.0') {
        delete $obj->{version};
        if (exists $obj->{id}) {
            $self->id($obj->{id}) if ($obj->{id}); # if undef, it is notification.
        }
        else {
            $obj->{id} = $self->id || ($self->id('JSON::RPC::Legacy::Client'));
        }
    }
    else {
        # $obj->{id} = $self->id if (defined $self->id);
	# Assign a random number to the id if one hasn't been set
	$obj->{id} = (defined $self->id) ? $self->id : substr(rand(),2);
    }

    my $content = $json->encode($obj);

    $self->ua->post(
        $uri,
        Content_Type   => $self->{content_type},
        Content        => $content,
        Accept         => 'application/json',
	@$headers,
	($self->{token} ? (Authorization => $self->{token}) : ()),
    );
}

1;


text:
. $PSScriptRoot\Get-MSBuildPath.ps1

Function Get-SolutionConfigurations {
    [CmdletBinding()]
    Param(
    [Parameter(Mandatory=$true)]
    [string]$SolutionFile)

    $msbuildPath = Get-MSBuildPath
    Add-Type -Path "$msbuildPath\Microsoft.Build.dll"
    $solution = [Microsoft.Build.Construction.SolutionFile]::Parse($SolutionFile)
    $solution.SolutionConfigurations
}

redpajama_set_name: RedPajamaGithub


text:
package com.hackerrank.strings;

import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class TokenContentExtractor {

	public static void main(String[] args) {
		 //Scanner in = new Scanner(System.in);
	     // int testCases = Integer.parseInt(in.nextLine());
	    int testCases = 3;
	    String[] inputStrings = new String[4];
	    inputStrings[3] = "
Nayeem loves counseling
";
	    inputStrings[2] = "

Sanjay has no watch

<par>So wait for a while</par>";
	    inputStrings[1] = "<Amee>safat codes like a ninja</amee>";
	    inputStrings[0] = "<SA premium>Imtiaz has a secret crush</SA premium>";
		while(testCases>=0){
	         //String line = in.nextLine();
	         String line = inputStrings[testCases];

	         int count = 0;
	         Pattern r = Pattern.compile("<(.+?)>([^<>]+)</\\1>");
	         Matcher m = r.matcher(line);
	         while(m.find()) {
	             if (m.group(2).length() !=0) {
	                 System.out.println(m.group(2));
	                 count++;
	             }
	         }
	         if (count == 0) System.out.println("None");

	         testCases--;
	      }
	}
}


text:
import React from 'react';
import { Dimensions, StyleSheet, View } from 'react-native';
import moment from 'moment';
import VitezKategorie from '../components/VitezKategorie';
import PopisekKategorie from '../components/Popisek/PopisekKategorie';

const kategorie = {
  pohlavi: 'muž',
  typ: 'maraton',
  vek: { min: 18, max: 30 }
};

const prvni = {
  cas: moment.duration('PT4H15M32.45S'),
  jmeno: 'Václav Zakouřil',
  narozeni: 1945,
  umisteni: 1
};
const druhy = {
  cas: moment.duration('PT2H17M29.14S'),
  jmeno: 'Roman Smeták',
  narozeni: 1986,
  umisteni: 2
};
const treti = {
  cas: moment.duration('PT3H27M42.38S'),
  jmeno: 'František Beran',
  narozeni: 1974,
  umisteni: 3
};

const VitezoveKategorieScreen = () => (
  <View style={styles.container}>
    <View style={styles.kategorieContainer}>
      <View style={styles.kategorie}>
        <PopisekKategorie {...kategorie} />
      </View>
    </View>

    <View style={styles.vitezove}>
      <VitezKategorie containerStyle={styles.vitez} {...treti} />
      <VitezKategorie containerStyle={styles.vitez} {...prvni} />
      <VitezKategorie containerStyle={styles.vitez} {...druhy} />
    </View>
  </View>
);

export default VitezoveKategorieScreen;

const styles = StyleSheet.create({
  container: {
    backgroundColor: '#fff',
    flex: 1,
    justifyContent: 'space-between',
    paddingBottom: 10,
    paddingTop: 30
  },
  kategorie: {
    backgroundColor: '#b0ffb5',
    borderRadius: 8,
    borderWidth: 2,
    padding: 8
  },
  kategorieContainer: {
    alignItems: 'center',
    marginBottom: 20,
    marginTop: 10
  },
  vitez: {
    margin: 10,
    width: Dimensions.get('window').height / 3
  },
  vitezove: {
    flexDirection: 'row',
    justifyContent: 'space-evenly'
  }
});


text:
/*
* GUI-Adapter for the CoapMessageLog on the bottom
* - Adds each sent / received message to the message log
* - Installs a resizer and a collapser
*/
Copper.MessageLogAdapter = function(){
};

Copper.MessageLogAdapter.resizer = undefined;
Copper.MessageLogAdapter.collapser = undefined;

Copper.MessageLogAdapter.beforeSessionInitialization = function(){
	Copper.MessageLogAdapter.resizer = Copper.Resizer.installResizer(document.getElementsByClassName("main-content-bottom-box")[0], function(newWidth, newHeight){
		Copper.Session.layout.messageLogHeight = newHeight;
		Copper.Session.updateLayout(Copper.Session.layout);
	}, false, true, false);
	Copper.MessageLogAdapter.collapser = Copper.Resizer.installCollapser(document.getElementsByClassName("main-content-bottom-box")[0], "top", function(collapsed){
        Copper.Session.layout.messageLogCollapsed = collapsed;
		Copper.Session.updateLayout(Copper.Session.layout);
    });
};

Copper.MessageLogAdapter.onLayoutUpdated = function(){
	if (Copper.Session.layout.messageLogHeight !== undefined){
		Copper.MessageLogAdapter.resizer.setHeight(Copper.Session.layout.messageLogHeight);
	}
	else {
		Copper.MessageLogAdapter.resizer.reset();
	}
	Copper.MessageLogAdapter.collapser.changeCollapsedState(Copper.Session.layout.messageLogCollapsed);
};

Copper.MessageLogAdapter.onEvent = function(event){
	switch(event.type){
		case Copper.Event.TYPE_COAP_MESSAGE_SENT:
			Copper.MessageLogAdapter.addLogEntry(event.data.coapMessage, false, event.data.retransmissionCount);
			break;
		case Copper.Event.TYPE_COAP_MESSAGE_RECEIVED:
			Copper.MessageLogAdapter.addLogEntry(event.data.coapMessage, true);
			break;
		case Copper.Event.TYPE_UNKNOWN_COAP_MESSAGE_RECEIVED:
			if (Copper.Session.settings.showUnknown){
				Copper.MessageLogAdapter.addLogEntry(event.data.coapMessage, true, undefined, true);
			}
			break;
		case Copper.Event.TYPE_DUPLICATE_COAP_MESSAGE_RECEIVED:
			Copper.MessageLogAdapter.addLogEntry(event.data.coapMessage, true, undefined, true);
			break;
	}
};

Copper.MessageLogAdapter.addLogEntry = function(coapMessage, isReceived, retransmissionCount, isUnexpected){
	let rootElement = document.getElementById("copper-coap-message-log-table");

	let logElement = document.createElement("div");
	logElement.classList.add("table-body-row");
	logElement.classList.add(isReceived ? (isUnexpected ? "unexpected" : "received") : "sent");

	let timeElement = document.createElement("span");
	timeElement.classList.add("coap-message-time");
	timeElement.textContent = Copper.StringUtils.getTime();
	logElement.appendChild(timeElement);

	let typeElement = document.createElement("span");
	typeElement.classList.add("coap-message-type");
	typeElement.textContent = coapMessage.type.name;
	logElement.appendChild(typeElement);

	let codeElement = document.createElement("span");
	codeElement.classList.add("coap-message-code");
	codeElement.textContent = coapMessage.code.getName();
	logElement.appendChild(codeElement);

	let midElement = document.createElement("span");
	midElement.classList.add("coap-message-mid");
	let mid = coapMessage.mid;
	if (!isReceived && Copper.CoapMessage.Type.CON.equals(coapMessage.type)){
		mid = mid + " (" + retransmissionCount + ")";
	}
	midElement.textContent = mid;
	logElement.appendChild(midElement);

	let tokenElement = document.createElement("span");
	tokenElement.classList.add("coap-message-token");
	tokenElement.textContent = Copper.ByteUtils.convertBytesToHexString(coapMessage.token);
	logElement.appendChild(tokenElement);

	let optionsElement = document.createElement("span");
	optionsElement.classList.add("coap-message-options");
	let options = coapMessage.getOptions();
	for (let i=0; i<options.length; i++){
		let optionHeader = options[i].header;
		let value = options[i].getValue({useUtf8: Copper.Session.options.useUtf8});
		for (let j=0; j<value.length; j++){
			let optionElement = document.createElement("span");
			optionElement.classList.add("no-wrap");
			let optionText = optionHeader.name + ": " + value[j];
			if ((i+1) < options.length || (j+1) < value.length){
				optionText = optionText + ", ";
			}
			optionElement.textContent = optionText;
			optionsElement.appendChild(optionElement);
		}
	}
	logElement.appendChild(optionsElement);

	let payloadElement = document.createElement("span");
	payloadElement.classList.add("coap-message-payload");
	if (coapMessage.payload.byteLength > 0){
		let contentFormat = coapMessage.getOption(Copper.CoapMessage.OptionHeader.CONTENT_FORMAT);
		contentFormat = contentFormat.length > 0 ? Copper.CoapMessage.ContentFormat.getContentFormat(contentFormat[0]) : undefined;
		if (contentFormat !== undefined && contentFormat.isText){
			payloadElement.textContent = Copper.ByteUtils.convertBytesToString(coapMessage.payload, undefined, undefined, !Copper.Session.options.useUtf8);
		}
		else {
			payloadElement.textContent = "[non-textual payload]";
		}
	}
	logElement.appendChild(payloadElement);

	rootElement.insertBefore(logElement, rootElement.firstChild);
};


text:
package de.ks.strudel.route;

public enum FilterType {
  BEFORE, AFTER;
}


text:
"""Tests for the SeedStream class."""

from __future__ import absolute_import
from __future__ import division
from __future__ import print_function

from tensorflow.contrib.distributions.python.ops import seed_stream
from tensorflow.python.platform import test

class SeedStreamTest(test.TestCase):

  def assertAllUnique(self, items):
    self.assertEqual(len(items), len(set(items)))

  def testNonRepetition(self):
    # The probability of repetitions in a short stream from a correct
    # PRNG is negligible; this test catches bugs that prevent state
    # updates.
    strm = seed_stream.SeedStream(seed=4, salt="salt")
    output = [strm() for _ in range(50)]
    self.assertEqual(sorted(output), sorted(list(set(output))))

  def testReproducibility(self):
    strm1 = seed_stream.SeedStream(seed=4, salt="salt")
    strm2 = seed_stream.SeedStream(seed=4, salt="salt")
    strm3 = seed_stream.SeedStream(seed=4, salt="salt")
    outputs = [strm1() for _ in range(50)]
    self.assertEqual(outputs, [strm2() for _ in range(50)])
    self.assertEqual(outputs, [strm3() for _ in range(50)])

  def testSeededDistinctness(self):
    strm1 = seed_stream.SeedStream(seed=4, salt="salt")
    strm2 = seed_stream.SeedStream(seed=5, salt="salt")
    self.assertAllUnique(
        [strm1() for _ in range(50)] + [strm2() for _ in range(50)])

  def testSaltedDistinctness(self):
    strm1 = seed_stream.SeedStream(seed=4, salt="salt")
    strm2 = seed_stream.SeedStream(seed=4, salt="another salt")
    self.assertAllUnique(
        [strm1() for _ in range(50)] + [strm2() for _ in range(50)])

  def testNestingRobustness(self):
    # SeedStreams started from generated seeds should not collide with
    # the master or with each other, even if the salts are the same.
    strm1 = seed_stream.SeedStream(seed=4, salt="salt")
    strm2 = seed_stream.SeedStream(strm1(), salt="salt")
    strm3 = seed_stream.SeedStream(strm1(), salt="salt")
    outputs = [strm1() for _ in range(50)]
    self.assertAllUnique(
        outputs + [strm2() for _ in range(50)] + [strm3() for _ in range(50)])

if __name__ == "__main__":
  test.main()


text:
require('@/styles/main.scss')
require('@/styles/main.styl')

// global axios configuration
import axios from 'axios'
import { camelizeKeys, decamelizeKeys } from 'humps'
axios.defaults.headers.common['Accept'] = 'application/json'
axios.defaults.headers.common['Content-Type'] = 'application/json'
axios.defaults.transformRequest = (data) => {
  return JSON.stringify(decamelizeKeys(data))
}
axios.defaults.transformResponse = (data) => {
  switch (typeof data) {
    case 'object':
      return camelizeKeys(data)
    case 'string':
      return camelizeKeys(JSON.parse(data))
  }
}

// global toastr configuration
window.toastr = require('toastr')
window.toastr.options = {
  closeButton: true,
  debug: false,
  extendedTimeOut: '1000',
  hideDuration: '1000',
  hideEasing: 'linear',
  hideMethod: 'fadeOut',
  newestOnTop: true,
  onclick: null,
  positionClass: 'toast-top-right',
  preventDuplicates: false,
  progressBar: true,
  showDuration: '300',
  showEasing: 'swing',
  showMethod: 'fadeIn',
  timeOut: '5000'
}

// Mounted Vue app || Aplicación Vue montada
import { app } from '@/app'
app.$mount('#root')


text:
<?php
namespace app\models;

use app\managers\QueryManager;

Class SqlSiteData extends \yii\base\Model{

    public function getMenu(){
       $queryManager=new QueryManager;
       $qs="SELECT kr.rubricId,kr.eng as engr, kc.eng, kr.name as rubric, kc.name as category,kc.categoryId".
               " FROM kochevni_new.categories as kc".
               " LEFT JOIN kochevni_new.rubrics as kr ON kc.rubricId=kr.rubricId ORDER BY kc.orderCat";
          return $queryManager->getSqlFullData($qs);

    }
    public function getMadeCategory($rubric,$category=0){
       $queryManager=new QueryManager;
       $where='';
       if(!empty($rubric)){
         $where='WHERE mc.rubricId = '.$rubric;
       }
       if(!empty($category)){
           $where.=' AND mc.categoryId='.$category;
       }
       $qs="SELECT mk.* ".
               " FROM kochevni_new.madeCategory as mc".
               " INNER JOIN kochevni_new.madeCompany as mk ON mc.idCompany=mk.idCompany".
               " {$where} GROUP BY mk.idCompany ORDER BY mk.nameCompany";
               return $queryManager->getSqlFullData($qs);

    }

      public function getFilterCategory($category,$made=0){
       $queryManager=new QueryManager;
       $where=' p.categoryId = '.$category;
       if(!empty($made)){
           $where.=' AND p.made='.$made;
       }
       $qs="SELECT fi.*,f.nameFilter FROM kochevni_new.filterProduct as p
            INNER JOIN kochevni_new.filterItem as fi ON p.filter=fi.idItem
            INNER JOIN kochevni_new.filter as f ON fi.filterId=f.filterId
            where {$where}";
          return $queryManager->getSqlFullData($qs);

    }

    public function getProductInfo($product_id){
        if(!empty($product_id)){
              $queryManager=new QueryManager;
             $qs="SELECT p.*,c.name as cat_name,c.eng as cat_eng,
                  r.name as rub_name,r.eng as rub_eng,m.*
                  FROM kochevni_new.pruducts as p
                  INNER JOIN kochevni_new.categories as c ON p.categoryId=c.categoryId
                  INNER JOIN kochevni_new.rubrics as r ON p.rubricId=r.rubricId
                  INNER JOIN kochevni_new.madeCompany as m ON p.made=m.idCompany
                  WHERE p.productId={$product_id}";
          return $queryManager->getSqlFullData($qs);
        }else{
            return array();
        }

    }

    public function getProductFilter($product_id){
        if(!empty($product_id)){
            $queryManager=new QueryManager;
            $qs="SELECT fi.*,f.* FROM kochevni_new.filterProduct as fp
                INNER JOIN kochevni_new.filterItem as fi ON fp.filter=fi.idItem
                INNER JOIN kochevni_new.filter as f ON fi.filterId=f.filterId
                WHERE fp.productId={$product_id}";
           return $queryManager->getSqlFullData($qs);
        }else{
           return array();
        }

    }

    public function getOrdersUser($indent) {
        if (!empty($indent)) {
            $queryManager = new QueryManager;
            $qs = " SELECT p.*,o.filterOrder,o.orderId,o.indent,o.countItem" .
                    " FROM kochevni_new.orders as o" .
                    " LEFT JOIN kochevni_new.pruducts as p ON o.productId=p.productId" .
                    " WHERE o.indent=" . $indent . " AND o.status=0";
             return $queryManager->getSqlFullData($qs);
        } else {
            return array();
        }
    }

        public function getFilterNamesByIds($item_ids){
        if(!empty($item_ids)){
            $queryManager=new QueryManager;
            $qs="SELECT fi.*,f.* FROM  kochevni_new.filterItem as fi
                INNER JOIN kochevni_new.filter as f ON fi.filterId=f.filterId
                WHERE fi.idItem IN ({$item_ids})";
           return $queryManager->getSqlFullData($qs);
        }else{
           return array();
        }

    }

    public function setUserData($user_data){
        if(!empty($user_data)){
            $queryManager=new QueryManager;
            $qs="INSERT  INTO  kochevni_new.buyers  SET name='".$user_data['nameBuyer']."',
             phone=".$user_data['phoneBuyer'].", email='".$user_data['mailBuyer']."',
             fPhone='".$user_data['phoneBuyerf']."',addDate=now() ON DUPLICATE KEY UPDATE ".
            " name='".$user_data['nameBuyer']."', email='".$user_data['mailBuyer']."',addDate=now()";
            $queryManager->updateSqlData($qs);
            $qs_get="SELECT idBuyer FROM kochevni_new.buyers WHERE phone=".$user_data['phoneBuyer'];
            return  $queryManager->getSqlFullData($qs_get);
        }else{
           return array();
        }
    }

    public function getProductsFilter($data_search,$count,$limit,$page){
        $gallery_date=array();
        $queryManager=new QueryManager;
         $from=$page*$limit;
         $limit_sql=" ORDER BY p.dateAdd DESC LIMIT ".$from.",".$limit;
         $qs="SELECT fp.filter,p.*,count(p.productId) as c, mc.imageMade".
            " FROM kochevni_new.pruducts as p ".
            " INNER JOIN kochevni_new.madeCompany as mc ON p.made=mc.idCompany".
            " INNER JOIN kochevni_new.filterProduct as fp ON p.productId=fp.productId".
            " WHERE p.`status`=0  AND p.categoryId =".$data_search['category'].
                    (!empty($data_search['brand_id'])?" AND p.made='".$data_search['brand_id']."'":"").
            " AND  fp.filter IN (".$data_search['filters'].")".
            " GROUP BY p.productId HAVING c=".$count;
        $count= count($queryManager->getSqlFullData($qs));
        $qs.=" ".$limit_sql;
        $data= $queryManager->getSqlFullData($qs);
        $made = '';
        if($count!=0){
            foreach ($data as $key => $value) {
                $gallery_date[$key]['title'] = $value['title'];
                $gallery_date[$key]['image'] = $value['image'];
                $gallery_date[$key]['price'] = $value['price'];
                $gallery_date[$key]['priceAction'] = $value['priceAction'];
                $gallery_date[$key]['translit'] = $value['translit'];
                $gallery_date[$key]['productId'] = $value['productId'];
                $gallery_date[$key]['made'] = $value['made'];
                if ($made)
                    $made.=",";
                $made.=$value['made'];
            }
        }
        return array('data'=>$gallery_date,'total'=>$count,'made'=>$made);
    }

    public function getProductsSearch($search_word,$limit,$page){
        if(empty($search_word) || strlen($search_word)<2){
            return [];
        }
        $from=$page*$limit;
        $count=0;
        $limit_sql=" ORDER BY p.dateAdd DESC LIMIT ".$from.",".$limit;
        $queryManager=new QueryManager;
        $date=array();
        $this->historySearch($search_word);
        $search_word_array=explode(" ",$search_word);
        if(count($search_word_array)>4) {
            $search_word_array=array_slice($search_word_array,0,4);
        }

        if(count($search_word_array)>1){
            $search_word=implode("(.*)",$search_word_array);
        }
        $sql="SELECT p.* FROM kochevni_new.productsSearch as ps "
                . " INNER JOIN kochevni_new.pruducts as p  ON ps.productId=p.productId"
                . " WHERE p.status=0 AND ps.titleSearch RLIKE '".$search_word."'";
        if($limit==12){
          $count= count($queryManager->getSqlFullData($sql));
        }
        $sql.=" ".$limit_sql;
        $products= $queryManager->getSqlFullData($sql);
         $made='';
        if(!empty($products)){
            foreach ($products as $key => $value) {
                 $date[$key]['title']=$value['title'];
                 $date[$key]['image']=preg_replace("/medium/","thumb",$value['image']);
                 $date[$key]['price']=$value['price'];
                 $date[$key]['priceAction']=$value['priceAction'];
                 $date[$key]['translit']=$value['translit'];
                 $date[$key]['productId']=$value['productId'];
                 $date[$key]['made']=$value['made'];
                 if($made)$made.=",";
                    $made.=$value['made'];
            }
        }
        return array('data'=>$date,'made'=>$made,'total'=>$count);
    }

    public function historySearch($searchWord){
        $queryManager=new QueryManager;
        $sql="INSERT INTO  kochevni_new.historySearch set wordSearch='{$searchWord}',".
                " count=1, dateAdd='".date("Y-m-d H-n-s")."'".
            " ON DUPLICATE KEY UPDATE count=count+1, dateAdd='".date("Y-m-d H-n-s")."'";
        $queryManager->updateSqlData($sql);

    }

}


text:
<?php

namespace Medooch\Components\Traits;
use Medooch\Components\Helper\Helper;

/**
 * Class Token
 * @package Medooch\Components\Traits
 */
trait Token
{
    /**
     * Token constructor.
     */
    public function setToken()
    {
        $this->token = Helper::generateToken();
    }

    /**
     * @var string
     * @ORM\Column(type="string", length=255)
     */
    private $token;

    /**
     * @return string
     */
    public function getToken()
    {
        return $this->token;
    }
}


text:
<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

class course_content extends Model
{
    //
}


text:
<!doctype html>
<meta charset="utf-8">

    <title>Minerva Analytics</title>
    <link rel="shortcut icon" href="http://sstatic.net/stackoverflow/img/favicon.ico">

    <link rel="stylesheet" type="text/css" href="css/normalize.css">
    <link rel="stylesheet" type="text/css" href="css/skeleton.css">
    <link rel="stylesheet" type="text/css" href="css/plottable.css">
    <link rel="stylesheet" type="text/css" href="css/main.css">

Browsing History

          <svg class = "graph" align="center" id="graph_id"></svg>

Bar Graph

Patterns Over Time

Pie Graph

Recommended Content

Technology

Finance

Politics

Productive

Unknown

Unproductive


text:
FROM library/ubuntu:14.04

MAINTAINER n4sjamk

RUN apt-get update && apt-get install -y openssh-server supervisor pptpd nano vim
RUN mkdir -p /var/run/sshd /var/log/supervisor
COPY supervisord.conf /etc/supervisor/conf.d/supervisord.conf
COPY pptpd.conf    /etc/
COPY chap-secrets  /etc/ppp/
COPY pptpd-options /etc/ppp/
COPY rc.local		/etc/
COPY sysctl.conf	/etc/
RUN /etc/init.d/pptpd restart
RUN sudo useradd dockeruser -m -s /bin/bash
RUN echo dockeruser:dockeruser | sudo chpasswd
RUN sudo usermod -aG sudo dockeruser
RUN iptables -t nat -A POSTROUTING -s 172.17.0.0/24 -o eth0 -j MASQUERADE
RUN iptables -A FORWARD -p tcp --syn -s 172.17.0.0/24 -j TCPMSS --set-mss 1356
RUN apt-get install iptables-persistent

EXPOSE 22 1723
CMD ["supervisord", "-c", "/etc/supervisor/supervisord.conf"]


text:
package com.imaginatelabs.jleaser.core;

import com.imaginatelabs.jleaser.TestUtils;
import com.imaginatelabs.jleaser.core.configuration.JLeaserConfiguration;
import com.imaginatelabs.jleaser.core.configuration.JLeaserConfigurationFactory;
import com.imaginatelabs.jleaser.docker.configuration.DockerConfiguration;
import com.imaginatelabs.jleaser.docker.configuration.DockerContainerConfiguration;
import com.imaginatelabs.jleaser.docker.configuration.DockerContainerConfigurationNotFoundException;
import org.testng.Assert;
import org.testng.annotations.Test;

import java.util.List;

public class XmlConfigurationTest {

    @Test
    public void shouldReadValidConfigurationFromXmlFileForPorts() throws Exception {
        JLeaserConfiguration config = JLeaserConfigurationFactory.getConfigurationFromXml("config/jleaser.config");

        // Test this section of the config file
        //<ports>
        //      <included> 16384 + 1 + 6 + 11 = 16402
        //          *,
        //          49151,
        //          49140-49145,
        //          39140-39150,
        //      </included>
        //      <excluded>
        //          49153,
        //          49160-49170,
        //          39143-39146
        //      </excluded>
        //</ports>

        List<String> excludedPorts = config.getPortConfiguration().getExcludedPorts();
        List<String> includedPorts = config.getPortConfiguration().getIncludedPorts();
        List<String> validPorts = config.getPortConfiguration().getValidPorts();

        Assert.assertTrue(validPorts.contains("49151"));
        Assert.assertTrue(validPorts.contains("49152"));
        Assert.assertTrue(validPorts.contains("49154"));
        Assert.assertTrue(validPorts.contains("39140"));
        Assert.assertTrue(validPorts.contains("39150"));

        Assert.assertFalse(validPorts.contains("49153"));
        Assert.assertFalse(validPorts.contains("49160"));
        Assert.assertFalse(validPorts.contains("49170"));
        Assert.assertFalse(validPorts.contains("39143"));
        Assert.assertFalse(validPorts.contains("39146"));
    }

    @Test
    public void shouldUseDefaultConfigValuesIfConfigFileIsAbsent() throws Exception {
        try {
            JLeaserConfigurationFactory.getConfigurationFromXml("foo.config");
        }catch (Exception e){
            Assert.fail();
        }
    }

    @Test
    public void shouldReadDockerConfigCorrectly() throws Exception {
        DockerConfiguration dockerConfiguration = JLeaserConfigurationFactory
                .getConfigurationFromXml("config/jleaser.config")
                .getDockerConfiguration();

        DockerContainerConfiguration mysqlContainerConfiguration = dockerConfiguration.getDockerContainerConfiguration("tutum/mysql");
        DockerContainerConfiguration mongoContainerConfiguration = dockerConfiguration.getDockerContainerConfiguration("tutum/mongodb");

        Assert.assertEquals(mysqlContainerConfiguration.getId(),"tutum/mysql");
        Assert.assertEquals(mysqlContainerConfiguration.getBaseImage(),"tutum/mysql");
        Assert.assertEquals(mysqlContainerConfiguration.getDefaultPoolSize(),1);

        Assert.assertEquals(mongoContainerConfiguration.getId(),"tutum/mongodb");
        Assert.assertEquals(mongoContainerConfiguration.getBaseImage(),"tutum/mongodb");
        Assert.assertEquals(mongoContainerConfiguration.getDefaultPoolSize(),0);

        try{
            dockerConfiguration.getDockerContainerConfiguration("foo/bar");
            Assert.fail("Get Docker Container Configuration should fail when searching for a config item that doesn't exits");
        }catch(DockerContainerConfigurationNotFoundException e){
            Assert.assertEquals(e.getMessage(),"Configuration for a Docker container with id 'foo/bar' was not found.");
        }
    }
}


text:
@interface MRPRCommitsViewController : BaseViewController
@property (strong, nonatomic) MRPR *curMRPR;
@property (strong, nonatomic) Project *curProject;

@end


text:
#include "computer.h"
#include <QDateTime>

Computer::Computer()
{
    this->procesEvents=false;
}

bool Computer::cd(QString dir)
{
    if (this->directory.cd(dir))
        return true;
    return false;
}

bool Computer::cdUp()
{
    if (this->directory.cdUp())
        return true;
    return false;
}

QList<File> *Computer::getFileList()
{
    QDir directory(this->getPath());
    QFileInfoList fileInfoList;
    if (this->hiddenFiles)
    {
        fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot | QDir::Hidden | QDir::System);
    }
    else
    {
        fileInfoList = directory.entryInfoList(QDir::AllEntries | QDir::NoDotAndDotDot);
    }
    QFileInfo fileInfo;
    File file;
    QList<File> *fileList = new QList<File>;
    QFileIconProvider *provider = new QFileIconProvider;
    while (!fileInfoList.isEmpty())
    {
        if (this->procesEvents)
            qApp->processEvents();
        fileInfo = fileInfoList.takeFirst();

        file.fileIcon = provider->icon(fileInfo);
        file.fileName = fileInfo.fileName();
        file.fileSize = QString::number(fileInfo.size());
        file.fileDate = fileInfo.lastModified().toString("MMM dd yyyy");
        file.filePath = fileInfo.absoluteFilePath();
        file.filePermissions = "";
        file.fileOwner = fileInfo.owner();
        if (fileInfo.isDir())
            file.fileType = "dir";
        else
            file.fileType = "file";

        fileList->append(file);
    }
    delete provider;
    return fileList;
}

FileList *Computer::getFileList(QString filter)
{
    FileList *fileList = new FileList;
    QFileInfoList list = this->directory.entryInfoList();
    QFileIconProvider *provider;

    QStringList date;
    QString tmp;
    while (!list.isEmpty())
    {
        date=list.first().lastModified().toString().split(" ");
        tmp=date.at(2)+" "+date.at(1)+" "+date.at(4);
        tmp.remove(".");
        fileList->date.append(tmp);
        fileList->name.append(list.first().fileName());
        fileList->size.append(QString::number(list.first().size()));
        provider=new QFileIconProvider;
        fileList->icon.append(provider->icon(list.first()));
        if (list.first().isDir())
            fileList->type.append("dir");
        else
        {
            if (!fileList->name.last().contains(filter))
            {
                fileList->date.removeLast();
                fileList->name.removeLast();
                fileList->size.removeLast();
                fileList->icon.removeLast();
            }
            fileList->type.append("file");
        }
        delete provider;
        list.removeFirst();
    }
    if (fileList->name.length()==0)
        return  fileList;
    //usun . i ..
    if (fileList->name.count()>0)
    {
//        if (fileList.name.first()==".")
//        {
        int x=fileList->name.indexOf(".");
        if (x!=-1)
        {
            fileList->date.removeAt(x);
            fileList->name.removeAt(x);
            fileList->size.removeAt(x);
            fileList->type.removeAt(x);
            fileList->icon.removeAt(x);
        }

        x=fileList->name.indexOf("..");
        if (x!=-1)
        {
            fileList->date.removeAt(x);
            fileList->name.removeAt(x);
            fileList->size.removeAt(x);
            fileList->type.removeAt(x);
            fileList->icon.removeAt(x);
        }
    }
    return fileList;
}

bool Computer::getHiddenFilesState()
{
    return this->hiddenFiles;
}

QString Computer::getPath()
{
    if (this->directory.path().endsWith("/"))
        return this->directory.path();
    else
        return this->directory.path() + "/";
}

bool Computer::makeDir(QString newDir)
{
    if (this->directory.mkdir(newDir))
        return true;
    return false;
}

bool Computer::remove(File file)
{
    if (file.fileType == "dir")
    {
        this->deleteDir(file.filePath);
    }
    else
    {
        this->deleteFile(file.filePath);
    }
    return false;
}

bool Computer::rename(QString oldName, QString newName)
{
    if (this->directory.rename(oldName,newName))
        return true;
    return false;
}

void Computer::setHiddenFiles(bool hiddenFiles)
{
    this->hiddenFiles=hiddenFiles;
    if (this->hiddenFiles)
    {
        this->directory.setFilter(QDir::Files | QDir::NoSymLinks |QDir::Dirs | QDir::Hidden);
        this->directory.setSorting(QDir::Name | QDir::IgnoreCase | QDir::DirsFirst);
    }
    else
    {
        this->directory.setFilter(QDir::Files | QDir::NoSymLinks |QDir::Dirs);
        this->directory.setSorting(QDir::Name | QDir::IgnoreCase | QDir::DirsFirst);
    }
}

void Computer::setPath(QString newPath)
{
    this->directory.setPath(newPath);
}

bool Computer::deleteFile(QString fileName)
{
    if (fileName.size() < 1) {
        return true;
    }

    QFile file(fileName);

    return file.remove();
}

bool Computer::deleteDir(QString dirName)
{
    QDir directory(dirName);

    if (!directory.exists())
    {
        return true;
    }

    QStringList dirs = directory.entryList(QDir::Dirs | QDir::Hidden);
    QStringList files = directory.entryList(QDir::Files | QDir::Hidden);

    QList<QString>::iterator f = files.begin();
    QList<QString>::iterator d = dirs.begin();

    bool error = false;

    for (; f != files.end(); ++f) {
        if (!deleteFile(directory.path() + '/' + (*f))) {
            error = true;
        }
    }

    for (; d != dirs.end(); ++d) {
        if ((*d) == "." || (*d) == "..") {
            continue;
        }

        if (!deleteDir(directory.path() + '/' + (*d))) {
            error = true;
        }
    }

    if(!directory.rmdir(directory.path())) {
        error = true;
    }

    return !error;

}