Group
Extension

Matches 11

Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/genapi/typedjson.pm ( view source; MetaCPAN )
package typedjson;


# based on code from EDG::WP4::CCM::Fetch::JSONProfileTyped
# (and EDG::WP4::CCM::Fetch::ProfileCache::_decode_json)
# for an explanation and original code, see
# https://github.c
l/Fetch/JSONProfileTyped.pm
# This was ported and modified here because CCM is not that trivial to install from source

use strict;
use warnings;

use JSON::XS v2.3.0 qw(decode_json encode_json);

use
 parent qw(Exporter);

our @EXPORT = qw(process_json);

use B;
use Scalar::Util qw(blessed);

$SIG{__DIE__} = \&confess;

# Turns a JSON Object (an unordered associative array) into a Perl hash
# refe
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/lib/Net/OpenStack/Client/API/Identity/v3.pod ( view source; MetaCPAN )
ption: string (JSON path: domain -> description)

=item enabled: boolean (JSON path: domain -> enabled)

=item name: string (JSON path: domain -> name)

=item raw: hashref used for JSON body, ignoring
ion: string (JSON path: project -> description)

=item domain_id: string (JSON path: project -> domain_id)

=item enabled: boolean (JSON path: project -> enabled)

=item name: string (JSON path: proje
ct -> name)

=item parent_id: string (JSON path: project -> parent_id)

=item raw: hashref used for JSON body, ignoring all options

=item All options starting with C<__> are passed as options to C<Ne
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/lib/Net/OpenStack/Client.pm ( view source; MetaCPAN )
in/.openrc',
        log => Log::Log4perl->get_logger()
        );

For debugging, including full JSON request / repsonse and headers (so contains sensitive data!):
    use Net::OpenStack::Client;
   
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/genapi/typedjson.t ( view source; MetaCPAN )
use strict;
use warnings;

use Test::More;

use typedjson;


my $txt = '{"a":{"b":1,"c":true},"d":{"b":"what","e":[1,2]}}';
my $result = {
    a_b => {'path' => ['a', 'b'], 'type' => 'long'},
    c =>

};


my $parsed = typedjson::parse_json($txt);

#diag "parsed ",explain $parsed;
is_deeply($parsed, [$result->{a_b}, $result->{c}, $result->{d_b}, $result->{d_e}], "parse_json returns list of scalars
");

my $options = process_json($txt, ['e']);
#diag "options ",explain $options;
is_deeply($options, $result, "generated options hashref");

done_testing();
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/lib/Net/OpenStack/Client/Error.pm ( view source; MetaCPAN )
ew(@_);
}


=item new

Create new error instance from options, e.g. from a (decoded dereferenced) JSON response.

Arguments are handled by C<set_error>.

=cut

sub new
{
    my $this = shift;
    my $
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/lib/Net/OpenStack/Client/REST.pm ( view source; MetaCPAN )
DR_X_AUTH_TOKEN);
use Net::OpenStack::Client::Response;
use REST::Client;
use LWP::UserAgent;
use JSON::XS;

use Readonly;

# Map with HTTP return codes indicating success
#   if method is missing (on
 => [204, 201], # yes, 201 when deleting a token
    };


# JSON::XS instance
# sort the keys, to create reproducable results
my $json = JSON::XS->new()->canonical(1);

=head1 methods

=over

=cut

su
e repsonse, repsonse headers and error message.
# Processes the repsonse code, including possible JSON decoding
# Reports error and returns err (with repsonse undef)
sub _call
{
    my ($self, $method
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/lib/Net/OpenStack/Client/Request.pm ( view source; MetaCPAN )
=> {
    $HDR_ACCEPT => 'application/json, text/plain',
    $HDR_ACCEPT_ENCODING => 'identity, gzip, deflate, compress',
    $HDR_CONTENT_TYPE => 'application/json',
};


=head1 NAME

Net::OpenStack::
";
    }

    return $endpoint;
}

=item opts_data

Generate hashref from options, to be used for JSON encoding.
If C<raw> attribute is defined, ignore all options and return it.

Returns empty hasref
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/lib/Net/OpenStack/Client/API/Version/v1.pod ( view source; MetaCPAN )
s

=item No optional url / endpoint parameters

=item Options

=over

=item raw: hashref used for JSON body, ignoring all options

=item All options starting with C<__> are passed as options to C<Net:
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/lib/Net/OpenStack/Client/Identity/v3.pm ( view source; MetaCPAN )
tion = $attr eq 'enabled' ? ($wa xor $fo): ($wa ne $fo);
                # hmmm, how to keep this JSON safe?
                $update->{$attr} = $wa if $action;
            }
            if (scalar key
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/lib/Net/OpenStack/Client/API/Convert.pm ( view source; MetaCPAN )
ck::Client::Request;

# cannot use 'use Types::Serialiser'; it is incompatible with JSON::XS 2.X (eg on EL6)
use JSON::XS;
use Readonly;

use base qw(Exporter);

our @EXPORT_OK = qw(convert process_ar
ce internal conversion to float/double
    boolean => sub {my $val = shift; return $val ? JSON::XS::true : JSON::XS::false;},
};

# Aliases for each dispatch
Readonly::Hash my %CONVERT_ALIAS => {
};

ptions
    # The processed options are removed from %origopts
    # TODO: naming conflict between JSON key, parameter and template name? (handled in gen.pl)
    foreach my $name (@{$cmdhs->{templates}
Net-OpenStack-Client ( S/ST/STDWEIRD/Net-OpenStack-Client-0.1.4.tar.gz, STDWEIRD, 2018; MetaCPAN )
Net-OpenStack-Client/genapi/gen.pl ( view source; MetaCPAN )
th qw(make_path);
use Config::INI::Reader;
use Data::Dumper;
use Template;
use Readonly;
use typedjson;

my $debug = 1;

Readonly my $GEN_API_DIR => dirname(abs_path($0));
Readonly my $API_DIR => "$GE
options from JSON
        my $json = $mcfg->{json};

        if ((grep {$mcfg->{method} eq $_} @METHODS_REQUIRE_OPTIONS) && !$json) {
            die "$err_prefix data should contain JSON for options 
for method $method $mcfg->{method}";
        }
        $mcfg->{options} = process_json($json, $templates) if $json;
        foreach my $kn (sort keys %{$mcfg->{options}}) {
            if (grep {$_ eq

Powered by Groonga
Maintained by Kenichi Ishigaki <ishigaki@cpan.org>. If you find anything, submit it on GitHub.