/**
  * Get the list of Programs, if channel (or channel id) is provided, then
  * returns the Programs associated to that Channel.
  *
  * @return array
  */
 public function getProgramList($channel = null)
 {
     if (is_null($channel)) {
         $entityList = $this->_getEntityList('Programs');
     } else {
         $channelId = Utilities::getEntityId($channel, 'WindowsAzure\\MediaServices\\Models\\Channel');
         $entityList = $this->_getEntityList("Channels('{$channelId}')/Programs");
     }
     $result = array();
     foreach ($entityList as $program) {
         $result[] = Program::createFromOptions($program);
     }
     return $result;
 }
 private function makeProgram($name, $channel)
 {
     $asset = new Asset(Asset::OPTIONS_NONE);
     $asset->setName(TestResources::MEDIA_SERVICES_ASSET_NAME . $this->createSuffix());
     $asset = $this->createAsset($asset);
     $policy = new AssetDeliveryPolicy();
     $policy->setName("Clear Policy");
     $policy->setAssetDeliveryProtocol(AssetDeliveryProtocol::SMOOTH_STREAMING | AssetDeliveryProtocol::DASH | AssetDeliveryProtocol::HLS);
     $policy->setAssetDeliveryPolicyType(AssetDeliveryPolicyType::NO_DYNAMIC_ENCRYPTION);
     $policy = $this->createAssetDeliveryPolicy($policy);
     $this->restProxy->linkDeliveryPolicyToAsset($asset, $policy);
     $program = new Program();
     $program->setName($name);
     $program->setAssetId($asset->getId());
     $program->setArchiveWindowLength(new \DateInterval("PT1H"));
     $program->setChannelId($channel->getId());
     return $program;
 }
function createAndStartProgram($restProxy, $asset, $channel, $options)
{
    // 1 - create a new program and link to the asset and channel
    $program = new Program();
    $program->setName($options->programName);
    $program->setAssetId($asset->getId());
    $program->setArchiveWindowLength($options->archiveWindowLenght);
    $program->setChannelId($channel->getId());
    echo "Creating program... ";
    $program = $restProxy->createProgram($program);
    // 2 - start the program
    echo "Done!" . PHP_EOL . "Starting program... ";
    $restProxy->startProgram($program);
    echo "Done!" . PHP_EOL;
    return $restProxy->getProgram($program);
}