Search in sources :

Example 11 with ApiParam

use of io.swagger.annotations.ApiParam in project smarthome by eclipse.

the class TemplateResource method getAll.

@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(value = "Get all available templates.", response = Template.class, responseContainer = "Collection")
@ApiResponses(value = { @ApiResponse(code = 200, message = "OK", response = Template.class, responseContainer = "Collection") })
public Response getAll(@HeaderParam("Accept-Language") @ApiParam(value = "language") String language) {
    Locale locale = LocaleUtil.getLocale(language);
    Collection<RuleTemplateDTO> result = templateRegistry.getAll(locale).stream().map(template -> RuleTemplateDTOMapper.map(template)).collect(Collectors.toList());
    return Response.ok(result).build();
}
Also used : Locale(java.util.Locale) PathParam(javax.ws.rs.PathParam) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Path(javax.ws.rs.Path) ApiParam(io.swagger.annotations.ApiParam) ApiResponses(io.swagger.annotations.ApiResponses) ApiOperation(io.swagger.annotations.ApiOperation) MediaType(javax.ws.rs.core.MediaType) RuleTemplateDTO(org.eclipse.smarthome.automation.dto.RuleTemplateDTO) Locale(java.util.Locale) RuleTemplateDTOMapper(org.eclipse.smarthome.automation.dto.RuleTemplateDTOMapper) HeaderParam(javax.ws.rs.HeaderParam) Api(io.swagger.annotations.Api) Status(javax.ws.rs.core.Response.Status) RESTResource(org.eclipse.smarthome.io.rest.RESTResource) Context(javax.ws.rs.core.Context) Collection(java.util.Collection) Collectors(java.util.stream.Collectors) RuleTemplate(org.eclipse.smarthome.automation.template.RuleTemplate) Template(org.eclipse.smarthome.automation.template.Template) TemplateRegistry(org.eclipse.smarthome.automation.template.TemplateRegistry) Response(javax.ws.rs.core.Response) ApiResponse(io.swagger.annotations.ApiResponse) UriInfo(javax.ws.rs.core.UriInfo) LocaleUtil(org.eclipse.smarthome.io.rest.LocaleUtil) RuleTemplateDTO(org.eclipse.smarthome.automation.dto.RuleTemplateDTO) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 12 with ApiParam

use of io.swagger.annotations.ApiParam in project data-prep by Talend.

the class FolderService method list.

/**
 * Get folders. If parentId is supplied, it will be used as filter.
 *
 * @param parentId the parent folder id parameter
 * @return direct sub folders for the given id.
 */
// @formatter:off
@RequestMapping(value = "/folders", method = GET)
@ApiOperation(value = "List children folders of the parameter if null list root children.", notes = "List all child folders of the one as parameter")
@Timed
public Stream<Folder> list(@RequestParam(required = false) @ApiParam(value = "Parent id filter.") String parentId, @RequestParam(defaultValue = "lastModificationDate") @ApiParam(value = "Sort key (by name or date).") Sort sort, @RequestParam(defaultValue = "desc") @ApiParam(value = "Order for sort key (desc or asc).") Order order) {
    // @formatter:on
    Stream<Folder> children;
    if (parentId != null) {
        if (!folderRepository.exists(parentId)) {
            throw new TDPException(FOLDER_NOT_FOUND, build().put("id", parentId));
        }
        children = folderRepository.children(parentId);
    } else {
        // This will list all folders
        children = folderRepository.searchFolders("", false);
    }
    final AtomicInteger folderCount = new AtomicInteger();
    // update the number of preparations in each children
    children = children.peek(f -> {
        final long count = folderRepository.count(f.getId(), PREPARATION);
        f.setNbPreparations(count);
        folderCount.addAndGet(1);
    });
    LOGGER.info("Found {} children for parentId: {}", folderCount.get(), parentId);
    // sort the folders
    return children.sorted(getFolderComparator(sort, order));
}
Also used : TDPException(org.talend.dataprep.exception.TDPException) PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) TDPException(org.talend.dataprep.exception.TDPException) PREPARATION(org.talend.dataprep.api.folder.FolderContentType.PREPARATION) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ApiParam(io.swagger.annotations.ApiParam) FOLDER_NOT_FOUND(org.talend.dataprep.exception.error.FolderErrorCodes.FOLDER_NOT_FOUND) GET(org.springframework.web.bind.annotation.RequestMethod.GET) RequestBody(org.springframework.web.bind.annotation.RequestBody) ApiOperation(io.swagger.annotations.ApiOperation) ExceptionContext.build(org.talend.daikon.exception.ExceptionContext.build) ExceptionContext(org.talend.daikon.exception.ExceptionContext) Folder(org.talend.dataprep.api.folder.Folder) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) StreamSupport(java.util.stream.StreamSupport) Api(io.swagger.annotations.Api) FolderRepository(org.talend.dataprep.folder.store.FolderRepository) SortAndOrderHelper.getFolderComparator(org.talend.dataprep.util.SortAndOrderHelper.getFolderComparator) Logger(org.slf4j.Logger) DELETE(org.springframework.web.bind.annotation.RequestMethod.DELETE) Order(org.talend.dataprep.util.SortAndOrderHelper.Order) HttpResponseContext(org.talend.dataprep.http.HttpResponseContext) Sort(org.talend.dataprep.util.SortAndOrderHelper.Sort) FolderTreeNode(org.talend.dataprep.api.folder.FolderTreeNode) RestController(org.springframework.web.bind.annotation.RestController) HttpStatus(org.springframework.http.HttpStatus) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) Stream(java.util.stream.Stream) Security(org.talend.dataprep.security.Security) Timed(org.talend.dataprep.metrics.Timed) FolderInfo(org.talend.dataprep.api.folder.FolderInfo) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Folder(org.talend.dataprep.api.folder.Folder) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 13 with ApiParam

