io.swagger.annotations.ResponseHeader Java Examples

The following examples show how to use io.swagger.annotations.ResponseHeader. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LicenseGroupResource.java    From dependency-track with Apache License 2.0 6 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Returns a list of all license groups",
        response = LicenseGroup.class,
        responseContainer = "List",
        responseHeaders = @ResponseHeader(name = TOTAL_COUNT_HEADER, response = Long.class, description = "The total number of license groups")
)
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Unauthorized")
})
@PermissionRequired(Permissions.Constants.POLICY_MANAGEMENT)
public Response getLicenseGroups() {
    try (QueryManager qm = new QueryManager(getAlpineRequest())) {
        final PaginatedResult result = qm.getLicenseGroups();
        return Response.ok(result.getObjects()).header(TOTAL_COUNT_HEADER, result.getTotal()).build();
    }
}
 
Example #2
Source File: RepositoryResource.java    From dependency-track with Apache License 2.0 6 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Returns a list of all repositories",
        response = Repository.class,
        responseContainer = "List",
        responseHeaders = @ResponseHeader(name = TOTAL_COUNT_HEADER, response = Long.class, description = "The total number of repositories")
)
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Unauthorized")
})
@PermissionRequired(Permissions.Constants.SYSTEM_CONFIGURATION)
public Response getRepositories() {
    try (QueryManager qm = new QueryManager(getAlpineRequest())) {
        final PaginatedResult result = qm.getRepositories();
        return Response.ok(result.getObjects()).header(TOTAL_COUNT_HEADER, result.getTotal()).build();
    }
}
 
Example #3
Source File: PolicyResource.java    From dependency-track with Apache License 2.0 6 votes vote down vote up
@GET
@Produces(MediaType.APPLICATION_JSON)
@ApiOperation(
        value = "Returns a list of all policies",
        response = Policy.class,
        responseContainer = "List",
        responseHeaders = @ResponseHeader(name = TOTAL_COUNT_HEADER, response = Long.class, description = "The total number of policies")
)
@ApiResponses(value = {
        @ApiResponse(code = 401, message = "Unauthorized")
})
@PermissionRequired(Permissions.Constants.POLICY_MANAGEMENT)
public Response getPolicies() {
    try (QueryManager qm = new QueryManager(getAlpineRequest())) {
        final PaginatedResult result = qm.getPolicies();
        return Response.ok(result.getObjects()).header(TOTAL_COUNT_HEADER, result.getTotal()).build();
    }
}
 
Example #4
Source File: CassandraMigrationRoutes.java    From james-project with Apache License 2.0 6 votes vote down vote up
@POST
@Path("upgrade/latest")
@ApiOperation("Triggers a migration of Cassandra schema to the latest available")
@ApiResponses({
    @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
        responseHeaders = {
            @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
        }),
    @ApiResponse(code = HttpStatus.CONFLICT_409, message = "Migration can not be done")
})
public Task upgradeToLatest() {
    try {
        return cassandraMigrationService.upgradeToLastVersion();
    } catch (IllegalStateException e) {
        LOGGER.info(MIGRATION_REQUEST_CAN_NOT_BE_DONE, e);
        throw ErrorResponder.builder()
            .statusCode(HttpStatus.CONFLICT_409)
            .type(ErrorType.WRONG_STATE)
            .message(MIGRATION_REQUEST_CAN_NOT_BE_DONE)
            .cause(e)
            .haltError();
    }
}
 
Example #5
Source File: DubboReaderExtension.java    From swagger-dubbo with Apache License 2.0 6 votes vote down vote up
private static Map<String, Property> parseResponseHeaders(ReaderContext context,
		ResponseHeader[] headers) {
	Map<String, Property> responseHeaders = null;
	for (ResponseHeader header : headers) {
		final String name = header.name();
		if (StringUtils.isNotEmpty(name)) {
			if (responseHeaders == null) {
				responseHeaders = new HashMap<String, Property>();
			}
			final Class<?> cls = header.response();
			if (!ReflectionUtils.isVoid(cls)) {
				final Property property = ModelConverters.getInstance().readAsProperty(cls);
				if (property != null) {
					final Property responseProperty = ContainerWrapper.wrapContainer(
							header.responseContainer(), property, ContainerWrapper.ARRAY,
							ContainerWrapper.LIST, ContainerWrapper.SET);
					responseProperty.setDescription(header.description());
					responseHeaders.put(name, responseProperty);
					appendModels(context.getSwagger(), cls);
				}
			}
		}
	}
	return responseHeaders;
}
 
