@@ -1393,6 +1393,166 @@ func (c *client) DeleteClientCertificate(
1393
1393
return nil
1394
1394
}
1395
1395
1396
+ func (c * client ) CreateStatusPage (
1397
+ ctx context.Context ,
1398
+ page StatusPage ,
1399
+ ) (* StatusPage , error ) {
1400
+ data , err := json .Marshal (page )
1401
+ if err != nil {
1402
+ return nil , err
1403
+ }
1404
+ status , res , err := c .apiCall (ctx , http .MethodPost , "status-pages" , data )
1405
+ if err != nil {
1406
+ return nil , err
1407
+ }
1408
+ if status != http .StatusCreated {
1409
+ return nil , fmt .Errorf ("unexpected response status: %d, res: %q" , status , res )
1410
+ }
1411
+ var result StatusPage
1412
+ err = json .NewDecoder (strings .NewReader (res )).Decode (& result )
1413
+ if err != nil {
1414
+ return nil , fmt .Errorf ("decoding error for data %s: %v" , res , err )
1415
+ }
1416
+ return & result , nil
1417
+ }
1418
+
1419
+ func (c * client ) GetStatusPage (
1420
+ ctx context.Context ,
1421
+ ID string ,
1422
+ ) (* StatusPage , error ) {
1423
+ status , res , err := c .apiCall (ctx , http .MethodGet , fmt .Sprintf ("status-pages/%s" , ID ), nil )
1424
+ if err != nil {
1425
+ return nil , err
1426
+ }
1427
+ if status != http .StatusOK {
1428
+ return nil , fmt .Errorf ("unexpected response status %d: %q" , status , res )
1429
+ }
1430
+ var result StatusPage
1431
+ err = json .NewDecoder (strings .NewReader (res )).Decode (& result )
1432
+ if err != nil {
1433
+ return nil , fmt .Errorf ("decoding error for data %q: %v" , res , err )
1434
+ }
1435
+ return & result , nil
1436
+ }
1437
+
1438
+ func (c * client ) UpdateStatusPage (
1439
+ ctx context.Context ,
1440
+ ID string ,
1441
+ page StatusPage ,
1442
+ ) (* StatusPage , error ) {
1443
+ data , err := json .Marshal (page )
1444
+ if err != nil {
1445
+ return nil , err
1446
+ }
1447
+ status , res , err := c .apiCall (ctx , http .MethodPut , fmt .Sprintf ("status-pages/%s" , ID ), data )
1448
+ if err != nil {
1449
+ return nil , err
1450
+ }
1451
+ if status != http .StatusOK {
1452
+ return nil , fmt .Errorf ("unexpected response status: %d, res: %q" , status , res )
1453
+ }
1454
+ var result StatusPage
1455
+ err = json .NewDecoder (strings .NewReader (res )).Decode (& result )
1456
+ if err != nil {
1457
+ return nil , fmt .Errorf ("decoding error for data %s: %v" , res , err )
1458
+ }
1459
+ return & result , nil
1460
+ }
1461
+
1462
+ func (c * client ) DeleteStatusPage (
1463
+ ctx context.Context ,
1464
+ ID string ,
1465
+ ) error {
1466
+ status , res , err := c .apiCall (ctx , http .MethodDelete , fmt .Sprintf ("status-pages/%s" , ID ), nil )
1467
+ if err != nil {
1468
+ return err
1469
+ }
1470
+ if status != http .StatusNoContent {
1471
+ return fmt .Errorf ("unexpected response status %d: %q" , status , res )
1472
+ }
1473
+ return nil
1474
+ }
1475
+
1476
+ func (c * client ) CreateStatusPageService (
1477
+ ctx context.Context ,
1478
+ service StatusPageService ,
1479
+ ) (* StatusPageService , error ) {
1480
+ data , err := json .Marshal (service )
1481
+ if err != nil {
1482
+ return nil , err
1483
+ }
1484
+ status , res , err := c .apiCall (ctx , http .MethodPost , "status-pages/services" , data )
1485
+ if err != nil {
1486
+ return nil , err
1487
+ }
1488
+ if status != http .StatusCreated {
1489
+ return nil , fmt .Errorf ("unexpected response status: %d, res: %q" , status , res )
1490
+ }
1491
+ var result StatusPageService
1492
+ err = json .NewDecoder (strings .NewReader (res )).Decode (& result )
1493
+ if err != nil {
1494
+ return nil , fmt .Errorf ("decoding error for data %s: %v" , res , err )
1495
+ }
1496
+ return & result , nil
1497
+ }
1498
+
1499
+ func (c * client ) GetStatusPageService (
1500
+ ctx context.Context ,
1501
+ ID string ,
1502
+ ) (* StatusPageService , error ) {
1503
+ status , res , err := c .apiCall (ctx , http .MethodGet , fmt .Sprintf ("status-pages/services/%s" , ID ), nil )
1504
+ if err != nil {
1505
+ return nil , err
1506
+ }
1507
+ if status != http .StatusOK {
1508
+ return nil , fmt .Errorf ("unexpected response status %d: %q" , status , res )
1509
+ }
1510
+ var result StatusPageService
1511
+ err = json .NewDecoder (strings .NewReader (res )).Decode (& result )
1512
+ if err != nil {
1513
+ return nil , fmt .Errorf ("decoding error for data %q: %v" , res , err )
1514
+ }
1515
+ return & result , nil
1516
+ }
1517
+
1518
+ func (c * client ) UpdateStatusPageService (
1519
+ ctx context.Context ,
1520
+ ID string ,
1521
+ service StatusPageService ,
1522
+ ) (* StatusPageService , error ) {
1523
+ data , err := json .Marshal (service )
1524
+ if err != nil {
1525
+ return nil , err
1526
+ }
1527
+ status , res , err := c .apiCall (ctx , http .MethodPut , fmt .Sprintf ("status-pages/services/%s" , ID ), data )
1528
+ if err != nil {
1529
+ return nil , err
1530
+ }
1531
+ if status != http .StatusOK {
1532
+ return nil , fmt .Errorf ("unexpected response status: %d, res: %q" , status , res )
1533
+ }
1534
+ var result StatusPageService
1535
+ err = json .NewDecoder (strings .NewReader (res )).Decode (& result )
1536
+ if err != nil {
1537
+ return nil , fmt .Errorf ("decoding error for data %s: %v" , res , err )
1538
+ }
1539
+ return & result , nil
1540
+ }
1541
+
1542
+ func (c * client ) DeleteStatusPageService (
1543
+ ctx context.Context ,
1544
+ ID string ,
1545
+ ) error {
1546
+ status , res , err := c .apiCall (ctx , http .MethodDelete , fmt .Sprintf ("status-pages/services/%s" , ID ), nil )
1547
+ if err != nil {
1548
+ return err
1549
+ }
1550
+ if status != http .StatusNoContent {
1551
+ return fmt .Errorf ("unexpected response status %d: %q" , status , res )
1552
+ }
1553
+ return nil
1554
+ }
1555
+
1396
1556
func payloadFromAlertChannel (ac AlertChannel ) map [string ]interface {} {
1397
1557
payload := map [string ]interface {}{
1398
1558
"id" : ac .ID ,
0 commit comments