@@ -1465,6 +1465,297 @@ public function updateReferrerDomainRestrictionRequest($playback_restriction_id,
1465
1465
);
1466
1466
}
1467
1467
1468
+ /**
1469
+ * Operation updateUserAgentRestriction
1470
+ *
1471
+ * Update the User Agent Restriction
1472
+ *
1473
+ * @param string $playback_restriction_id ID of the Playback Restriction. (required)
1474
+ * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request update_user_agent_restriction_request (required)
1475
+ *
1476
+ * @throws \MuxPhp\ApiException on non-2xx response
1477
+ * @throws \InvalidArgumentException
1478
+ * @return \MuxPhp\Models\PlaybackRestrictionResponse
1479
+ */
1480
+ public function updateUserAgentRestriction ($ playback_restriction_id , $ update_user_agent_restriction_request )
1481
+ {
1482
+ list ($ response ) = $ this ->updateUserAgentRestrictionWithHttpInfo ($ playback_restriction_id , $ update_user_agent_restriction_request );
1483
+ return $ response ;
1484
+ }
1485
+
1486
+ /**
1487
+ * Operation updateUserAgentRestrictionWithHttpInfo
1488
+ *
1489
+ * Update the User Agent Restriction
1490
+ *
1491
+ * @param string $playback_restriction_id ID of the Playback Restriction. (required)
1492
+ * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request (required)
1493
+ *
1494
+ * @throws \MuxPhp\ApiException on non-2xx response
1495
+ * @throws \InvalidArgumentException
1496
+ * @return array of \MuxPhp\Models\PlaybackRestrictionResponse, HTTP status code, HTTP response headers (array of strings)
1497
+ */
1498
+ public function updateUserAgentRestrictionWithHttpInfo ($ playback_restriction_id , $ update_user_agent_restriction_request )
1499
+ {
1500
+ $ request = $ this ->updateUserAgentRestrictionRequest ($ playback_restriction_id , $ update_user_agent_restriction_request );
1501
+
1502
+ try {
1503
+ $ options = $ this ->createHttpClientOption ();
1504
+ try {
1505
+ $ response = $ this ->client ->send ($ request , $ options );
1506
+ } catch (RequestException $ e ) {
1507
+ throw new ApiException (
1508
+ "[ {$ e ->getCode ()}] {$ e ->getMessage ()}" ,
1509
+ $ e ->getCode (),
1510
+ $ e ->getResponse () ? $ e ->getResponse ()->getHeaders () : null ,
1511
+ $ e ->getResponse () ? (string ) $ e ->getResponse ()->getBody () : null
1512
+ );
1513
+ }
1514
+
1515
+ $ statusCode = $ response ->getStatusCode ();
1516
+
1517
+ if ($ statusCode < 200 || $ statusCode > 299 ) {
1518
+ throw new ApiException (
1519
+ sprintf (
1520
+ '[%d] Error connecting to the API (%s) ' ,
1521
+ $ statusCode ,
1522
+ $ request ->getUri ()
1523
+ ),
1524
+ $ statusCode ,
1525
+ $ response ->getHeaders (),
1526
+ $ response ->getBody ()
1527
+ );
1528
+ }
1529
+
1530
+ $ responseBody = $ response ->getBody ();
1531
+ switch ($ statusCode ) {
1532
+ case 200 :
1533
+ if ('\MuxPhp\Models\PlaybackRestrictionResponse ' === '\SplFileObject ' ) {
1534
+ $ content = $ responseBody ; //stream goes to serializer
1535
+ } else {
1536
+ $ content = (string ) $ responseBody ;
1537
+ }
1538
+
1539
+ return [
1540
+ ObjectSerializer::deserialize ($ content , '\MuxPhp\Models\PlaybackRestrictionResponse ' , []),
1541
+ $ response ->getStatusCode (),
1542
+ $ response ->getHeaders ()
1543
+ ];
1544
+ }
1545
+
1546
+ $ returnType = '\MuxPhp\Models\PlaybackRestrictionResponse ' ;
1547
+ $ responseBody = $ response ->getBody ();
1548
+ if ($ returnType === '\SplFileObject ' ) {
1549
+ $ content = $ responseBody ; //stream goes to serializer
1550
+ } else {
1551
+ $ content = (string ) $ responseBody ;
1552
+ }
1553
+
1554
+ return [
1555
+ ObjectSerializer::deserialize ($ content , $ returnType , []),
1556
+ $ response ->getStatusCode (),
1557
+ $ response ->getHeaders ()
1558
+ ];
1559
+
1560
+ } catch (ApiException $ e ) {
1561
+ switch ($ e ->getCode ()) {
1562
+ case 200 :
1563
+ $ data = ObjectSerializer::deserialize (
1564
+ $ e ->getResponseBody (),
1565
+ '\MuxPhp\Models\PlaybackRestrictionResponse ' ,
1566
+ $ e ->getResponseHeaders ()
1567
+ );
1568
+ $ e ->setResponseObject ($ data );
1569
+ break ;
1570
+ }
1571
+ throw $ e ;
1572
+ }
1573
+ }
1574
+
1575
+ /**
1576
+ * Operation updateUserAgentRestrictionAsync
1577
+ *
1578
+ * Update the User Agent Restriction
1579
+ *
1580
+ * @param string $playback_restriction_id ID of the Playback Restriction. (required)
1581
+ * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request (required)
1582
+ *
1583
+ * @throws \InvalidArgumentException
1584
+ * @return \GuzzleHttp\Promise\PromiseInterface
1585
+ */
1586
+ public function updateUserAgentRestrictionAsync ($ playback_restriction_id , $ update_user_agent_restriction_request )
1587
+ {
1588
+ return $ this ->updateUserAgentRestrictionAsyncWithHttpInfo ($ playback_restriction_id , $ update_user_agent_restriction_request )
1589
+ ->then (
1590
+ function ($ response ) {
1591
+ return $ response [0 ];
1592
+ }
1593
+ );
1594
+ }
1595
+
1596
+ /**
1597
+ * Operation updateUserAgentRestrictionAsyncWithHttpInfo
1598
+ *
1599
+ * Update the User Agent Restriction
1600
+ *
1601
+ * @param string $playback_restriction_id ID of the Playback Restriction. (required)
1602
+ * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request (required)
1603
+ *
1604
+ * @throws \InvalidArgumentException
1605
+ * @return \GuzzleHttp\Promise\PromiseInterface
1606
+ */
1607
+ public function updateUserAgentRestrictionAsyncWithHttpInfo ($ playback_restriction_id , $ update_user_agent_restriction_request )
1608
+ {
1609
+ $ returnType = '\MuxPhp\Models\PlaybackRestrictionResponse ' ;
1610
+ $ request = $ this ->updateUserAgentRestrictionRequest ($ playback_restriction_id , $ update_user_agent_restriction_request );
1611
+
1612
+ return $ this ->client
1613
+ ->sendAsync ($ request , $ this ->createHttpClientOption ())
1614
+ ->then (
1615
+ function ($ response ) use ($ returnType ) {
1616
+ $ responseBody = $ response ->getBody ();
1617
+ if ($ returnType === '\SplFileObject ' ) {
1618
+ $ content = $ responseBody ; //stream goes to serializer
1619
+ } else {
1620
+ $ content = (string ) $ responseBody ;
1621
+ }
1622
+
1623
+ return [
1624
+ ObjectSerializer::deserialize ($ content , $ returnType , []),
1625
+ $ response ->getStatusCode (),
1626
+ $ response ->getHeaders ()
1627
+ ];
1628
+ },
1629
+ function ($ exception ) {
1630
+ $ response = $ exception ->getResponse ();
1631
+ $ statusCode = $ response ->getStatusCode ();
1632
+ throw new ApiException (
1633
+ sprintf (
1634
+ '[%d] Error connecting to the API (%s) ' ,
1635
+ $ statusCode ,
1636
+ $ exception ->getRequest ()->getUri ()
1637
+ ),
1638
+ $ statusCode ,
1639
+ $ response ->getHeaders (),
1640
+ $ response ->getBody ()
1641
+ );
1642
+ }
1643
+ );
1644
+ }
1645
+
1646
+ /**
1647
+ * Create request for operation 'updateUserAgentRestriction'
1648
+ *
1649
+ * @param string $playback_restriction_id ID of the Playback Restriction. (required)
1650
+ * @param \MuxPhp\Models\UpdateUserAgentRestrictionRequest $update_user_agent_restriction_request (required)
1651
+ *
1652
+ * @throws \InvalidArgumentException
1653
+ * @return \GuzzleHttp\Psr7\Request
1654
+ */
1655
+ public function updateUserAgentRestrictionRequest ($ playback_restriction_id , $ update_user_agent_restriction_request )
1656
+ {
1657
+ // verify the required parameter 'playback_restriction_id' is set
1658
+ if ($ playback_restriction_id === null || (is_array ($ playback_restriction_id ) && count ($ playback_restriction_id ) === 0 )) {
1659
+ throw new \InvalidArgumentException (
1660
+ 'Missing the required parameter $playback_restriction_id when calling updateUserAgentRestriction '
1661
+ );
1662
+ }
1663
+ // verify the required parameter 'update_user_agent_restriction_request' is set
1664
+ if ($ update_user_agent_restriction_request === null || (is_array ($ update_user_agent_restriction_request ) && count ($ update_user_agent_restriction_request ) === 0 )) {
1665
+ throw new \InvalidArgumentException (
1666
+ 'Missing the required parameter $update_user_agent_restriction_request when calling updateUserAgentRestriction '
1667
+ );
1668
+ }
1669
+
1670
+ $ resourcePath = '/video/v1/playback-restrictions/{PLAYBACK_RESTRICTION_ID}/user_agent ' ;
1671
+ $ formParams = [];
1672
+ $ queryParams = [];
1673
+ $ headerParams = [];
1674
+ $ httpBody = '' ;
1675
+ $ multipart = false ;
1676
+
1677
+
1678
+
1679
+ // path params
1680
+ if ($ playback_restriction_id !== null ) {
1681
+ $ resourcePath = str_replace (
1682
+ '{ ' . 'PLAYBACK_RESTRICTION_ID ' . '} ' ,
1683
+ ObjectSerializer::toPathValue ($ playback_restriction_id ),
1684
+ $ resourcePath
1685
+ );
1686
+ }
1687
+
1688
+
1689
+ if ($ multipart ) {
1690
+ $ headers = $ this ->headerSelector ->selectHeadersForMultipart (
1691
+ ['application/json ' ]
1692
+ );
1693
+ } else {
1694
+ $ headers = $ this ->headerSelector ->selectHeaders (
1695
+ ['application/json ' ],
1696
+ ['application/json ' ]
1697
+ );
1698
+ }
1699
+
1700
+ // for model (json/xml)
1701
+ if (isset ($ update_user_agent_restriction_request )) {
1702
+ if ($ headers ['Content-Type ' ] === 'application/json ' ) {
1703
+ $ httpBody = \GuzzleHttp \json_encode (ObjectSerializer::sanitizeForSerialization ($ update_user_agent_restriction_request ));
1704
+ } else {
1705
+ $ httpBody = $ update_user_agent_restriction_request ;
1706
+ }
1707
+ } elseif (count ($ formParams ) > 0 ) {
1708
+ if ($ multipart ) {
1709
+ $ multipartContents = [];
1710
+ foreach ($ formParams as $ formParamName => $ formParamValue ) {
1711
+ $ formParamValueItems = is_array ($ formParamValue ) ? $ formParamValue : [$ formParamValue ];
1712
+ foreach ($ formParamValueItems as $ formParamValueItem ) {
1713
+ $ multipartContents [] = [
1714
+ 'name ' => $ formParamName ,
1715
+ 'contents ' => $ formParamValueItem
1716
+ ];
1717
+ }
1718
+ }
1719
+ // for HTTP post (form)
1720
+ $ httpBody = new MultipartStream ($ multipartContents );
1721
+
1722
+ } elseif ($ headers ['Content-Type ' ] === 'application/json ' ) {
1723
+ $ httpBody = \GuzzleHttp \json_encode ($ formParams );
1724
+
1725
+ } else {
1726
+ // for HTTP post (form)
1727
+ $ httpBody = \GuzzleHttp \Psr7 \build_query ($ formParams );
1728
+ }
1729
+ }
1730
+
1731
+ // this endpoint requires HTTP basic authentication
1732
+ if (!empty ($ this ->config ->getUsername ()) || !(empty ($ this ->config ->getPassword ()))) {
1733
+ $ headers ['Authorization ' ] = 'Basic ' . base64_encode ($ this ->config ->getUsername () . ": " . $ this ->config ->getPassword ());
1734
+ }
1735
+
1736
+ $ defaultHeaders = [];
1737
+ if ($ this ->config ->getUserAgent ()) {
1738
+ $ defaultHeaders ['User-Agent ' ] = $ this ->config ->getUserAgent ();
1739
+ }
1740
+
1741
+ $ headers = array_merge (
1742
+ $ defaultHeaders ,
1743
+ $ headerParams ,
1744
+ $ headers
1745
+ );
1746
+
1747
+
1748
+ // MUX: adds support for array params.
1749
+ // TODO: future upstream?
1750
+ $ query = ObjectSerializer::buildBetterQuery ($ queryParams );
1751
+ return new Request (
1752
+ 'PUT ' ,
1753
+ $ this ->config ->getHost () . $ resourcePath . ($ query ? "? {$ query }" : '' ),
1754
+ $ headers ,
1755
+ $ httpBody
1756
+ );
1757
+ }
1758
+
1468
1759
/**
1469
1760
* Create http client option
1470
1761
*
0 commit comments