Skip to content
Merged

#4025 #4328

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
43 commits
Select commit Hold shift + click to select a range
49daf3f
update
Stepan-Kirjakov Oct 10, 2024
c4c5935
[skip ci] Add swagger.yaml
envision-ci-agent Oct 10, 2024
0e63379
update
Stepan-Kirjakov Oct 11, 2024
2b63523
[skip ci] Add swagger.yaml
envision-ci-agent Oct 11, 2024
a1ec1ed
update
Stepan-Kirjakov Oct 14, 2024
2c257c1
Merge branch 'feature/4025' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Oct 14, 2024
d489ee4
update
Stepan-Kirjakov Oct 16, 2024
3f0c195
Merge branch 'develop' into feature/4025
Stepan-Kirjakov Oct 16, 2024
97e99c7
update
Stepan-Kirjakov Oct 17, 2024
b877bcb
update
Stepan-Kirjakov Oct 18, 2024
ba09ecb
update
Stepan-Kirjakov Oct 21, 2024
c14a15c
[skip ci] Add swagger.yaml
envision-ci-agent Oct 21, 2024
4cf8076
fix
Stepan-Kirjakov Oct 21, 2024
f6972f6
Merge branch 'feature/4025' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Oct 21, 2024
7174b59
fix
Stepan-Kirjakov Oct 21, 2024
ab54dd3
[skip ci] Add swagger.yaml
envision-ci-agent Oct 21, 2024
91bb0ae
update
Stepan-Kirjakov Oct 23, 2024
184bbe8
update
Stepan-Kirjakov Oct 23, 2024
f438e96
fix
Stepan-Kirjakov Oct 23, 2024
19d59f7
Merge branch 'feature/4025' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Oct 23, 2024
16e0f71
update
Stepan-Kirjakov Oct 24, 2024
e07be29
update
Stepan-Kirjakov Oct 24, 2024
6a4245d
Merge branch 'develop' into feature/4025
Stepan-Kirjakov Oct 24, 2024
114df70
update
Stepan-Kirjakov Oct 25, 2024
57c3d73
[skip ci] Add swagger.yaml
envision-ci-agent Oct 25, 2024
b51722b
fix
Stepan-Kirjakov Oct 25, 2024
ae930a3
Merge branch 'feature/4025' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Oct 25, 2024
abe4ae8
fix
Stepan-Kirjakov Oct 25, 2024
bc0f66e
update
Stepan-Kirjakov Oct 28, 2024
ed113f9
[skip ci] Add swagger.yaml
envision-ci-agent Oct 28, 2024
6707cb6
update
Stepan-Kirjakov Oct 28, 2024
40db981
Merge branch 'feature/4025' of github.com:hashgraph/guardian into fea…
Stepan-Kirjakov Oct 28, 2024
ed05135
update
Stepan-Kirjakov Oct 28, 2024
173bad0
fix
Stepan-Kirjakov Oct 29, 2024
480e565
fix
Stepan-Kirjakov Oct 29, 2024
a408885
fix
Stepan-Kirjakov Oct 29, 2024
f51e16d
update xlsx parser
Stepan-Kirjakov Oct 29, 2024
5754feb
fix
Stepan-Kirjakov Oct 30, 2024
46f646c
fix
Stepan-Kirjakov Oct 30, 2024
884c740
fix
Stepan-Kirjakov Oct 30, 2024
71554be
fix
Stepan-Kirjakov Oct 30, 2024
d6a8dc8
fix
Stepan-Kirjakov Oct 30, 2024
8fbb4dc
Merge branch 'develop' into feature/4025
Stepan-Kirjakov Oct 30, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
121 changes: 121 additions & 0 deletions api-gateway/src/api/service/policy-statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -605,4 +605,125 @@ export class PolicyStatisticsApi {
await InternalException(error, this.logger);
}
}

/**
* Import statistic definition
*/
@Post('/:policyId/import/file')
@Auth(Permissions.STATISTICS_STATISTIC_CREATE)
@ApiOperation({
summary: 'Imports new statistic definition from a zip file.',
description: 'Imports new statistic definition from the provided zip file into the local DB.',
})
@ApiParam({
name: 'policyId',
type: String,
description: 'Policy Id',
required: true,
example: Examples.DB_ID
})
@ApiBody({
description: 'A zip file containing statistic definition to be imported.',
required: true
})
@ApiOkResponse({
description: 'Successful operation.',
type: StatisticDefinitionDTO
})
@ApiInternalServerErrorResponse({
description: 'Internal server error.',
type: InternalServerErrorDTO
})
@ApiExtraModels(StatisticDefinitionDTO, InternalServerErrorDTO)
@HttpCode(HttpStatus.CREATED)
async importStatisticDefinition(
@AuthUser() user: IAuthUser,
@Param('policyId') policyId: string,
@Body() zip: any
): Promise<StatisticDefinitionDTO> {
const guardian = new Guardians();
try {
const owner = new EntityOwner(user);
return await guardian.importStatisticDefinition(zip, policyId, owner);
} catch (error) {
await InternalException(error, this.logger);
}
}

/**
* Export statistic definition
*/
@Get('/:definitionId/export/file')
@Auth(Permissions.STATISTICS_STATISTIC_READ)
@ApiOperation({
summary: 'Returns a zip file containing statistic definition.',
description: 'Returns a zip file containing statistic definition.',
})
@ApiParam({
name: 'definitionId',
type: String,
description: 'Statistic Definition Identifier',
required: true,
example: Examples.DB_ID
})
@ApiOkResponse({
description: 'Successful operation. Response zip file.'
})
@ApiInternalServerErrorResponse({
description: 'Internal server error.',
type: InternalServerErrorDTO
})
@ApiExtraModels(InternalServerErrorDTO)
@HttpCode(HttpStatus.OK)
async exportStatisticDefinition(
@AuthUser() user: IAuthUser,
@Param('definitionId') definitionId: string,
@Response() res: any
): Promise<any> {
const guardian = new Guardians();
try {
const owner = new EntityOwner(user);
const file: any = await guardian.exportStatisticDefinition(definitionId, owner);
res.header('Content-disposition', `attachment; filename=theme_${Date.now()}`);
res.header('Content-type', 'application/zip');
return res.send(file);
} catch (error) {
await InternalException(error, this.logger);
}
}

/**
* Preview statistic definition
*/
@Post('/import/file/preview')
@Auth(Permissions.STATISTICS_STATISTIC_CREATE)
@ApiOperation({
summary: 'Imports a zip file containing statistic definition.',
description: 'Imports a zip file containing statistic definition.',
})
@ApiBody({
description: 'File.',
})
@ApiOkResponse({
description: 'Statistic definition preview.',
type: StatisticDefinitionDTO
})
@ApiInternalServerErrorResponse({
description: 'Internal server error.',
type: InternalServerErrorDTO,
})
@ApiExtraModels(StatisticDefinitionDTO, InternalServerErrorDTO)
@HttpCode(HttpStatus.OK)
async previewStatisticDefinition(
@AuthUser() user: IAuthUser,
@Body() body: any
): Promise<any> {
try {
const owner = new EntityOwner(user);
const guardian = new Guardians();
return await guardian.previewStatisticDefinition(body, owner);
} catch (error) {
await InternalException(error, this.logger);
}
}
}
Loading