use of io.swagger.annotations.ApiParam in project data-prep by Talend.

the class DataSetService method preview.

/**
 * Returns preview of the the data set content for given id (first 100 rows). Service might return
 * {@link org.apache.http.HttpStatus#SC_ACCEPTED} if the data set exists but analysis is not yet fully
 * completed so content is not yet ready to be served.
 *
 * @param metadata If <code>true</code>, includes data set metadata information.
 * @param sheetName the sheet name to preview
 * @param dataSetId A data set id.
 */
@RequestMapping(value = "/datasets/{id}/preview", method = RequestMethod.GET)
@ApiOperation(value = "Get a data preview set by id", notes = "Get a data set preview content based on provided id. Not valid or non existing data set id returns empty content. Data set not in drat status will return a redirect 301")
@Timed
@ResponseBody
public DataSet preview(@RequestParam(defaultValue = "true") @ApiParam(name = "metadata", value = "Include metadata information in the response") boolean metadata, @RequestParam(defaultValue = "") @ApiParam(name = "sheetName", value = "Sheet name to preview") String sheetName, @PathVariable(value = "id") @ApiParam(name = "id", value = "Id of the requested data set") String dataSetId) {
    DataSetMetadata dataSetMetadata = dataSetMetadataRepository.get(dataSetId);
    if (dataSetMetadata == null) {
        HttpResponseContext.status(HttpStatus.NO_CONTENT);
        // No data set, returns empty content.
        return DataSet.empty();
    }
    if (!dataSetMetadata.isDraft()) {
        // Moved to get data set content operation
        HttpResponseContext.status(HttpStatus.MOVED_PERMANENTLY);
        HttpResponseContext.header("Location", "/datasets/" + dataSetId + "/content");
        // dataset not anymore a draft so preview doesn't make sense.
        return DataSet.empty();
    }
    if (StringUtils.isNotEmpty(sheetName)) {
        dataSetMetadata.setSheetName(sheetName);
    }
    // take care of previous data without schema parser result
    if (dataSetMetadata.getSchemaParserResult() != null) {
        // sheet not yet set correctly so use the first one
        if (StringUtils.isEmpty(dataSetMetadata.getSheetName())) {
            String theSheetName = dataSetMetadata.getSchemaParserResult().getSheetContents().get(0).getName();
            LOG.debug("preview for dataSetMetadata: {} with sheetName: {}", dataSetId, theSheetName);
            dataSetMetadata.setSheetName(theSheetName);
        }
        String theSheetName = dataSetMetadata.getSheetName();
        Optional<Schema.SheetContent> sheetContentFound = dataSetMetadata.getSchemaParserResult().getSheetContents().stream().filter(sheetContent -> theSheetName.equals(sheetContent.getName())).findFirst();
        if (!sheetContentFound.isPresent()) {
            HttpResponseContext.status(HttpStatus.NO_CONTENT);
            // No sheet found, returns empty content.
            return DataSet.empty();
        }
        List<ColumnMetadata> columnMetadatas = sheetContentFound.get().getColumnMetadatas();
        if (dataSetMetadata.getRowMetadata() == null) {
            dataSetMetadata.setRowMetadata(new RowMetadata(emptyList()));
        }
        dataSetMetadata.getRowMetadata().setColumns(columnMetadatas);
    } else {
        LOG.warn("dataset#{} has draft status but any SchemaParserResult");
    }
    // Build the result
    DataSet dataSet = new DataSet();
    if (metadata) {
        dataSet.setMetadata(conversionService.convert(dataSetMetadata, UserDataSetMetadata.class));
    }
    dataSet.setRecords(contentStore.stream(dataSetMetadata).limit(100));
    return dataSet;
}
Also used : VolumeMetered(org.talend.dataprep.metrics.VolumeMetered) RequestParam(org.springframework.web.bind.annotation.RequestParam) ImportBuilder(org.talend.dataprep.api.dataset.Import.ImportBuilder) FormatFamilyFactory(org.talend.dataprep.schema.FormatFamilyFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ApiParam(io.swagger.annotations.ApiParam) StringUtils(org.apache.commons.lang3.StringUtils) TEXT_PLAIN_VALUE(org.springframework.http.MediaType.TEXT_PLAIN_VALUE) SortAndOrderHelper.getDataSetMetadataComparator(org.talend.dataprep.util.SortAndOrderHelper.getDataSetMetadataComparator) Collections.singletonList(java.util.Collections.singletonList) SemanticDomain(org.talend.dataprep.api.dataset.statistics.SemanticDomain) BeanConversionService(org.talend.dataprep.conversions.BeanConversionService) PipedInputStream(java.io.PipedInputStream) DistributedLock(org.talend.dataprep.lock.DistributedLock) Arrays.asList(java.util.Arrays.asList) Map(java.util.Map) DataprepBundle.message(org.talend.dataprep.i18n.DataprepBundle.message) UserData(org.talend.dataprep.api.user.UserData) TaskExecutor(org.springframework.core.task.TaskExecutor) MAX_STORAGE_MAY_BE_EXCEEDED(org.talend.dataprep.exception.error.DataSetErrorCodes.MAX_STORAGE_MAY_BE_EXCEEDED) DataSet(org.talend.dataprep.api.dataset.DataSet) LocalStoreLocation(org.talend.dataprep.api.dataset.location.LocalStoreLocation) FormatFamily(org.talend.dataprep.schema.FormatFamily) Resource(javax.annotation.Resource) Set(java.util.Set) DatasetUpdatedEvent(org.talend.dataprep.dataset.event.DatasetUpdatedEvent) RestController(org.springframework.web.bind.annotation.RestController) QuotaService(org.talend.dataprep.dataset.store.QuotaService) Stream(java.util.stream.Stream) StreamSupport.stream(java.util.stream.StreamSupport.stream) FlagNames(org.talend.dataprep.api.dataset.row.FlagNames) UNEXPECTED_CONTENT(org.talend.dataprep.exception.error.CommonErrorCodes.UNEXPECTED_CONTENT) Analyzers(org.talend.dataquality.common.inference.Analyzers) DataSetLocatorService(org.talend.dataprep.api.dataset.location.locator.DataSetLocatorService) Callable(java.util.concurrent.Callable) Schema(org.talend.dataprep.schema.Schema) ArrayList(java.util.ArrayList) Value(org.springframework.beans.factory.annotation.Value) RequestBody(org.springframework.web.bind.annotation.RequestBody) DataSetLocationService(org.talend.dataprep.api.dataset.location.DataSetLocationService) AnalyzerService(org.talend.dataprep.quality.AnalyzerService) UserDataRepository(org.talend.dataprep.user.store.UserDataRepository) Markers(org.talend.dataprep.log.Markers) Api(io.swagger.annotations.Api) DraftValidator(org.talend.dataprep.schema.DraftValidator) HttpResponseContext(org.talend.dataprep.http.HttpResponseContext) Sort(org.talend.dataprep.util.SortAndOrderHelper.Sort) IOException(java.io.IOException) PipedOutputStream(java.io.PipedOutputStream) FormatAnalysis(org.talend.dataprep.dataset.service.analysis.synchronous.FormatAnalysis) ContentAnalysis(org.talend.dataprep.dataset.service.analysis.synchronous.ContentAnalysis) SchemaAnalysis(org.talend.dataprep.dataset.service.analysis.synchronous.SchemaAnalysis) HttpStatus(org.springframework.http.HttpStatus) FilterService(org.talend.dataprep.api.filter.FilterService) Marker(org.slf4j.Marker) NullOutputStream(org.apache.commons.io.output.NullOutputStream) StatisticsAdapter(org.talend.dataprep.dataset.StatisticsAdapter) Timed(org.talend.dataprep.metrics.Timed) ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) PathVariable(org.springframework.web.bind.annotation.PathVariable) DataSetMetadataBuilder(org.talend.dataprep.dataset.DataSetMetadataBuilder) URLDecoder(java.net.URLDecoder) DataSetErrorCodes(org.talend.dataprep.exception.error.DataSetErrorCodes) PUT(org.springframework.web.bind.annotation.RequestMethod.PUT) LoggerFactory(org.slf4j.LoggerFactory) SEMANTIC(org.talend.dataprep.quality.AnalyzerService.Analysis.SEMANTIC) ApiOperation(io.swagger.annotations.ApiOperation) UNABLE_TO_CREATE_OR_UPDATE_DATASET(org.talend.dataprep.exception.error.DataSetErrorCodes.UNABLE_TO_CREATE_OR_UPDATE_DATASET) DataSetRow(org.talend.dataprep.api.dataset.row.DataSetRow) StrictlyBoundedInputStream(org.talend.dataprep.dataset.store.content.StrictlyBoundedInputStream) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) UNSUPPORTED_CONTENT(org.talend.dataprep.exception.error.DataSetErrorCodes.UNSUPPORTED_CONTENT) TimeToLive(org.talend.dataprep.cache.ContentCache.TimeToLive) Order(org.talend.dataprep.util.SortAndOrderHelper.Order) Collections.emptyList(java.util.Collections.emptyList) PublicAPI(org.talend.dataprep.security.PublicAPI) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) UUID(java.util.UUID) Collectors(java.util.stream.Collectors) ContentCache(org.talend.dataprep.cache.ContentCache) INVALID_DATASET_NAME(org.talend.dataprep.exception.error.DataSetErrorCodes.INVALID_DATASET_NAME) List(java.util.List) Optional(java.util.Optional) Analyzer(org.talend.dataquality.common.inference.Analyzer) RequestHeader(org.springframework.web.bind.annotation.RequestHeader) Pattern(java.util.regex.Pattern) Security(org.talend.dataprep.security.Security) Spliterator(java.util.Spliterator) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) ComponentProperties(org.talend.dataprep.parameters.jsonschema.ComponentProperties) TDPException(org.talend.dataprep.exception.TDPException) JsonErrorCodeDescription(org.talend.dataprep.exception.json.JsonErrorCodeDescription) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) UNABLE_CREATE_DATASET(org.talend.dataprep.exception.error.DataSetErrorCodes.UNABLE_CREATE_DATASET) HashMap(java.util.HashMap) GET(org.springframework.web.bind.annotation.RequestMethod.GET) Import(org.talend.dataprep.api.dataset.Import) ExceptionContext.build(org.talend.daikon.exception.ExceptionContext.build) ExceptionContext(org.talend.daikon.exception.ExceptionContext) Charset(java.nio.charset.Charset) UpdateColumnParameters(org.talend.dataprep.dataset.service.api.UpdateColumnParameters) VersionService(org.talend.dataprep.api.service.info.VersionService) POST(org.springframework.web.bind.annotation.RequestMethod.POST) OutputStream(java.io.OutputStream) DataSetLocation(org.talend.dataprep.api.dataset.DataSetLocation) Logger(org.slf4j.Logger) LocaleContextHolder.getLocale(org.springframework.context.i18n.LocaleContextHolder.getLocale) UpdateDataSetCacheKey(org.talend.dataprep.dataset.service.cache.UpdateDataSetCacheKey) IOUtils(org.apache.commons.compress.utils.IOUtils) APPLICATION_JSON_VALUE(org.springframework.http.MediaType.APPLICATION_JSON_VALUE) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) Certification(org.talend.dataprep.api.dataset.DataSetGovernance.Certification) EncodingSupport(org.talend.dataprep.configuration.EncodingSupport) Comparator(java.util.Comparator) InputStream(java.io.InputStream) ColumnMetadata(org.talend.dataprep.api.dataset.ColumnMetadata) DataSet(org.talend.dataprep.api.dataset.DataSet) RowMetadata(org.talend.dataprep.api.dataset.RowMetadata) DataSetMetadata(org.talend.dataprep.api.dataset.DataSetMetadata) Timed(org.talend.dataprep.metrics.Timed) ApiOperation(io.swagger.annotations.ApiOperation) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) ResponseBody(org.springframework.web.bind.annotation.ResponseBody)

