Commit 62c895b4 authored by Mike Jones's avatar Mike Jones 🌶

Merge branch 'dev' into 'master'

Compliance

See merge request !38
parents 054d942f 97dc38c4
......@@ -13,6 +13,7 @@ use WebService::Mattermost::V4::API::Resource::Channel::Member;
use WebService::Mattermost::V4::API::Resource::Channels;
use WebService::Mattermost::V4::API::Resource::Cluster;
use WebService::Mattermost::V4::API::Resource::Compliance;
use WebService::Mattermost::V4::API::Resource::Compliance::Report;
use WebService::Mattermost::V4::API::Resource::DataRetention;
use WebService::Mattermost::V4::API::Resource::Database;
use WebService::Mattermost::V4::API::Resource::ElasticSearch;
......@@ -55,43 +56,44 @@ has resources => (is => 'rw', isa => ArrayRef, default => sub {
add_resource => 'push',
});
has analytics => (is => 'ro', isa => InstanceOf[v4 'Analytics'], lazy => 1, builder => 1);
has application => (is => 'ro', isa => InstanceOf[v4 'OAuth::Application'], lazy => 1, builder => 1);
has audits => (is => 'ro', isa => InstanceOf[v4 'Audits'], lazy => 1, builder => 1);
has brand => (is => 'ro', isa => InstanceOf[v4 'Brand'], lazy => 1, builder => 1);
has cache => (is => 'ro', isa => InstanceOf[v4 'Cache'], lazy => 1, builder => 1);
has channel => (is => 'ro', isa => InstanceOf[v4 'Channel'], lazy => 1, builder => 1);
has channel_member => (is => 'ro', isa => InstanceOf[v4 'Channel::Member'], lazy => 1, builder => 1);
has channels => (is => 'ro', isa => InstanceOf[v4 'Channels'], lazy => 1, builder => 1);
has cluster => (is => 'ro', isa => InstanceOf[v4 'Cluster'], lazy => 1, builder => 1);
has compliance => (is => 'ro', isa => InstanceOf[v4 'Compliance'], lazy => 1, builder => 1);
has data_retention => (is => 'ro', isa => InstanceOf[v4 'DataRetention'], lazy => 1, builder => 1);
has database => (is => 'ro', isa => InstanceOf[v4 'Database'], lazy => 1, builder => 1);
has elasticsearch => (is => 'ro', isa => InstanceOf[v4 'ElasticSearch'], lazy => 1, builder => 1);
has email => (is => 'ro', isa => InstanceOf[v4 'Email'], lazy => 1, builder => 1);
has emoji => (is => 'ro', isa => InstanceOf[v4 'Emoji'], lazy => 1, builder => 1);
has file => (is => 'ro', isa => InstanceOf[v4 'File'], lazy => 1, builder => 1);
has files => (is => 'ro', isa => InstanceOf[v4 'Files'], lazy => 1, builder => 1);
has jobs => (is => 'ro', isa => InstanceOf[v4 'Jobs'], lazy => 1, builder => 1);
has ldap => (is => 'ro', isa => InstanceOf[v4 'LDAP'], lazy => 1, builder => 1);
has logs => (is => 'ro', isa => InstanceOf[v4 'Logs'], lazy => 1, builder => 1);
has oauth => (is => 'ro', isa => InstanceOf[v4 'OAuth'], lazy => 1, builder => 1);
has plugin => (is => 'ro', isa => InstanceOf[v4 'Plugin'], lazy => 1, builder => 1);
has plugins => (is => 'ro', isa => InstanceOf[v4 'Plugins'], lazy => 1, builder => 1);
has post => (is => 'ro', isa => InstanceOf[v4 'Post'], lazy => 1, builder => 1);
has posts => (is => 'ro', isa => InstanceOf[v4 'Posts'], lazy => 1, builder => 1);
has reactions => (is => 'ro', isa => InstanceOf[v4 'Reactions'], lazy => 1, builder => 1);
has roles => (is => 'ro', isa => InstanceOf[v4 'Roles'], lazy => 1, builder => 1);
has s3 => (is => 'ro', isa => InstanceOf[v4 'S3'], lazy => 1, builder => 1);
has saml => (is => 'ro', isa => InstanceOf[v4 'SAML'], lazy => 1, builder => 1);
has schemes => (is => 'ro', isa => InstanceOf[v4 'Schemes'], lazy => 1, builder => 1);
has system => (is => 'ro', isa => InstanceOf[v4 'System'], lazy => 1, builder => 1);
has team => (is => 'ro', isa => InstanceOf[v4 'Team'], lazy => 1, builder => 1);
has teams => (is => 'ro', isa => InstanceOf[v4 'Teams'], lazy => 1, builder => 1);
has user => (is => 'ro', isa => InstanceOf[v4 'User'], lazy => 1, builder => 1);
has users => (is => 'ro', isa => InstanceOf[v4 'Users'], lazy => 1, builder => 1);
has webhooks => (is => 'ro', isa => InstanceOf[v4 'Webhook'], lazy => 1, builder => 1);
has webrtc => (is => 'ro', isa => InstanceOf[v4 'WebRTC'], lazy => 1, builder => 1);
has analytics => (is => 'ro', isa => InstanceOf[v4 'Analytics'], lazy => 1, builder => 1);
has application => (is => 'ro', isa => InstanceOf[v4 'OAuth::Application'], lazy => 1, builder => 1);
has audits => (is => 'ro', isa => InstanceOf[v4 'Audits'], lazy => 1, builder => 1);
has brand => (is => 'ro', isa => InstanceOf[v4 'Brand'], lazy => 1, builder => 1);
has cache => (is => 'ro', isa => InstanceOf[v4 'Cache'], lazy => 1, builder => 1);
has channel => (is => 'ro', isa => InstanceOf[v4 'Channel'], lazy => 1, builder => 1);
has channel_member => (is => 'ro', isa => InstanceOf[v4 'Channel::Member'], lazy => 1, builder => 1);
has channels => (is => 'ro', isa => InstanceOf[v4 'Channels'], lazy => 1, builder => 1);
has cluster => (is => 'ro', isa => InstanceOf[v4 'Cluster'], lazy => 1, builder => 1);
has compliance => (is => 'ro', isa => InstanceOf[v4 'Compliance'], lazy => 1, builder => 1);
has compliance_report => (is => 'ro', isa => InstanceOf[v4 'Compliance::Report'], lazy => 1, builder => 1);
has data_retention => (is => 'ro', isa => InstanceOf[v4 'DataRetention'], lazy => 1, builder => 1);
has database => (is => 'ro', isa => InstanceOf[v4 'Database'], lazy => 1, builder => 1);
has elasticsearch => (is => 'ro', isa => InstanceOf[v4 'ElasticSearch'], lazy => 1, builder => 1);
has email => (is => 'ro', isa => InstanceOf[v4 'Email'], lazy => 1, builder => 1);
has emoji => (is => 'ro', isa => InstanceOf[v4 'Emoji'], lazy => 1, builder => 1);
has file => (is => 'ro', isa => InstanceOf[v4 'File'], lazy => 1, builder => 1);
has files => (is => 'ro', isa => InstanceOf[v4 'Files'], lazy => 1, builder => 1);
has jobs => (is => 'ro', isa => InstanceOf[v4 'Jobs'], lazy => 1, builder => 1);
has ldap => (is => 'ro', isa => InstanceOf[v4 'LDAP'], lazy => 1, builder => 1);
has logs => (is => 'ro', isa => InstanceOf[v4 'Logs'], lazy => 1, builder => 1);
has oauth => (is => 'ro', isa => InstanceOf[v4 'OAuth'], lazy => 1, builder => 1);
has plugin => (is => 'ro', isa => InstanceOf[v4 'Plugin'], lazy => 1, builder => 1);
has plugins => (is => 'ro', isa => InstanceOf[v4 'Plugins'], lazy => 1, builder => 1);
has post => (is => 'ro', isa => InstanceOf[v4 'Post'], lazy => 1, builder => 1);
has posts => (is => 'ro', isa => InstanceOf[v4 'Posts'], lazy => 1, builder => 1);
has reactions => (is => 'ro', isa => InstanceOf[v4 'Reactions'], lazy => 1, builder => 1);
has roles => (is => 'ro', isa => InstanceOf[v4 'Roles'], lazy => 1, builder => 1);
has s3 => (is => 'ro', isa => InstanceOf[v4 'S3'], lazy => 1, builder => 1);
has saml => (is => 'ro', isa => InstanceOf[v4 'SAML'], lazy => 1, builder => 1);
has schemes => (is => 'ro', isa => InstanceOf[v4 'Schemes'], lazy => 1, builder => 1);
has system => (is => 'ro', isa => InstanceOf[v4 'System'], lazy => 1, builder => 1);
has team => (is => 'ro', isa => InstanceOf[v4 'Team'], lazy => 1, builder => 1);
has teams => (is => 'ro', isa => InstanceOf[v4 'Teams'], lazy => 1, builder => 1);
has user => (is => 'ro', isa => InstanceOf[v4 'User'], lazy => 1, builder => 1);
has users => (is => 'ro', isa => InstanceOf[v4 'Users'], lazy => 1, builder => 1);
has webhooks => (is => 'ro', isa => InstanceOf[v4 'Webhook'], lazy => 1, builder => 1);
has webrtc => (is => 'ro', isa => InstanceOf[v4 'WebRTC'], lazy => 1, builder => 1);
################################################################################
......@@ -136,44 +138,45 @@ sub _new_resource {
# name", i.e. DataRetention's base resource is "data_retention", not
# "dataretention".
sub _build_analytics { shift->_new_resource('Analytics') }
sub _build_application { shift->_new_resource('OAuth::Application', 'oauth') }
sub _build_audits { shift->_new_resource('Audits') }
sub _build_brand { shift->_new_resource('Brand') }
sub _build_cache { shift->_new_resource('Cache', 'caches') }
sub _build_channel { shift->_new_resource('Channel', 'channels') }
sub _build_channel_member { shift->_new_resource('Channel::Member', 'channels') }
sub _build_channels { shift->_new_resource('Channels') }
sub _build_cluster { shift->_new_resource('Cluster') }
sub _build_compliance { shift->_new_resource('Compliance') }
sub _build_config { shift->_new_resource('Config') }
sub _build_data_retention { shift->_new_resource('DataRetention', 'data_retention') }
sub _build_database { shift->_new_resource('Database') }
sub _build_elasticsearch { shift->_new_resource('ElasticSearch') }
sub _build_email { shift->_new_resource('Email') }
sub _build_emoji { shift->_new_resource('Emoji') }
sub _build_files { shift->_new_resource('Files', 'files') }
sub _build_file { shift->_new_resource('File', 'files') }
sub _build_jobs { shift->_new_resource('Jobs') }
sub _build_ldap { shift->_new_resource('LDAP') }
sub _build_logs { shift->_new_resource('Logs') }
sub _build_oauth { shift->_new_resource('OAuth') }
sub _build_plugin { shift->_new_resource('Plugin', 'plugins') }
sub _build_plugins { shift->_new_resource('Plugins') }
sub _build_post { shift->_new_resource('Post', 'posts') }
sub _build_posts { shift->_new_resource('Posts') }
sub _build_reactions { shift->_new_resource('Reactions') }
sub _build_roles { shift->_new_resource('Roles') }
sub _build_s3 { shift->_new_resource('S3', 'file') }
sub _build_saml { shift->_new_resource('SAML') }
sub _build_schemes { shift->_new_resource('Schemes') }
sub _build_system { shift->_new_resource('System') }
sub _build_team { shift->_new_resource('Team', 'teams') }
sub _build_teams { shift->_new_resource('Teams') }
sub _build_user { shift->_new_resource('User', 'users') }
sub _build_users { shift->_new_resource('Users') }
sub _build_webhooks { shift->_new_resource('Webhook', 'hooks') }
sub _build_webrtc { shift->_new_resource('WebRTC') }
sub _build_analytics { shift->_new_resource('Analytics') }
sub _build_application { shift->_new_resource('OAuth::Application', 'oauth') }
sub _build_audits { shift->_new_resource('Audits') }
sub _build_brand { shift->_new_resource('Brand') }
sub _build_cache { shift->_new_resource('Cache', 'caches') }
sub _build_channel { shift->_new_resource('Channel', 'channels') }
sub _build_channel_member { shift->_new_resource('Channel::Member', 'channels') }
sub _build_channels { shift->_new_resource('Channels') }
sub _build_cluster { shift->_new_resource('Cluster') }
sub _build_compliance { shift->_new_resource('Compliance') }
sub _build_compliance_report { shift->_new_resource('Compliance::Report', 'compliance') }
sub _build_config { shift->_new_resource('Config') }
sub _build_data_retention { shift->_new_resource('DataRetention', 'data_retention') }
sub _build_database { shift->_new_resource('Database') }
sub _build_elasticsearch { shift->_new_resource('ElasticSearch') }
sub _build_email { shift->_new_resource('Email') }
sub _build_emoji { shift->_new_resource('Emoji') }
sub _build_files { shift->_new_resource('Files', 'files') }
sub _build_file { shift->_new_resource('File', 'files') }
sub _build_jobs { shift->_new_resource('Jobs') }
sub _build_ldap { shift->_new_resource('LDAP') }
sub _build_logs { shift->_new_resource('Logs') }
sub _build_oauth { shift->_new_resource('OAuth') }
sub _build_plugin { shift->_new_resource('Plugin', 'plugins') }
sub _build_plugins { shift->_new_resource('Plugins') }
sub _build_post { shift->_new_resource('Post', 'posts') }
sub _build_posts { shift->_new_resource('Posts') }
sub _build_reactions { shift->_new_resource('Reactions') }
sub _build_roles { shift->_new_resource('Roles') }
sub _build_s3 { shift->_new_resource('S3', 'file') }
sub _build_saml { shift->_new_resource('SAML') }
sub _build_schemes { shift->_new_resource('Schemes') }
sub _build_system { shift->_new_resource('System') }
sub _build_team { shift->_new_resource('Team', 'teams') }
sub _build_teams { shift->_new_resource('Teams') }
sub _build_user { shift->_new_resource('User', 'users') }
sub _build_users { shift->_new_resource('Users') }
sub _build_webhooks { shift->_new_resource('Webhook', 'hooks') }
sub _build_webrtc { shift->_new_resource('WebRTC') }
################################################################################
......@@ -232,6 +235,10 @@ See C<WebService::Mattermost::V4::API::Resource::Config>.
See C<WebService::Mattermost::V4::API::Resource::Compliance>.
=item C<compliance_report>
See C<WebService::Mattermost::V4::API::Resource::Compliance::Report>.
=item C<data_retention>
See C<WebService::Mattermost::V4::API::Resource::DataRetention>.
......
......@@ -5,6 +5,7 @@ use Types::Standard qw(Str InstanceOf Int Maybe);
extends 'WebService::Mattermost::V4::API::Object';
with qw(
WebService::Mattermost::V4::API::Object::Role::APIMethods
WebService::Mattermost::V4::API::Object::Role::ID
WebService::Mattermost::V4::API::Object::Role::Status
WebService::Mattermost::V4::API::Object::Role::CreatedAt
......@@ -23,6 +24,17 @@ has [ qw(
################################################################################
sub BUILD {
my $self = shift;
$self->api_resource_name('compliance_report');
$self->available_api_methods([ 'download' ]);
return 1;
}
################################################################################
sub _build_count {
my $self = shift;
......@@ -76,6 +88,17 @@ WebService::Mattermost::V4::API::Object::Compliance::Report
=head1 DESCRIPTION
See matching methods in C<WebService::Mattermost::V4::API::Resource::Compliance::Report>
for full documentation.
ID parameters are not required:
my $response = $mattermost->api->compliance_report->get('ID-HERE')->item->download();
Is the same as:
my $response = $mattermost->api->compliance_report->download('ID-HERE');
=head2 ATTRIBUTES
=over 4
......@@ -104,6 +127,8 @@ WebService::Mattermost::V4::API::Object::Compliance::Report
=over 4
=item C<WebService::Mattermost::V4::API::Resource::Compliance::Report>
=item C<WebService::Mattermost::V4::API::Object::Role::ID>
=item C<WebService::Mattermost::V4::API::Object::Role::Status>
......
......@@ -11,14 +11,6 @@ has view_name => (is => 'ro', isa => Str, default => 'Compliance::Report');
################################################################################
around [ qw(get_report_by_id download_report_by_id) ] => sub {
my $orig = shift;
my $self = shift;
my $id = shift;
return $self->validate_id($orig, $id, @_);
};
sub create_report {
my $self = shift;
......@@ -36,28 +28,6 @@ sub get_reports {
});
}
sub get_report_by_id {
my $self = shift;
my $id = shift;
return $self->_single_view_get({
view => 'Compliance::Report',
endpoint => 'reports/%s',
ids => [ $id ],
});
}
sub download_report_by_id {
my $self = shift;
my $id = shift;
return $self->_single_view_get({
view => 'Compliance::Report',
endpoint => 'reports/%s/download',
ids => [ $id ],
});
}
################################################################################
1;
......@@ -102,18 +72,6 @@ Get all compliance reports.
per_page => 60,
});
=item C<get_report_by_id()>
Get a compliance report by its ID.
my $response = $resource->get_report_by_id('REPORT-ID-HERE');
=item C<download_report_by_id()>
Download a compliance report by its ID.
my $response = $resource->download_report_by_id('REPORT-ID-HERE');
=back
=head1 SEE ALSO
......
package WebService::Mattermost::V4::API::Resource::Compliance::Report;
use Moo;
use Types::Standard 'Str';
extends 'WebService::Mattermost::V4::API::Resource';
################################################################################
has view_name => (is => 'ro', isa => Str, default => 'Compliance::Report');
################################################################################
around [ qw(get download) ] => sub {
my $orig = shift;
my $self = shift;
my $id = shift;
return $self->validate_id($orig, $id, @_);
};
sub get {
my $self = shift;
my $id = shift;
return $self->_single_view_get({
endpoint => 'reports/%s',
ids => [ $id ],
});
}
sub download {
my $self = shift;
my $id = shift;
return $self->_single_view_get({
view => 'Binary',
endpoint => 'reports/%s/download',
ids => [ $id ],
});
}
################################################################################
1;
__END__
=head1 NAME
WebService::Mattermost::V4::API::Resource::Compliance::Report
=head1 DESCRIPTION
=head2 USAGE
use WebService::Mattermost;
my $mm = WebService::Mattermost->new({
authenticate => 1,
username => 'me@somewhere.com',
password => 'hunter2',
base_url => 'https://my.mattermost.server.com/api/v4/',
});
my $resource = $mm->api->compliance_report;
=head2 METHODS
=over 4
=item C<get()>
Get a compliance report by its ID.
my $response = $resource->get('REPORT-ID-HERE');
=item C<download()>
Download a compliance report by its ID.
my $response = $resource->download('REPORT-ID-HERE');
=back
=head1 SEE ALSO
=over 4
=item L<Official compliance documentation|https://api.mattermost.com/#tag/compliance>
=back
=head1 AUTHOR
Mike Jones L<email:mike@netsplit.org.uk>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment