Skip to content

Commit

Permalink
create_project: Add db engine driver and athorization token parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
sadam21 committed Dec 24, 2012
1 parent ccf656f commit 513cf6d
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 5 deletions.
24 changes: 23 additions & 1 deletion bin/gdc
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,19 @@ Title of the project.
Descriptive summary of the project.
=item B<-e>, B<--template>
Project template. The list of valid project templates is available from
the template server: L<https://secure.gooddata.com/projectTemplates/>.
=item B<-d>, B<--driver>
Valid db engine drivers are 'Pg' (default) and 'mysql'.
=item B<-k>, B<--token>
Authorization token.
=back
=cut
Expand All @@ -314,17 +327,26 @@ sub mkproject
{
my $title;
my $summary = '';
my $template;
my $driver;
my $token;

GetOptionsFromArray (\@_,
't|title=s' => \$title,
's|summary=s' => \$summary,
'e|template=s' => \$template,
'd|driver=s' => \$driver,
'k|token=s' => \$token,
) or die 'Bad arguments to mkproject';
$title = shift if @_;
$summary = shift if @_;
$template = shift if @_;
$driver = shift if @_;
$token = shift if @_;
die 'Extra arguments' if @_;
die 'No project title given' unless defined $title;

$project = $gdc->create_project ($title, $summary);
$project = $gdc->create_project ($title, $summary, $template, $driver, $token);
}

=head2 lsreports
Expand Down
17 changes: 13 additions & 4 deletions lib/WWW/GoodData.pm
Original file line number Diff line number Diff line change
Expand Up @@ -322,14 +322,17 @@ sub delete_project
$self->{agent}->delete ($uri);
}

=item B<create_project> TITLE SUMMARY TEMPLATE
=item B<create_project> TITLE SUMMARY TEMPLATE DRIVER TOKEN
Create a project given its title and optionally summary and project template,
Create a project given its title and optionally summary, project template,
db engine driver and authorization token
return its identifier.
The list of valid project templates is available from the template server:
L<https://secure.gooddata.com/projectTemplates/>.
Valid db engine drivers are 'Pg' (default) and 'mysql'.
=cut

sub create_project
Expand All @@ -338,15 +341,21 @@ sub create_project
my $title = shift or die 'No title given';
my $summary = shift || '';
my $template = shift;
my $driver= shift;
my $token = shift;

# The redirect magic does not work for POSTs and we can't really
# handle 401s until the API provides reason for them...
$self->{agent}->get ($self->get_uri ('token'));

return $self->{agent}->post ($self->get_uri ('projects'), {
project => {
# No hook to override this; use web UI
content => { guidedNavigation => 1 },
content => {
# No hook to override this; use web UI
guidedNavigation => 1,
($driver ? (driver => $driver) : ()),
($token ? (authorizationToken => $token) : ())
},
meta => {
summary => $summary,
title => $title,
Expand Down

0 comments on commit 513cf6d

Please sign in to comment.