Example 14 with ApiParam

use of io.swagger.annotations.ApiParam in project candlepin by candlepin.

the class OwnerResource method listPools.

/**
 * Retrieves a list of Pools for an Owner
 *
 * @param ownerKey id of the owner whose entitlement pools are sought.
 * @param matches Find pools matching the given pattern in a variety of fields.
 * * and ? wildcards are supported.
 * @return a list of Pool objects
 * @httpcode 400
 * @httpcode 404
 * @httpcode 200
 */
@GET
@Produces(MediaType.APPLICATION_JSON)
@Path("{owner_key}/pools")
@SuppressWarnings("checkstyle:indentation")
@ApiOperation(notes = "Retrieves a list of Pools for an Owner", value = "List Pools")
@ApiResponses({ @ApiResponse(code = 404, message = "Owner not found"), @ApiResponse(code = 400, message = "Invalid request") })
public List<PoolDTO> listPools(@PathParam("owner_key") @Verify(value = Owner.class, subResource = SubResource.POOLS) String ownerKey, @QueryParam("consumer") String consumerUuid, @QueryParam("activation_key") String activationKeyName, @QueryParam("product") String productId, @QueryParam("subscription") String subscriptionId, @ApiParam("Include pools that are not suited to the unit's facts.") @QueryParam("listall") @DefaultValue("false") boolean listAll, @ApiParam("Date to use as current time for lookup criteria. Defaults" + " to current date if not specified.") @QueryParam("activeon") @DefaultValue(DateFormat.NOW) @DateFormat Date activeOn, @ApiParam("Find pools matching the given pattern in a variety of fields;" + " * and ? wildcards are supported; may be specified multiple times") @QueryParam("matches") List<String> matches, @ApiParam("The attributes to return based on the specified types.") @QueryParam("attribute") @CandlepinParam(type = KeyValueParameter.class) List<KeyValueParameter> attrFilters, @ApiParam("When set to true, it will add future dated pools to the result, " + "based on the activeon date.") @QueryParam("add_future") @DefaultValue("false") boolean addFuture, @ApiParam("When set to true, it will return only future dated pools to the result, " + "based on the activeon date.") @QueryParam("only_future") @DefaultValue("false") boolean onlyFuture, @ApiParam("Will only return pools with a start date after the supplied date. " + "Overrides the activeOn date.") @QueryParam("after") @DateFormat Date after, @ApiParam("One or more pool IDs to use to filter the output; only pools with IDs matching " + "those provided will be returned; may be specified multiple times") @QueryParam("poolid") List<String> poolIds, @Context Principal principal, @Context PageRequest pageRequest) {
    Owner owner = findOwnerByKey(ownerKey);
    Consumer c = null;
    if (consumerUuid != null) {
        c = consumerCurator.findByUuid(consumerUuid);
        if (c == null) {
            throw new NotFoundException(i18n.tr("Unit: {0} not found", consumerUuid));
        }
        if (!c.getOwnerId().equals(owner.getId())) {
            throw new BadRequestException("Consumer specified does not belong to owner on path");
        }
        if (!principal.canAccess(c, SubResource.NONE, Access.READ_ONLY)) {
            throw new ForbiddenException(i18n.tr("User {0} cannot access consumer {1}", principal.getPrincipalName(), c.getUuid()));
        }
    }
    ActivationKey key = null;
    if (activationKeyName != null) {
        key = activationKeyCurator.lookupForOwner(activationKeyName, owner);
        if (key == null) {
            throw new BadRequestException(i18n.tr("ActivationKey with id {0} could not be found.", activationKeyName));
        }
    }
    if (addFuture && onlyFuture) {
        throw new BadRequestException(i18n.tr("The flags add_future and only_future cannot be used at the same time."));
    }
    if (after != null && (addFuture || onlyFuture)) {
        throw new BadRequestException(i18n.tr("The flags add_future and only_future cannot be used with the parameter after."));
    }
    if (after != null) {
        activeOn = null;
    }
    // Process the filters passed for the attributes
    PoolFilterBuilder poolFilters = new PoolFilterBuilder();
    for (KeyValueParameter filterParam : attrFilters) {
        poolFilters.addAttributeFilter(filterParam.key(), filterParam.value());
    }
    if (matches != null) {
        matches.stream().filter(elem -> elem != null && !elem.isEmpty()).forEach(elem -> poolFilters.addMatchesFilter(elem));
    }
    if (poolIds != null && !poolIds.isEmpty()) {
        poolFilters.addIdFilters(poolIds);
    }
    Page<List<Pool>> page = poolManager.listAvailableEntitlementPools(c, key, owner.getId(), productId, subscriptionId, activeOn, listAll, poolFilters, pageRequest, addFuture, onlyFuture, after);
    List<Pool> poolList = page.getPageData();
    calculatedAttributesUtil.setCalculatedAttributes(poolList, activeOn);
    calculatedAttributesUtil.setQuantityAttributes(poolList, c, activeOn);
    // Store the page for the LinkHeaderResponseFilter
    ResteasyProviderFactory.pushContext(Page.class, page);
    List<PoolDTO> poolDTOs = new ArrayList<>();
    for (Pool pool : poolList) {
        poolDTOs.add(translator.translate(pool, PoolDTO.class));
    }
    return poolDTOs;
}
Also used : StringUtils(org.apache.commons.lang.StringUtils) Arrays(java.util.Arrays) Produces(javax.ws.rs.Produces) ApiParam(io.swagger.annotations.ApiParam) CalculatedAttributesUtil(org.candlepin.resource.util.CalculatedAttributesUtil) EventSink(org.candlepin.audit.EventSink) MediaType(javax.ws.rs.core.MediaType) ImportRecordCurator(org.candlepin.model.ImportRecordCurator) PageRequest(org.candlepin.common.paging.PageRequest) ImporterException(org.candlepin.sync.ImporterException) ExporterMetadataCurator(org.candlepin.model.ExporterMetadataCurator) ActivationKeyCurator(org.candlepin.model.activationkeys.ActivationKeyCurator) ForbiddenException(org.candlepin.common.exceptions.ForbiddenException) DateFormat(org.candlepin.resteasy.DateFormat) HealEntireOrgJob(org.candlepin.pinsetter.tasks.HealEntireOrgJob) EventCurator(org.candlepin.model.EventCurator) Feed(org.jboss.resteasy.plugins.providers.atom.Feed) ActivationKeyDTO(org.candlepin.dto.api.v1.ActivationKeyDTO) SyncDataFormatException(org.candlepin.sync.SyncDataFormatException) ResourceMovedException(org.candlepin.common.exceptions.ResourceMovedException) UeberCertificateCurator(org.candlepin.model.UeberCertificateCurator) Set(java.util.Set) PoolManager(org.candlepin.controller.PoolManager) Access(org.candlepin.auth.Access) IseException(org.candlepin.common.exceptions.IseException) Type(org.candlepin.audit.Event.Type) OwnerServiceAdapter(org.candlepin.service.OwnerServiceAdapter) PoolDTO(org.candlepin.dto.api.v1.PoolDTO) Util(org.candlepin.util.Util) I18n(org.xnap.commons.i18n.I18n) Event(org.candlepin.audit.Event) Subscription(org.candlepin.model.dto.Subscription) GET(javax.ws.rs.GET) RefreshPoolsJob(org.candlepin.pinsetter.tasks.RefreshPoolsJob) KeyValueParameter(org.candlepin.resteasy.parameter.KeyValueParameter) ContentAccessCertServiceAdapter(org.candlepin.service.ContentAccessCertServiceAdapter) EventDTO(org.candlepin.dto.api.v1.EventDTO) ArrayList(java.util.ArrayList) ResteasyProviderFactory(org.jboss.resteasy.spi.ResteasyProviderFactory) Target(org.candlepin.audit.Event.Target) Entitlement(org.candlepin.model.Entitlement) StringTokenizer(java.util.StringTokenizer) Branding(org.candlepin.model.Branding) Api(io.swagger.annotations.Api) UpstreamConsumerDTO(org.candlepin.dto.api.v1.UpstreamConsumerDTO) UeberCertificateGenerator(org.candlepin.model.UeberCertificateGenerator) CandlepinException(org.candlepin.common.exceptions.CandlepinException) OwnerInfo(org.candlepin.model.OwnerInfo) ModelTranslator(org.candlepin.dto.ModelTranslator) ExporterMetadata(org.candlepin.model.ExporterMetadata) ServiceLevelValidator(org.candlepin.util.ServiceLevelValidator) Wrapped(org.jboss.resteasy.annotations.providers.jaxb.Wrapped) IOException(java.io.IOException) CandlepinQuery(org.candlepin.model.CandlepinQuery) File(java.io.File) EntitlementCurator(org.candlepin.model.EntitlementCurator) UndoImportsJob(org.candlepin.pinsetter.tasks.UndoImportsJob) CandlepinParam(org.candlepin.resteasy.parameter.CandlepinParam) ApiResponse(io.swagger.annotations.ApiResponse) ImportRecord(org.candlepin.model.ImportRecord) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) EnvironmentDTO(org.candlepin.dto.api.v1.EnvironmentDTO) Date(java.util.Date) Inject(com.google.inject.Inject) LoggerFactory(org.slf4j.LoggerFactory) Path(javax.ws.rs.Path) MultipartInput(org.jboss.resteasy.plugins.providers.multipart.MultipartInput) EntitlementFinderUtil(org.candlepin.resource.util.EntitlementFinderUtil) EntitlementFilterBuilder(org.candlepin.model.EntitlementFilterBuilder) ConflictOverrides(org.candlepin.sync.ConflictOverrides) ActivationKeyContentOverride(org.candlepin.model.activationkeys.ActivationKeyContentOverride) Transactional(com.google.inject.persist.Transactional) OwnerDTO(org.candlepin.dto.api.v1.OwnerDTO) ConflictException(org.candlepin.common.exceptions.ConflictException) ApiOperation(io.swagger.annotations.ApiOperation) InputPart(org.jboss.resteasy.plugins.providers.multipart.InputPart) QueryParam(javax.ws.rs.QueryParam) Consumes(javax.ws.rs.Consumes) ConsumerTypeCurator(org.candlepin.model.ConsumerTypeCurator) DefaultValue(javax.ws.rs.DefaultValue) ContentOverrideValidator(org.candlepin.util.ContentOverrideValidator) Product(org.candlepin.model.Product) DELETE(javax.ws.rs.DELETE) NotFoundException(org.candlepin.common.exceptions.NotFoundException) UpstreamConsumer(org.candlepin.model.UpstreamConsumer) Context(javax.ws.rs.core.Context) OwnerManager(org.candlepin.controller.OwnerManager) ConstraintViolationException(org.hibernate.exception.ConstraintViolationException) EventAdapter(org.candlepin.audit.EventAdapter) GenericType(org.jboss.resteasy.util.GenericType) Page(org.candlepin.common.paging.Page) OwnerCurator(org.candlepin.model.OwnerCurator) EntitlementDTO(org.candlepin.dto.api.v1.EntitlementDTO) OwnerProductCurator(org.candlepin.model.OwnerProductCurator) ManifestFileServiceException(org.candlepin.sync.file.ManifestFileServiceException) ConsumerCurator(org.candlepin.model.ConsumerCurator) List(java.util.List) PersistenceException(javax.persistence.PersistenceException) ProductCurator(org.candlepin.model.ProductCurator) SourceSubscription(org.candlepin.model.SourceSubscription) PathParam(javax.ws.rs.PathParam) ConsumerDTO(org.candlepin.dto.api.v1.ConsumerDTO) Release(org.candlepin.model.Release) Verify(org.candlepin.auth.Verify) ManifestManager(org.candlepin.controller.ManifestManager) ConsumerType(org.candlepin.model.ConsumerType) PoolFilterBuilder(org.candlepin.model.PoolFilterBuilder) ApiResponses(io.swagger.annotations.ApiResponses) ConfigProperties(org.candlepin.config.ConfigProperties) Pool(org.candlepin.model.Pool) UeberCertificate(org.candlepin.model.UeberCertificate) HashSet(java.util.HashSet) SubResource(org.candlepin.auth.SubResource) PoolType(org.candlepin.model.Pool.PoolType) Owner(org.candlepin.model.Owner) CollectionUtils(org.apache.commons.collections.CollectionUtils) BadRequestException(org.candlepin.common.exceptions.BadRequestException) BrandingDTO(org.candlepin.dto.api.v1.BrandingDTO) Environment(org.candlepin.model.Environment) Principal(org.candlepin.auth.Principal) LinkedList(java.util.LinkedList) Configuration(org.candlepin.common.config.Configuration) JobDetail(org.quartz.JobDetail) OwnerInfoCurator(org.candlepin.model.OwnerInfoCurator) ResolverUtil(org.candlepin.resource.util.ResolverUtil) Logger(org.slf4j.Logger) POST(javax.ws.rs.POST) EnvironmentCurator(org.candlepin.model.EnvironmentCurator) ConsumerTypeValidator(org.candlepin.resource.util.ConsumerTypeValidator) EventFactory(org.candlepin.audit.EventFactory) MultivaluedMap(javax.ws.rs.core.MultivaluedMap) ImportJob(org.candlepin.pinsetter.tasks.ImportJob) Level(ch.qos.logback.classic.Level) EntitlementCertificateCurator(org.candlepin.model.EntitlementCertificateCurator) PUT(javax.ws.rs.PUT) Consumer(org.candlepin.model.Consumer) Authorization(io.swagger.annotations.Authorization) Collections(java.util.Collections) ArrayUtils(org.apache.commons.lang.ArrayUtils) Owner(org.candlepin.model.Owner) ForbiddenException(org.candlepin.common.exceptions.ForbiddenException) ArrayList(java.util.ArrayList) NotFoundException(org.candlepin.common.exceptions.NotFoundException) PoolDTO(org.candlepin.dto.api.v1.PoolDTO) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) UpstreamConsumer(org.candlepin.model.UpstreamConsumer) Consumer(org.candlepin.model.Consumer) BadRequestException(org.candlepin.common.exceptions.BadRequestException) PoolFilterBuilder(org.candlepin.model.PoolFilterBuilder) KeyValueParameter(org.candlepin.resteasy.parameter.KeyValueParameter) ArrayList(java.util.ArrayList) List(java.util.List) LinkedList(java.util.LinkedList) Pool(org.candlepin.model.Pool) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) ApiOperation(io.swagger.annotations.ApiOperation) ApiResponses(io.swagger.annotations.ApiResponses)

