Open topic with navigation

# Timeslots (Create, Get all timeslots)

Available in versions: 12.56 and later

## Description

Adds a timeslot or retrieves a list of existing timeslots.

## URL

    /LoadTest/rest/domains/{domainName}/projects/{projectName}/timeslots

## Remarks

Body of the request should contain a resource folder description in xml format.

## HTTP Method

POST: Creates a timeslot.

GET: Returns the timeslots in the body of the response.

## Request

Headers:

Content-Type: application/xml

Cookies:

Version 2020 (or later) | LWSSO_COOKIE_KEY={LwssoCookie};
Versions earlier than 2020 | LWSSO_COOKIE_KEY={LwssoCookie};QCSession={QCSessionCookie};

Request Body:

POST: An XML containing the timeslot reservation.

GET: No request body.

Request Example - POST

    POST http://<LRE_Server>/LoadTest/rest/domains/{domainName}/projects/{projectName}/timeslots
    Content-Type: application/xml
    Cookie: LWSSO_COOKIE_KEY={LwssoCookie};

An example of a request body when using Content-Type header application/xml:

    <Timeslot xmlns="http://www.hp.com/PC/REST/API">
        <StartTime>2017-09-05T08:00:00Z</StartTime>
        <DurationInMinutes>30</DurationInMinutes>
        <Description>add text</Description>
        <Name>My_Timeslot</Name>
        <Demands>
          <ControllerDemandManual>
             <HostID>1001</HostID>
          </ControllerDemandManual>
          <LoadGeneratorDemandManual>
             <HostID>1002</HostID>
          </LoadGeneratorDemandManual>
        </Demands>
    </Timeslot>

An example of request when a load test is linked to the timeslot (demands are automatically added to the timeslot based on the load test data):

    <Timeslot xmlns="http://www.hp.com/PC/REST/API">
        <StartTime>2017-09-05T22:30:00Z</StartTime>
        <DurationInMinutes>30</DurationInMinutes>
        <LoadTestInstanceID>1</LoadTestInstanceID>
        <PostRunAction>CollateAnalyze</PostRunAction>
        <Description>add text</Description>
    </Timeslot>

An example of the response:

    <Timeslot>
        <Name />
        <VusersNumber>0</VusersNumber>
        <PostRunAction>CollateAnalyze</PostRunAction>
        <StartTime>2017-09-05T22:30:00+00</StartTime>
          <IsTestAutostart>false</IsTestAutostart>
          <LoadTestInstanceID>1</LoadTestInstanceID>
        <DurationInMinutes>30</DurationInMinutes>
        <Description />
        <AllocatedDemands>
          <ControllerDemand>
             <ID>1361</ID>
             <Type>Manual</Type>
             <RequestedAmount>1</RequestedAmount>
             <AllocatedAmount>1</AllocatedAmount>
             <FilterString>my12365.lab.net</FilterString>
             <AllocatedHostID>1001</AllocatedHostID>
             <AllocatedHostName>my12365.lab.net</AllocatedHostName>
             <IsLoadGenerator>false</IsLoadGenerator>
           </ControllerDemand>
           <LoadGeneratorDemand>
             <ID>1362</ID>
             <Type>Manual</Type>
             <RequestedAmount>1</RequestedAmount>
             <AllocatedAmount>1</AllocatedAmount>
             <FilterString>my12366.lab.net</FilterString>
             <AllocatedHostIDs>
               <HostID>1002</HostID>
             </AllocatedHostIDs>
             <AllocatedHostNames>
               <AllocatedHostName>my12366.lab.net</AllocatedHostName>
             </AllocatedHostNames>
           </LoadGeneratorDemand>
        </AllocatedDemands>
        <ID>1122</ID>
        <LoadTestID>3</LoadTestID>
        <LoadTestName>test_300</LoadTestName>
        <EndTime>2017-09-05T23:00:00+00</EndTime>
        <CreatedBy>sa</CreatedBy>
        <CreationDate>2017-09-05T08:46:51+00</CreationDate>
        <CurrentRunState>Not Started</CurrentRunState>
        <IsAdHoc>false</IsAdHoc>
        <IsAllocated>true</IsAllocated>
        <FailureDescription />
        <OpenStatus>Future</OpenStatus>
        <ProjectID>2</ProjectID>
    </Timeslot>