Example #6
Source File: IRestExportService.java    From EDDI with Apache License 2.0 5 votes vote down vote up
@POST
@Path("{botId}")
@ApiResponse(code = 200, responseHeaders = {
        @ResponseHeader(name = "location", response = URI.class)
}, message = "returns location of the exported ZIP file to be downloaded")
Response exportBot(@PathParam("botId") String botId,
                   @ApiParam(name = "botVersion", required = true, format = "integer", example = "1")
                   @QueryParam("botVersion") @DefaultValue("1") Integer botVersion);
 
Example #7
Source File: Reader.java    From dorado with Apache License 2.0 5 votes vote down vote up
private Map<String, Property> parseResponseHeaders(ResponseHeader[] headers, JsonView jsonView) {
	Map<String, Property> responseHeaders = null;
	if (headers != null) {
		for (ResponseHeader header : headers) {
			String name = header.name();
			if (!"".equals(name)) {
				if (responseHeaders == null) {
					responseHeaders = new LinkedHashMap<String, Property>();
				}
				String description = header.description();
				Class<?> cls = header.response();

				if (!isVoid(cls)) {
					final Property property = ModelConverters.getInstance().readAsProperty(cls, jsonView);
					if (property != null) {
						Property responseProperty = ContainerWrapper.wrapContainer(header.responseContainer(),
								property, ContainerWrapper.ARRAY, ContainerWrapper.LIST, ContainerWrapper.SET);
						responseProperty.setDescription(description);
						responseHeaders.put(name, responseProperty);
						appendModels(cls);
					}
				}
			}
		}
	}
	return responseHeaders;
}
 
Example #8
Source File: CassandraMigrationRoutes.java    From james-project with Apache License 2.0 5 votes vote down vote up
@POST
@Path("upgrade")
@ApiOperation("Triggers a migration of Cassandra schema to a specific version")
@ApiImplicitParams({
    @ApiImplicitParam(
        required = true,
        paramType = "body",
        dataType = "Integer",
        example = "3",
        value = "The schema version to upgrade to.")
})
@ApiResponses({
    @ApiResponse(code = HttpStatus.CREATED_201, message = "The taskId of the given scheduled task", response = TaskIdDto.class,
        responseHeaders = {
        @ResponseHeader(name = "Location", description = "URL of the resource associated with the scheduled task")
    }),
    @ApiResponse(code = HttpStatus.CONFLICT_409, message = "Migration can not be done")
})
public Task upgradeToVersion(Request request) {
    LOGGER.debug("Cassandra upgrade launched");
    CassandraVersionRequest cassandraVersionRequest = CassandraVersionRequest.parse(request.body());
    return cassandraMigrationService.upgradeToVersion(cassandraVersionRequest.getValue());
}
 
Example #9
Source File: CodeFirstSpringmvcSimplifiedMappingAnnotation.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
    @ResponseHeader(name = "h2", response = String.class)})
@GetMapping(path = "/cseResponse")
@Override
public Response cseResponse(InvocationContext c1) {
  return super.cseResponse(c1);
}
 
Example #10
Source File: CodeFirstSpringmvc.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
    @ResponseHeader(name = "h2", response = String.class)})
