@@ -51,6 +51,9 @@ type AppsService interface {
51
51
UpdateAlertDestinations (ctx context.Context , appID , alertID string , update * AlertDestinationUpdateRequest ) (* AppAlert , * Response , error )
52
52
53
53
Detect (ctx context.Context , detect * DetectRequest ) (* DetectResponse , * Response , error )
54
+
55
+ ListBuildpacks (ctx context.Context ) ([]* Buildpack , * Response , error )
56
+ UpgradeBuildpack (ctx context.Context , appID string , opts UpgradeBuildpackOptions ) (* UpgradeBuildpackResponse , * Response , error )
54
57
}
55
58
56
59
// AppLogs represent app logs.
@@ -75,6 +78,16 @@ type AlertDestinationUpdateRequest struct {
75
78
SlackWebhooks []* AppAlertSlackWebhook `json:"slack_webhooks"`
76
79
}
77
80
81
+ // UpgradeBuildpackOptions struct for UpgradeBuildpackOptions
82
+ type UpgradeBuildpackOptions struct {
83
+ // The ID of the buildpack to upgrade.
84
+ BuildpackID string `json:"buildpack_id,omitempty"`
85
+ // The Major Version to upgrade the buildpack to. If omitted, the latest available major version will be used.
86
+ MajorVersion int32 `json:"major_version,omitempty"`
87
+ // Whether or not to trigger a deployment for the app after upgrading the buildpack.
88
+ TriggerDeployment bool `json:"trigger_deployment,omitempty"`
89
+ }
90
+
78
91
type appRoot struct {
79
92
App * App `json:"app"`
80
93
}
@@ -123,6 +136,10 @@ type appAlertRoot struct {
123
136
Alert * AppAlert `json:"alert"`
124
137
}
125
138
139
+ type buildpacksRoot struct {
140
+ Buildpacks []* Buildpack `json:"buildpacks,omitempty"`
141
+ }
142
+
126
143
// AppsServiceOp handles communication with Apps methods of the DigitalOcean API.
127
144
type AppsServiceOp struct {
128
145
client * Client
@@ -444,6 +461,36 @@ func (s *AppsServiceOp) Detect(ctx context.Context, detect *DetectRequest) (*Det
444
461
return res , resp , nil
445
462
}
446
463
464
+ // ListBuildpacks lists the available buildpacks on App Platform.
465
+ func (s * AppsServiceOp ) ListBuildpacks (ctx context.Context ) ([]* Buildpack , * Response , error ) {
466
+ path := fmt .Sprintf ("%s/buildpacks" , appsBasePath )
467
+ req , err := s .client .NewRequest (ctx , http .MethodGet , path , nil )
468
+ if err != nil {
469
+ return nil , nil , err
470
+ }
471
+ root := new (buildpacksRoot )
472
+ resp , err := s .client .Do (ctx , req , root )
473
+ if err != nil {
474
+ return nil , resp , err
475
+ }
476
+ return root .Buildpacks , resp , nil
477
+ }
478
+
479
+ // UpgradeBuildpack upgrades a buildpack for an app.
480
+ func (s * AppsServiceOp ) UpgradeBuildpack (ctx context.Context , appID string , opts UpgradeBuildpackOptions ) (* UpgradeBuildpackResponse , * Response , error ) {
481
+ path := fmt .Sprintf ("%s/%s/upgrade_buildpack" , appsBasePath , appID )
482
+ req , err := s .client .NewRequest (ctx , http .MethodPost , path , opts )
483
+ if err != nil {
484
+ return nil , nil , err
485
+ }
486
+ root := new (UpgradeBuildpackResponse )
487
+ resp , err := s .client .Do (ctx , req , root )
488
+ if err != nil {
489
+ return nil , resp , err
490
+ }
491
+ return root , resp , nil
492
+ }
493
+
447
494
// AppComponentType is an app component type.
448
495
type AppComponentType string
449
496
0 commit comments