# Class HtsgetRequest

java.lang.Object
htsjdk.samtools.util.htsget.HtsgetRequest

Direct Known Subclasses:
  `HtsgetPOSTRequest`

public class HtsgetRequest extends Object
Builder for an htsget GET request that allows opening a connection using the request after validating that it is properly formed.

This class currently supports version 1.2.0 of the spec as defined in https://samtools.github.io/hts-specs/htsget.html

## Field Summary

Fields
Modifier and Type
Field
Description
`protected static final String`
`ACCEPT_TYPE`
`protected HtsgetClass`
`dataClass`
`protected final EnumSet<HtsgetRequestField>`
`fields`
`protected HtsgetFormat`
`format`
`protected Locatable`
`interval`
`protected final Set<String>`
`notags`
`protected static final String`
`PROTOCOL_VERSION`
`protected final Set<String>`
`tags`
`static final Interval`
`UNMAPPED_UNPLACED_INTERVAL`

## Constructor Summary

Constructors
Constructor
Description
`HtsgetRequest(URI endpoint)`
Construct an HtsgetRequest from a URI identifying a valid resource on a htsget server

## Method Summary

Modifier and Type
Method
Description
`void`
`addField(HtsgetRequestField field)`
`void`
`addFields(Collection<HtsgetRequestField> fields)`
`void`
`addNotag(String notag)`
`void`
`addNotags(Collection<String> notags)`
`void`
`addTag(String tag)`
`void`
`addTags(Collection<String> tags)`
`protected HttpURLConnection`
`getConnection()`
`HtsgetClass`
`getDataClass()`
`URI`
`getEndpoint()`
`Set<HtsgetRequestField>`
`getFields()`
`HtsgetFormat`
`getFormat()`
`Locatable`
`getInterval()`
`Set<String>`
`getNoTags()`
`HtsgetResponse`
`getResponse()`
Attempt to make htsget request and return response if there are no errors
`Set<String>`
`getTags()`
`void`
`setDataClass(HtsgetClass dataClass)`
`void`
`setFormat(HtsgetFormat format)`
`void`
`setInterval(Locatable interval)`
`URI`
`toURI()`
Convert request to a URI which can be used to make http request for data blocks
`void`
`validateRequest()`
Validates that the user query obeys htsget spec
`HtsgetRequest`
`withDataClass(HtsgetClass dataClass)`
`HtsgetRequest`
`withField(HtsgetRequestField field)`
`HtsgetRequest`
`withFields(Collection<HtsgetRequestField> fields)`
`HtsgetRequest`
`withFormat(HtsgetFormat format)`
`HtsgetRequest`
`withInterval(Locatable interval)`
`HtsgetRequest`
`withNotag(String notag)`
`HtsgetRequest`
`withNotags(Collection<String> notags)`
`HtsgetRequest`
`withTag(String tag)`
`HtsgetRequest`
`withTags(Collection<String> tags)`

### Methods inherited from class Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### UNMAPPED_UNPLACED_INTERVAL

public static final Interval UNMAPPED_UNPLACED_INTERVAL

### PROTOCOL_VERSION

protected static final String PROTOCOL_VERSION

See Also:
  - Constant Field Values

### ACCEPT_TYPE

protected static final String ACCEPT_TYPE

See Also:
  - Constant Field Values

### format

protected HtsgetFormat format

### dataClass

protected HtsgetClass dataClass

### interval

protected Locatable interval

### fields

protected final EnumSet<HtsgetRequestField> fields

### tags

protected final Set<String> tags

### notags

protected final Set<String> notags

## Constructor Details

### HtsgetRequest

public HtsgetRequest(URI endpoint)
Construct an HtsgetRequest from a URI identifying a valid resource on a htsget server

Parameters:
  `endpoint` - the full URI including both server path and the ID of the htsget resource, without the filtering parameters defined in the htsget spec such as start or referenceName

## Method Details

### getEndpoint

public URI getEndpoint()

### getFormat

public HtsgetFormat getFormat()

### getDataClass

public HtsgetClass getDataClass()

### getInterval

public Locatable getInterval()

### getFields

public Set<HtsgetRequestField> getFields()

### getTags

public Set<String> getTags()

### getNoTags

public Set<String> getNoTags()

### setFormat

public void setFormat(HtsgetFormat format)

### setDataClass

public void setDataClass(HtsgetClass dataClass)

### setInterval

public void setInterval(Locatable interval)

### addField

public void addField(HtsgetRequestField field)

### addFields

public void addFields(Collection<HtsgetRequestField> fields)

### addTag

public void addTag(String tag)

### addTags

public void addTags(Collection<String> tags)

### addNotag

public void addNotag(String notag)

### addNotags

public void addNotags(Collection<String> notags)

### withFormat

public HtsgetRequest withFormat(HtsgetFormat format)

### withDataClass

public HtsgetRequest withDataClass(HtsgetClass dataClass)

### withInterval

public HtsgetRequest withInterval(Locatable interval)

### withField

public HtsgetRequest withField(HtsgetRequestField field)

### withFields

public HtsgetRequest withFields(Collection<HtsgetRequestField> fields)

### withTag

public HtsgetRequest withTag(String tag)

### withTags

public HtsgetRequest withTags(Collection<String> tags)

### withNotag

public HtsgetRequest withNotag(String notag)

### withNotags

public HtsgetRequest withNotags(Collection<String> notags)

### validateRequest

public void validateRequest()
Validates that the user query obeys htsget spec

### toURI

public URI toURI()
Convert request to a URI which can be used to make http request for data blocks

### getConnection

protected HttpURLConnection getConnection()

### getResponse

public HtsgetResponse getResponse()
Attempt to make htsget request and return response if there are no errors

Returns:
  the response from the htsget server if request is successful as an HtsgetResponse object