@RequestMapping(path = "/responseEntity", method = RequestMethod.POST, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
@Override
public ResponseEntity<Date> responseEntity(InvocationContext c1, @RequestAttribute("date") Date date) {
  return super.responseEntity(c1, date);
}
 
Example #11
Source File: CodeFirstSpringmvc.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@ApiResponse(code = 200, response = User.class, message = "")
@ResponseHeaders({@ResponseHeader(name = "h1", response = String.class),
    @ResponseHeader(name = "h2", response = String.class)})
@RequestMapping(path = "/cseResponse", method = RequestMethod.GET)
@Override
public Response cseResponse(InvocationContext c1) {
  return super.cseResponse(c1);
}
 
Example #12
Source File: ShoppingListApi.java    From commerce-cif-api with Apache License 2.0 5 votes vote down vote up
@POST
@Path("/{id}/entries")
@ApiOperation(value = "Creates a new entry for a shopping list.")
@ApiResponses(value = {
    @ApiResponse(code = HTTP_CREATED, message = HTTP_CREATED_MESSAGE, response = ShoppingList.class,
                 responseHeaders = @ResponseHeader(name = "Location", description = "Location of the newly created entry.", response = String.class)),
    @ApiResponse(code = HTTP_BAD_REQUEST, message = HTTP_BAD_REQUEST_MESSAGE, response = ErrorResponse.class),
    @ApiResponse(code = HTTP_UNAUTHORIZED, message = HTTP_UNAUTHORIZED_MESSAGE, response = ErrorResponse.class),
    @ApiResponse(code = HTTP_NOT_FOUND, message = HTTP_NOT_FOUND_MESSAGE, response = ErrorResponse.class)
})
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
ShoppingListEntry postShoppingListEntry(
    @ApiParam(value = "The id of the shopping list.", required = true)
    @PathParam("id")
    String id,

    @ApiParam(value = "The quantity for the new entry.", required = true)
    @FormParam("quantity")
    @Min(value = 0)
    int quantity,

    @ApiParam(value = "The product variant id to be added to the entry. If the product variant exists in the shopping list, its quantity is increased with the provided quantity.", required = true)
    @FormParam("productVariantId")
    String productVariantId,

    @ApiParam(value = ACCEPT_LANGUAGE_DESC)
    @HeaderParam(ACCEPT_LANGUAGE) String acceptLanguage
);
 
Example #13
Source File: ExtendedSwaggerReader.java    From msf4j with Apache License 2.0 5 votes vote down vote up
private Map<String, Property> parseResponseHeaders(ResponseHeader[] headers) {
    Map<String, Property> responseHeaders = null;
    if (headers != null && headers.length > 0) {
        for (ResponseHeader header : headers) {
            String name = header.name();
            if (!"".equals(name)) {
                if (responseHeaders == null) {
                    responseHeaders = new HashMap<>();
                }
                String description = header.description();
                Class<?> cls = header.response();

                if (!isVoid(cls)) {
                    final Property property = ModelConverters.getInstance().readAsProperty(cls);
                    if (property != null) {
                        Property responseProperty = ContainerWrapper
                                .wrapContainer(header.responseContainer(), property, ContainerWrapper.ARRAY,
                                               ContainerWrapper.LIST, ContainerWrapper.SET);
                        responseProperty.setDescription(description);
                        responseHeaders.put(name, responseProperty);
                        appendModels(cls);
                    }
                }
            }
        }
    }
    return responseHeaders;
}
 
Example #14
Source File: ResponseHeadersProcessor.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
public void process(SwaggerGenerator swaggerGenerator, OperationGenerator operationGenerator,
    ResponseHeaders responseHeaders) {
  MethodAnnotationProcessor<ResponseHeader> processor = findMethodAnnotationProcessor(ResponseHeader.class);
  for (ResponseHeader responseHeader : responseHeaders.value()) {
    processor.process(swaggerGenerator, operationGenerator, responseHeader);
  }
}
 
Example #15
Source File: ResponseConfig.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
public void setResponseHeaders(ResponseHeader[] responseHeaders) {
  this.responseHeaders = new ArrayList<>();
  for (ResponseHeader header : responseHeaders) {
    ResponseHeaderConfig config = AnnotationUtils.convert(header);
    if (config != null) {
      this.responseHeaders.add(config);
    }
  }

  if (this.responseHeaders.isEmpty()) {
    this.responseHeaders = null;
  }
}
 
Example #16
Source File: FilesResource.java    From hmdm-server with Apache License 2.0 5 votes vote down vote up
@ApiOperation(
        value = "Download a file",
        notes = "Downloads the content of the file",
        responseHeaders = {@ResponseHeader(name = "Content-Disposition")}
)
@GET
@Path("/{filePath}")
@Produces(MediaType.APPLICATION_OCTET_STREAM)
public javax.ws.rs.core.Response downloadFile(@PathParam("filePath") @ApiParam("A path to a file") String filePath) throws Exception {
    File file = new File(filePath + "/" + URLDecoder.decode(filePath, "UTF8"));
    if (!file.exists()) {
        return javax.ws.rs.core.Response.status(404).build();
    } else {
        ContentDisposition contentDisposition = ContentDisposition.type("attachment").fileName(file.getName()).creationDate(new Date()).build();
        return javax.ws.rs.core.Response.ok( ( StreamingOutput ) output -> {
            try {
                InputStream input = new FileInputStream( file );
                IOUtils.copy(input, output);
                output.flush();
            } catch ( Exception e ) { e.printStackTrace(); }
        } ).header( "Content-Disposition", contentDisposition ).build();

    }
}
 
Example #17
Source File: ResponseHeaderProcessor.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@Override
public void process(SwaggerGenerator swaggerGenerator, OperationGenerator operationGenerator,
    ResponseHeader responseHeader) {
  ResponseHeaderConfig config = AnnotationUtils.convert(responseHeader);
  if (config != null) {
    Property property =
        AnnotationUtils.generateResponseHeaderProperty(swaggerGenerator.getSwagger(), config);
    operationGenerator.addMethodResponseHeader(config.getName(), property);
  }
}
 
Example #18
Source File: TestApiOperation.java    From servicecomb-java-chassis with Apache License 2.0 5 votes vote down vote up
@ApiOperation(
    value = "summary",
    notes = "notes",
    tags = {"tag1", "tag2"},
    httpMethod = "GET",
    nickname = "test",
    produces = "application/json",
    consumes = "application/json",
    protocols = "http,https",
    code = 202,
    responseHeaders = {@ResponseHeader(name = "h1", response = int.class)},
    extensions = {@Extension(
        name = "x-tagA",
        properties = {@ExtensionProperty(name = "x-tagAExt", value = "value of tagAExt")})})
void testBase();
 
Example #19
Source File: CompositeController.java    From microservices-transactions-tcc with Apache License 2.0 5 votes vote down vote up
@POST
@Path("files")
@Produces ( "application/json" )
   @ApiOperation(
   		code = 201,
           value = "Save new content while creating its discussion board",
           notes = "Both operations (new content and forum) must succeed within a given time interval, otherwise both will be canceled or rolled back. "
           		+ "The newly created resource(s) can be referenced by the URI(s) returned in the entity of the response, with the URI for the "
           		+ "distributed transaction given by the Location header field",
           response = String.class,
           responseContainer = "List",
           responseHeaders = {
   			 @ResponseHeader(name = "Location", description = "The distributed transaction URI", response = String.class)
   		}
       )
@ApiResponses(value = {
		@ApiResponse(code=500, message="Error processing request", response = ErrorDetails.class)
})
public Response save(@Context UriInfo uriInfo, 
		@ApiParam(value = "Data to pass to server", required = true) CompositeData data
		) throws CompositeTransactionException {
	
	Entry<String, List<String>> txEntities = service.saveAllEntities(data);
	
	URI location = uriInfo.getAbsolutePathBuilder().path("{id}")
			.resolveTemplate("id", txEntities.getKey()).build();
	
	return Response.created(location).entity(txEntities.getValue()).build();
}
 
Example #20
Source File: UserManagementService.java    From carbon-device-mgt with Apache License 2.0 5 votes vote down vote up
@GET
@Path("/checkUser")
@ApiOperation(
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "GET",
        value = "Getting the User existence status",
        notes = "Check if the user exists in the user store.",
        tags = "User Management",
        extensions = {
            @Extension(properties = {
                    @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:is-exist")
            })
        }
)
@ApiResponses(value = {
        @ApiResponse(
                code = 200,
                message = "OK. \n Successfully fetched user exist status.",
                response = BasicUserInfoList.class,
                responseHeaders = {
                        @ResponseHeader(
                                name = "Content-Type",
                                description = "The content type of the body")
                }),
        @ApiResponse(
                code = 406,
                message = "Not Acceptable.\n The requested media type is not supported",
                response = ErrorResponse.class),
        @ApiResponse(
                code = 500,
                message = "Internal Server Error. \n Server error occurred while fetching the " +
                        "total user exist status.",
                response = ErrorResponse.class)
})
Response isUserExists(@ApiParam(
                name = "username",
                value = "The username of the user.",
                required = true)
        @QueryParam("username") String userName);
 
Example #21
Source File: DeviceEventManagementService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@DELETE
@Path("/{type}")
@ApiOperation(
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "DELETE",
        value = "Delete Event Type Defnition",
        notes = "Delete the event definition for the device.",
        tags = "Device Event Management",
        extensions = {
                @Extension(properties = {
                        @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
                })
        }
)
@ApiResponses(
        value = {
                @ApiResponse(
                        code = 200,
                        message = "OK. \n Successfully deleted the event definition.",
                        responseHeaders = {
                                @ResponseHeader(
                                        name = "Content-Type",
                                        description = "The content type of the body"),
                                @ResponseHeader(
                                        name = "ETag",
                                        description = "Entity Tag of the response resource.\n" +
                                                "Used by caches, or in conditional requests."),
                                @ResponseHeader(
                                        name = "Last-Modified",
                                        description =
                                                "Date and time the resource was last modified.\n" +
                                                        "Used by caches, or in conditional requests."),
                        }
                ),
                @ApiResponse(
                        code = 400,
                        message =
                                "Bad Request. \n"),
                @ApiResponse(
                        code = 406,
                        message = "Not Acceptable.\n The requested media type is not supported"),
                @ApiResponse(
                        code = 500,
                        message = "Internal Server Error. \n Server error occurred while fetching the " +
                                "list of supported device types.",
                        response = ErrorResponse.class)
        }
)
Response deleteDeviceTypeEventDefinitions(@ApiParam(name = "type", value = "name of the device type", required = false)
                                          @PathParam("type")String deviceType);
 
Example #22
Source File: PolicyManagementService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@PUT
@Path("/{id}")
@ApiOperation(
        consumes = MediaType.APPLICATION_JSON,
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "PUT",
        value = "Updating a Policy",
        notes = "Make changes to an existing policy by updating the policy using this resource.",
        tags = "Device Policy Management",
        extensions = {
            @Extension(properties = {
                    @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:update")
            })
        }
)
@ApiResponses(
        value = {
                @ApiResponse(
                        code = 200,
                        message = "OK. \n Successfully updated the policy.",
                        responseHeaders = {
                                @ResponseHeader(
                                        name = "Content-Location",
                                        description = "The URL of the updated device."),
                                @ResponseHeader(
                                        name = "Content-Type",
                                        description = "The content type of the body"),
                                @ResponseHeader(
                                        name = "ETag",
                                        description = "Entity Tag of the response resource.\n" +
                                                "Used by caches, or in conditional requests."),
                                @ResponseHeader(
                                        name = "Last-Modified",
                                        description = "Date and time the resource was last modified.\n" +
                                                "Used by caches, or in conditional requests.")
                        }
                ),
                @ApiResponse(
                        code = 400,
                        message = "Bad Request. \n Invalid request or validation error.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 404,
                        message = "Not Found. \n The specified resource does not exist.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 415,
                        message = "Unsupported media type. \n The format of the requested entity was not supported."),
                @ApiResponse(
                        code = 500,
                        message = "Internal Server Error. \n " +
                                "Server error occurred while updating the policy.",
                        response = ErrorResponse.class)
        })
Response updatePolicy(
        @ApiParam(
                name = "id",
                value = "The policy ID.",
                required = true,
                defaultValue = "1")
        @PathParam("id")
                int id,
        @ApiParam(
                name = "policy",
                value = "Update the required property details.",
                required = true)
                @Valid PolicyWrapper policy);
 
Example #23
Source File: DeviceTypeManagementAdminService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@PUT
@ApiOperation(
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "PUT",
        value = "Update Device Type",
        notes = "Update the details of a device type.",
        response = DeviceType.class,
        tags = "Device Type Management Administrative Service",
        extensions = {
                @Extension(properties = {
                        @ExtensionProperty(name = Constants.SCOPE, value = "perm:admin:device-type")
                })
        }
)
@ApiResponses(value = {
        @ApiResponse(code = 200, message = "OK. \n Successfully updated the device type.",
                     responseHeaders = {
                             @ResponseHeader(
                                     name = "Content-Type",
                                     description = "The content type of the body")
                     }),
        @ApiResponse(
                code = 304,
                message = "Not Modified. Empty body because the client already has the latest version of the " +
                        "requested resource.\n"),
        @ApiResponse(
                code = 401,
                message = "Unauthorized.\n The unauthorized access to the requested resource.",
                response = ErrorResponse.class),
        @ApiResponse(
                code = 404,
                message = "Not Found.\n The specified device does not exist",
                response = ErrorResponse.class),
        @ApiResponse(
                code = 406,
                message = "Not Acceptable.\n The requested media type is not supported"),
        @ApiResponse(
                code = 500,
                message = "Internal Server Error. \n Server error occurred while fetching the device list.",
                response = ErrorResponse.class)
})
Response updateDeviceType(@ApiParam(
        name = "type",
        value = "The device type such as ios, android, windows or fire-alarm.",
        required = true) DeviceType deviceType);
 
Example #24
Source File: DeviceManagementService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/{type}/{id}")
@ApiOperation(
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "GET",
        value = "Getting Details of a Device",
        notes = "Get the details of a device by specifying the device type and device identifier and optionally " +
                "the owner.",
        tags = "Device Management",
        extensions = {
            @Extension(properties = {
                    @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:details")
            })
        }
)
@ApiResponses(
        value = {
                @ApiResponse(
                        code = 200,
                        message = "OK. \n Successfully fetched the details of the device.",
                        response = Device.class,
                        responseHeaders = {
                                @ResponseHeader(
                                        name = "Content-Type",
                                        description = "The content type of the body"),
                                @ResponseHeader(
                                        name = "ETag",
                                        description = "Entity Tag of the response resource.\n" +
                                                "Used by caches, or in conditional requests."),
                                @ResponseHeader(
                                        name = "Last-Modified",
                                        description = "Date and time the resource was last modified.\n" +
                                                "Used by caches, or in conditional requests."),
                        }),
                @ApiResponse(
                        code = 304,
                        message = "Not Modified. Empty body because the client already has the latest version" +
                                " of the requested resource.\n"),
                @ApiResponse(
                        code = 400,
                        message = "Bad Request. \n Invalid request or validation error.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 404,
                        message = "Not Found. \n A device with the specified device type and id was not found.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 500,
                        message = "Internal Server Error. \n " +
                                "Server error occurred while retrieving the device details.",
                        response = ErrorResponse.class)
        })
Response getDevice(
        @ApiParam(
                name = "type",
                value = "The device type name, such as ios, android, windows or fire-alarm.",
                required = true)
        @PathParam("type")
        @Size(max = 45)
                String type,
        @ApiParam(
                name = "id",
                value = "The device identifier of the device you want ot get details.",
                required = true)
        @PathParam("id")
        @Size(max = 45)
                String id,
        @ApiParam(
                name = "owner",
                value = "The owner of the device you want ot get details.",
                required = false)
        @QueryParam("owner")
        @Size(max = 100)
        String owner,
        @ApiParam(
        name = "If-Modified-Since",
        value = "Checks if the requested variant was modified, since the specified date-time. \n" +
                "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z. \n" +
                "Example: Mon, 05 Jan 2014 15:10:00 +0200",
        required = false)
        @HeaderParam("If-Modified-Since")
                String ifModifiedSince);
 
Example #25
Source File: DeviceAgentService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/pending/operations/{type}/{id}")
@ApiOperation(
        produces = MediaType.APPLICATION_JSON,
        consumes = MediaType.APPLICATION_JSON,
        httpMethod = "GET",
        value = "Get pending operation of the given device",
        notes = "Returns the Operations.",
        tags = "Device Agent Management",
        extensions = {
                @Extension(properties = {
                        @ExtensionProperty(name = Constants.SCOPE, value = "perm:device:operations")
                })
        }
)
@ApiResponses(
        value = {
                @ApiResponse(
                        code = 200,
                        message = "OK. \n Successfully retrieved the operations.",
                        response = OperationList.class,
                        responseHeaders = {
                                @ResponseHeader(
                                        name = "Content-Type",
                                        description = "The content type of the body"),
                                @ResponseHeader(
                                        name = "ETag",
                                        description = "Entity Tag of the response resource.\n" +
                                                "Used by caches, or in conditional requests."),
                                @ResponseHeader(
                                        name = "Last-Modified",
                                        description = "Date and time the resource has been modified the last time.\n" +
                                                "Used by caches, or in conditional requests."),
                        }),
                @ApiResponse(
                        code = 304,
                        message = "Not Modified. Empty body because the client already has the latest " +
                                "version of the requested resource."),
                @ApiResponse(
                        code = 400,
                        message = "Bad Request. \n Invalid request or validation error.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 404,
                        message = "Not Found. \n No device is found under the provided type and id.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 500,
                        message = "Internal Server Error. \n " +
                                "Server error occurred while retrieving information requested device.",
                        response = ErrorResponse.class)
        })
Response getPendingOperations(@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
                              @PathParam("type") String type,
                              @ApiParam(name = "id", value = "The device id.", required = true)
                              @PathParam("id") String deviceId);
 
Example #26
Source File: DeviceManagementService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/{type}/{id}/applications")
@ApiOperation(
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "GET",
        value = "Getting Installed Application Details of a Device",
        notes = "Get the list of applications subscribed to by a device.",
        tags = "Device Management",
        extensions = {
        @Extension(properties = {
                @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:applications")
        })

}
)
@ApiResponses(
        value = {
                @ApiResponse(
                        code = 200,
                        message = "OK. \n Successfully fetched the list of applications.",
                        response = Application.class,
                        responseContainer = "List",
                        responseHeaders = {
                                @ResponseHeader(
                                        name = "Content-Type",
                                        description = "The content type of the body"),
                                @ResponseHeader(
                                        name = "ETag",
                                        description = "Entity Tag of the response resource.\n" +
                                                "Used by caches, or in conditional requests."),
                                @ResponseHeader(
                                        name = "Last-Modified",
                                        description = "Date and time the resource was last modified\n" +
                                                "Used by caches, or in conditional requests.")}),
                @ApiResponse(
                        code = 303,
                        message = "See Other. \n " +
                                "The source can be retrieved from the URL specified in the location header.\n",
                        responseHeaders = {
                                @ResponseHeader(
                                        name = "Content-Location",
                                        description = "The Source URL of the document.")}),
                @ApiResponse(
                        code = 304,
                        message = "Not Modified. \n " +
                                "Empty body because the client already has the latest version of the requested resource."),
                @ApiResponse(
                        code = 400,
                        message = "Bad Request. \n Invalid request or validation error.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 404,
                        message = "Not Found. \n The specified device does not exist.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 406,
                        message = "Not Acceptable. \n The requested media type is not supported."),
                @ApiResponse(
                        code = 500,
                        message = "Internal Server Error. \n " +
                                "Server error occurred while retrieving the list of installed application on the device.",
                        response = ErrorResponse.class)
        })
Response getInstalledApplications(
        @ApiParam(
                name = "type",
                value = "The device type name, such as ios, android, windows or fire-alarm.",
                required = true)
        @PathParam("type")
        @Size(max = 45)
        String type,
        @ApiParam(
                name = "id",
                value = "The device identifier of the device.",
                required = true)
        @PathParam("id")
        @Size(max = 45)
        String id,
        @ApiParam(
                name = "If-Modified-Since",
                value = "Checks if the requested variant was modified, since the specified date-time. \n" +
                        "Provide the value in the following format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
                        "Example: Mon, 05 Jan 2014 15:10:00 +0200",
                required = false)
        @HeaderParam("If-Modified-Since")
        String ifModifiedSince,
        @ApiParam(
                name = "offset",
                value = "The starting pagination index for the complete list of qualified items.",
                required = false,
                defaultValue = "0")
        @QueryParam("offset")
        int offset,
        @ApiParam(
                name = "limit",
                value = "Provide how many application details you require from the starting pagination index/offset.",
                required = false,
                defaultValue = "5")
        @QueryParam("limit")
        int limit);
 
Example #27
Source File: UserManagementService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@GET
@ApiOperation(
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "GET",
        value = "Getting Details of Users",
        notes = "You are able to manage users in WSO2 IoTS by adding, updating and removing users. If you wish to get the list of users registered with WSO2 IoTS, you can do so "
                + "using this REST API",
        tags = "User Management",
        extensions = {
            @Extension(properties = {
                    @ExtensionProperty(name = Constants.SCOPE, value = "perm:users:user-details")
            })
        }
)
@ApiResponses(value = {
        @ApiResponse(
                code = 200,
                message = "OK. \n Successfully fetched the list of users registered with WSO2 IoTS.",
                response = BasicUserInfoList.class,
                responseHeaders = {
                        @ResponseHeader(
                                name = "Content-Type",
                                description = "The content type of the body"),
                        @ResponseHeader(
                                name = "ETag",
                                description = "Entity Tag of the response resource.\n" +
                                        "Used by caches, or in conditional requests."),
                        @ResponseHeader(
                                name = "Last-Modified",
                                description = "Date and time the resource was last modified.\n" +
                                        "Used by caches, or in conditional requests."),
                }),
        @ApiResponse(
                code = 304,
                message = "Not Modified. \n Empty body because the client already has the latest version of " +
                        "the requested resource.\n"),
        @ApiResponse(
                code = 406,
                message = "Not Acceptable.\n The requested media type is not supported",
                response = ErrorResponse.class),
        @ApiResponse(
                code = 500,
                message = "Internal Server Error. \n Server error occurred while fetching the list of WSO2 IoTS users.",
                response = ErrorResponse.class)
})
Response getUsers(
        @ApiParam(
                name = "filter",
                value = "The username of the user.",
                required = false)
        @QueryParam("filter") String filter,
        @ApiParam(
                name = "If-Modified-Since",
                value = "Checks if the requested variant was modified, since the specified date-time\n." +
                        "Provide the value in the Java Date Format: EEE, d MMM yyyy HH:mm:ss Z.\n" +
                        "Example: Mon, 05 Jan 2014 15:10:00 +0200",
                required = false)
        @HeaderParam("If-Modified-Since") String timestamp,
        @ApiParam(
                name = "offset",
                value = "The starting pagination index for the complete list of qualified items.",
                required = false,
                defaultValue = "0")
        @QueryParam("offset") int offset,
        @ApiParam(
                name = "limit",
                value = "Provide how many user details you require from the starting pagination index/offset.",
                required = false,
                defaultValue = "5")
        @QueryParam("limit") int limit);
 
Example #28
Source File: PolicyManagementService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@GET
@Path("/effective-policy/{deviceType}/{deviceId}")
@ApiOperation(
        consumes = MediaType.APPLICATION_JSON,
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "GET",
        value = "Getting the Effective Policy",
        notes = "Retrieve the effective policy of a device using this API.",
        tags = "Device Policy Management",
        extensions = {
                @Extension(properties = {
                        @ExtensionProperty(name = Constants.SCOPE, value = "perm:policies:effective-policy")
                })
        }
)
@ApiResponses(
        value = {
                @ApiResponse(
                        code = 200,
                        message = "OK. \n Successfully fetched the policy.",
                        response = Policy.class,
                        responseHeaders = {
                                @ResponseHeader(
                                        name = "Content-Type",
                                        description = "The content type of the body"),
                                @ResponseHeader(
                                        name = "ETag",
                                        description = "Entity Tag of the response resource.\n" +
                                                "Used by caches, or in conditional requests."),
                                @ResponseHeader(
                                        name = "Last-Modified",
                                        description = "Date and time the resource was last modified.\n" +
                                                "Used by caches, or in conditional requests."),
                        }
                ),
                @ApiResponse(
                        code = 304,
                        message = "Not Modified. \n Empty body because the client already has the latest version " +
                                "of the requested resource.\n"),
                @ApiResponse(
                        code = 404,
                        message = "Not Found. \n A specified policy was not found.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 406,
                        message = "Not Acceptable.\n The requested media type is not supported."),
                @ApiResponse(
                        code = 500,
                        message = "Internal Server Error. \n Server error occurred while fetching the " +
                                "policy.",
                        response = ErrorResponse.class)
        })
Response getEffectivePolicy(
        @ApiParam(
                name = "deviceType",
                value = "The device type name, such as ios, android, windows or fire-alarm.",
                required = true)
        @PathParam("deviceType")
        @Size(max = 45)
                String deviceType,
        @ApiParam(
                name = "deviceId",
                value = "The device identifier of the device you want ot get details.",
                required = true)
        @PathParam("deviceId")
        @Size(max = 45)
                String deviceId);
 
Example #29
Source File: DeviceManagementService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@PUT
@Path("/{type}/{id}")
@ApiOperation(
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "GET",
        value = "Getting the Device Enrollment Status",
        notes = "Get the device enrollment status and the device details of the device.",
        tags = "Device Management",
        extensions = {
                @Extension(properties = {
                        @ExtensionProperty(name = Constants.SCOPE, value = "perm:devices:view")
                })
        }
)
@ApiResponses(
        value = {
                @ApiResponse(
                        code = 200,
                        message = "OK. \n Successfully created a device instance.",
                        responseHeaders = {
                                @ResponseHeader(
                                        name = "Content-Type",
                                        description = "The content type of the body"),
                                @ResponseHeader(
                                        name = "ETag",
                                        description = "Entity Tag of the response resource.\n" +
                                                "Used by caches, or in conditional requests."),
                                @ResponseHeader(
                                        name = "Last-Modified",
                                        description = "Date and time the resource was last modified.\n" +
                                                "Used by caches, or in conditional requests."),
                        }),
                @ApiResponse(
                        code = 304,
                        message = "Not Modified. Empty body because the client already has the latest version" +
                                " of the requested resource.\n"),
                @ApiResponse(
                        code = 400,
                        message = "Bad Request. \n Invalid request or validation error.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 404,
                        message = "Not Found. \n A deviceType with the specified device type was not found.",
                        response = ErrorResponse.class),
                @ApiResponse(
                        code = 500,
                        message = "Internal Server Error. \n " +
                                "Server error occurred while retrieving the device details.",
                        response = ErrorResponse.class)
        })
Response isEnrolled(@ApiParam(name = "type", value = "The device type, such as ios, android or windows.", required = true)
                    @PathParam("type") String type,
                    @ApiParam(name = "id", value = "The device id.", required = true)
                    @PathParam("id") String deviceId);
 
Example #30
Source File: DeviceEventManagementService.java    From carbon-device-mgt with Apache License 2.0 4 votes vote down vote up
@POST
@Path("/{type}")
@ApiOperation(
        produces = MediaType.APPLICATION_JSON,
        httpMethod = "POST",
        value = "Add Event Type Defnition",
        notes = "Add the event definition for the device.",
        tags = "Device Event Management",
        extensions = {
                @Extension(properties = {
                        @ExtensionProperty(name = Constants.SCOPE, value = "perm:device-types:events")
                })
        }
)
@ApiResponses(
        value = {
                @ApiResponse(
                        code = 200,
                        message = "OK. \n Successfully added the event defintion.",
                        responseHeaders = {
                                @ResponseHeader(
                                        name = "Content-Type",
                                        description = "The content type of the body"),
                                @ResponseHeader(
                                        name = "ETag",
                                        description = "Entity Tag of the response resource.\n" +
                                                "Used by caches, or in conditional requests."),
                                @ResponseHeader(
                                        name = "Last-Modified",
                                        description =
                                                "Date and time the resource was last modified.\n" +
                                                        "Used by caches, or in conditional requests."),
                        }
                ),
                @ApiResponse(
                        code = 400,
                        message =
                                "Bad Request. \n"),
                @ApiResponse(
                        code = 406,
                        message = "Not Acceptable.\n The requested media type is not supported"),
                @ApiResponse(
                        code = 500,
                        message = "Internal Server Error. \n Server error occurred while fetching the " +
                                "list of supported device types.",
                        response = ErrorResponse.class)
        }
)
Response deployDeviceTypeEventDefinition(@ApiParam(name = "type", value = "name of the device type", required = false)
                                         @PathParam("type")String deviceType,
                                         @ApiParam(name = "deviceTypeEvent", value = "DeviceTypeEvent object with data.", required = true)
                                         @Valid DeviceTypeEvent deviceTypeEvent);