Example 15 with ApiParam

use of io.swagger.annotations.ApiParam in project syndesis by syndesisio.

the class IntegrationHandler method putDeployment.

@PUT
@Produces(MediaType.APPLICATION_JSON)
@Path("/{id}/deployments")
public IntegrationDeployment putDeployment(@Context SecurityContext sec, @NotNull @PathParam("id") @ApiParam(required = true) String id) {
    Integration integration = getIntegration(id);
    int nextDeploymentVersion = 1;
    // Update previous deployments targetState=Undeployed and make sure nextDeploymentVersion is larger than all previous ones.
    Set<String> deploymentIds = getDataManager().fetchIdsByPropertyValue(IntegrationDeployment.class, "integrationId", id);
    if (deploymentIds != null && !deploymentIds.isEmpty()) {
        Stream<IntegrationDeployment> deployments = deploymentIds.stream().map(i -> getDataManager().fetch(IntegrationDeployment.class, i)).filter(r -> r != null);
        for (IntegrationDeployment d : deployments.toArray(IntegrationDeployment[]::new)) {
            nextDeploymentVersion = Math.max(nextDeploymentVersion, d.getVersion() + 1);
            getDataManager().update(d.withTargetState(IntegrationDeploymentState.Unpublished));
        }
    }
    IntegrationDeployment deployment = new IntegrationDeployment.Builder().id(IntegrationDeployment.compositeId(id, nextDeploymentVersion)).spec(integration).version(nextDeploymentVersion).userId(sec.getUserPrincipal().getName()).build();
    deployment = getDataManager().create(deployment);
    return deployment;
}
Also used : Produces(javax.ws.rs.Produces) Path(javax.ws.rs.Path) SecurityContext(javax.ws.rs.core.SecurityContext) ApiParam(io.swagger.annotations.ApiParam) SortOptionsFromQueryParams(io.syndesis.server.endpoint.v1.operations.SortOptionsFromQueryParams) PaginationFilter(io.syndesis.server.endpoint.util.PaginationFilter) MediaType(javax.ws.rs.core.MediaType) EncryptionComponent(io.syndesis.server.dao.manager.EncryptionComponent) Connection(io.syndesis.common.model.connection.Connection) IdPrefixFilter(io.syndesis.server.dao.manager.operators.IdPrefixFilter) IntegrationOverview(io.syndesis.common.model.integration.IntegrationOverview) Integration(io.syndesis.common.model.integration.Integration) AllValidations(io.syndesis.common.model.validation.AllValidations) Context(javax.ws.rs.core.Context) Set(java.util.Set) Validator(javax.validation.Validator) Connector(io.syndesis.common.model.connection.Connector) ListResult(io.syndesis.common.model.ListResult) Extension(io.syndesis.common.model.extension.Extension) NotNull(javax.validation.constraints.NotNull) Collectors(java.util.stream.Collectors) Updater(io.syndesis.server.endpoint.v1.operations.Updater) List(java.util.List) Stream(java.util.stream.Stream) PaginationOptionsFromQueryParams(io.syndesis.server.endpoint.v1.operations.PaginationOptionsFromQueryParams) DataManagerSupport(io.syndesis.server.endpoint.v1.util.DataManagerSupport) Optional(java.util.Optional) UriInfo(javax.ws.rs.core.UriInfo) IntegrationDeploymentState(io.syndesis.common.model.integration.IntegrationDeploymentState) ReflectiveSorter(io.syndesis.server.endpoint.util.ReflectiveSorter) ReverseFilter(io.syndesis.server.dao.manager.operators.ReverseFilter) Op(io.syndesis.common.model.filter.Op) PathParam(javax.ws.rs.PathParam) Creator(io.syndesis.server.endpoint.v1.operations.Creator) Action(io.syndesis.common.model.action.Action) GET(javax.ws.rs.GET) Step(io.syndesis.common.model.integration.Step) Kind(io.syndesis.common.model.Kind) IntegrationBulletinBoard(io.syndesis.common.model.bulletin.IntegrationBulletinBoard) Validating(io.syndesis.server.endpoint.v1.operations.Validating) ConvertGroup(javax.validation.groups.ConvertGroup) EntityNotFoundException(javax.persistence.EntityNotFoundException) FilterOptions(io.syndesis.common.model.filter.FilterOptions) DataManager(io.syndesis.server.dao.manager.DataManager) Api(io.swagger.annotations.Api) SuppressFBWarnings(io.syndesis.common.util.SuppressFBWarnings) IntegrationDeployment(io.syndesis.common.model.integration.IntegrationDeployment) Default(javax.validation.groups.Default) POST(javax.ws.rs.POST) IntegrationDeploymentOverview(io.syndesis.common.model.integration.IntegrationDeploymentOverview) Deleter(io.syndesis.server.endpoint.v1.operations.Deleter) DataShape(io.syndesis.common.model.DataShape) Getter(io.syndesis.server.endpoint.v1.operations.Getter) Lister(io.syndesis.server.endpoint.v1.operations.Lister) Component(org.springframework.stereotype.Component) Inspectors(io.syndesis.server.inspector.Inspectors) OpenShiftService(io.syndesis.server.openshift.OpenShiftService) PUT(javax.ws.rs.PUT) BaseHandler(io.syndesis.server.endpoint.v1.handler.BaseHandler) Integration(io.syndesis.common.model.integration.Integration) IntegrationDeployment(io.syndesis.common.model.integration.IntegrationDeployment) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT)

Aggregations

ApiParam (io.swagger.annotations.ApiParam)68 ApiOperation (io.swagger.annotations.ApiOperation)64 Api (io.swagger.annotations.Api)63 Path (javax.ws.rs.Path)56 ApiResponse (io.swagger.annotations.ApiResponse)51 PathParam (javax.ws.rs.PathParam)51 ApiResponses (io.swagger.annotations.ApiResponses)50 GET (javax.ws.rs.GET)50 List (java.util.List)49 Produces (javax.ws.rs.Produces)49 Response (javax.ws.rs.core.Response)49 Collectors (java.util.stream.Collectors)42 PUT (javax.ws.rs.PUT)42 Logger (org.slf4j.Logger)40 LoggerFactory (org.slf4j.LoggerFactory)40 POST (javax.ws.rs.POST)39 DELETE (javax.ws.rs.DELETE)38 Inject (javax.inject.Inject)37 MediaType (javax.ws.rs.core.MediaType)37 QueryParam (javax.ws.rs.QueryParam)36