Request Example - GET

    GET http://<LRE_Server>/LoadTest/rest/domains/MyDomain/projects/MyProject/timeslots

Fields that can be used in the request body during timeslot creation:

Element | Description
--- | ---
StartTime | The UTC date and time (in hours and minutes) that the timeslot starts.
DurationInMinutes | The duration of the timeslot (in minutes).
Description | A description of the timeslot.
Name | Name of the timeslot.
Demands | The type of demands for timeslot creation. Can include: ControllerDemandManual. Fields include: HostID (mandatory), IsLoadGenerator (optional) ControllerDemandAutomatic. Contains no fields; any host can be allocated as a Controller. LoadGeneratorDemandManual. Fields: HostID (mandatory) LoadGeneratorDemandAutomatic. Fields: HostsToReserve (mandatory), LocationID (optional)
VusersNumber | The number of Vusers requested for the timeslot.
VudsNumber | The number of VUDs that are defined in the linked test.
PostRunAction | The action to be taken when the test run is complete. The post-run action can be: DoNothing, CollateOnly, or CollateAnalyze.
LoadTestInstanceID | Enables you to link a performance test instance to the timeslot.
IsTestAutostart | The linked tests or test sets automatically start running at the start of the timeslot, without any manual intervention (true/false).

## Response

Headers:

One of:

- Content-Type: application/xml
- Content-Type: application/json

Cookies:

None

HTML Return Code:

One of the HTTP Return Codes

HTML Body:

GET: Returns the data on the entity in the response. See Timeslot XML.

Response Example

    <Timeslots>
      <Timeslot>
        <Name>MyTimeslot</Name>
        <VusersNumber>0</VusersNumber>
        <PostRunAction>DoNothing</PostRunAction>
        <StartTime>2017-09-04T22:30:00+00</StartTime>
        <DurationInMinutes>30</DurationInMinutes>
        <IsTestAutostart>false</IsTestAutostart>
        <LoadTestInstanceID>1</LoadTestInstanceID>
        <ID>1118</ID>
        <LoadTestID>3</LoadTestID>
        <LoadTestName>test_300</LoadTestName>
        <EndTime>2017-09-04T23:00:00+00</EndTime>
        <CreatedBy>sa</CreatedBy>
        <CreationDate>2017-09-04T11:30:41+00</CreationDate>
        <CurrentRunState>Not Started</CurrentRunState>
        <Description />
        <IsAdHoc>false</IsAdHoc>
        <IsAllocated>true</IsAllocated>
        <OpenStatus>Closed</OpenStatus>
        <ProjectID>2</ProjectID>
      </Timeslot>
      <Timeslot>
        <Name />
        <VusersNumber>0</VusersNumber>
        <VudsNumber>0</VudsNumber>
        <PostRunAction>DoNothing</PostRunAction>
        <StartTime>2017-09-04T20:00:00+00</StartTime>
        <DurationInMinutes>30</DurationInMinutes>
        <IsTestAutostart>false</IsTestAutostart>
        <ID>1119</ID>
        <LoadTestName />
        <EndTime>2017-09-04T20:30:00+00</EndTime>
        <CreatedBy>sa</CreatedBy>
        <CreationDate>2017-09-04T12:02:13+00</CreationDate>
        <CurrentRunState>None</CurrentRunState>
        <Description />
        <IsAdHoc>false</IsAdHoc>
        <IsAllocated>true</IsAllocated>
        <OpenStatus>Closed</OpenStatus>
        <ProjectID>3</ProjectID>
      </Timeslot>
    </Timeslots>

## See Also

Timeslots (Delete a timeslot)
Timeslots (Check availability)
Timeslot XML