# Apps ## List Apps `client.MagicTransit.Apps.List(ctx, query) (*SinglePage[AppListResponse], error)` **get** `/accounts/{account_id}/magic/apps` Lists Apps associated with an account. ### Parameters - `query AppListParams` - `AccountID param.Field[string]` Identifier ### Returns - `type AppListResponse interface{…}` Collection of Hostnames and/or IP Subnets to associate with traffic decisions. - `type AppListResponseMagicAccountApp struct{…}` Custom app defined for an account. - `AccountAppID string` Magic account app ID. - `Hostnames []string` FQDNs to associate with traffic decisions. - `IPSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Name string` Display name for the app. - `SourceSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Type string` Category of the app. - `type AppListResponseMagicManagedApp struct{…}` Managed app defined by Cloudflare. - `ManagedAppID string` Managed app ID. - `Hostnames []string` FQDNs to associate with traffic decisions. - `IPSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Name string` Display name for the app. - `SourceSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Type string` Category of the app. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) page, err := client.MagicTransit.Apps.List(context.TODO(), magic_transit.AppListParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", page) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": [ { "account_app_id": "ac60d3d0435248289d446cedd870bcf4", "hostnames": [ "auth.cloudflare.com" ], "ip_subnets": [ "192.0.2.0/24" ], "name": "Cloudflare Dashboard", "source_subnets": [ "192.0.2.0/24" ], "type": "Development" } ], "success": true } ``` ## Create a new App `client.MagicTransit.Apps.New(ctx, params) (*AppNewResponse, error)` **post** `/accounts/{account_id}/magic/apps` Creates a new App for an account ### Parameters - `params AppNewParams` - `AccountID param.Field[string]` Path param: Identifier - `Name param.Field[string]` Body param: Display name for the app. - `Type param.Field[string]` Body param: Category of the app. - `Hostnames param.Field[[]string]` Body param: FQDNs to associate with traffic decisions. - `IPSubnets param.Field[[]string]` Body param: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `SourceSubnets param.Field[[]string]` Body param: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) ### Returns - `type AppNewResponse struct{…}` Custom app defined for an account. - `AccountAppID string` Magic account app ID. - `Hostnames []string` FQDNs to associate with traffic decisions. - `IPSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Name string` Display name for the app. - `SourceSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Type string` Category of the app. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) app, err := client.MagicTransit.Apps.New(context.TODO(), magic_transit.AppNewParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), Name: cloudflare.F("Cloudflare Dashboard"), Type: cloudflare.F("Development"), }) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", app.AccountAppID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "account_app_id": "ac60d3d0435248289d446cedd870bcf4", "hostnames": [ "auth.cloudflare.com" ], "ip_subnets": [ "192.0.2.0/24" ], "name": "Cloudflare Dashboard", "source_subnets": [ "192.0.2.0/24" ], "type": "Development" }, "success": true } ``` ## Update an App `client.MagicTransit.Apps.Update(ctx, accountAppID, params) (*AppUpdateResponse, error)` **put** `/accounts/{account_id}/magic/apps/{account_app_id}` Updates an Account App ### Parameters - `accountAppID string` Identifier - `params AppUpdateParams` - `AccountID param.Field[string]` Path param: Identifier - `Hostnames param.Field[[]string]` Body param: FQDNs to associate with traffic decisions. - `IPSubnets param.Field[[]string]` Body param: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Name param.Field[string]` Body param: Display name for the app. - `SourceSubnets param.Field[[]string]` Body param: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Type param.Field[string]` Body param: Category of the app. ### Returns - `type AppUpdateResponse struct{…}` Custom app defined for an account. - `AccountAppID string` Magic account app ID. - `Hostnames []string` FQDNs to associate with traffic decisions. - `IPSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Name string` Display name for the app. - `SourceSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Type string` Category of the app. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) app, err := client.MagicTransit.Apps.Update( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.AppUpdateParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", app.AccountAppID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "account_app_id": "ac60d3d0435248289d446cedd870bcf4", "hostnames": [ "auth.cloudflare.com" ], "ip_subnets": [ "192.0.2.0/24" ], "name": "Cloudflare Dashboard", "source_subnets": [ "192.0.2.0/24" ], "type": "Development" }, "success": true } ``` ## Update an App `client.MagicTransit.Apps.Edit(ctx, accountAppID, params) (*AppEditResponse, error)` **patch** `/accounts/{account_id}/magic/apps/{account_app_id}` Updates an Account App ### Parameters - `accountAppID string` Identifier - `params AppEditParams` - `AccountID param.Field[string]` Path param: Identifier - `Hostnames param.Field[[]string]` Body param: FQDNs to associate with traffic decisions. - `IPSubnets param.Field[[]string]` Body param: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Name param.Field[string]` Body param: Display name for the app. - `SourceSubnets param.Field[[]string]` Body param: IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Type param.Field[string]` Body param: Category of the app. ### Returns - `type AppEditResponse struct{…}` Custom app defined for an account. - `AccountAppID string` Magic account app ID. - `Hostnames []string` FQDNs to associate with traffic decisions. - `IPSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Name string` Display name for the app. - `SourceSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Type string` Category of the app. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) response, err := client.MagicTransit.Apps.Edit( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.AppEditParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", response.AccountAppID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "account_app_id": "ac60d3d0435248289d446cedd870bcf4", "hostnames": [ "auth.cloudflare.com" ], "ip_subnets": [ "192.0.2.0/24" ], "name": "Cloudflare Dashboard", "source_subnets": [ "192.0.2.0/24" ], "type": "Development" }, "success": true } ``` ## Delete Account App `client.MagicTransit.Apps.Delete(ctx, accountAppID, body) (*AppDeleteResponse, error)` **delete** `/accounts/{account_id}/magic/apps/{account_app_id}` Deletes specific Account App. ### Parameters - `accountAppID string` Identifier - `body AppDeleteParams` - `AccountID param.Field[string]` Identifier ### Returns - `type AppDeleteResponse struct{…}` Custom app defined for an account. - `AccountAppID string` Magic account app ID. - `Hostnames []string` FQDNs to associate with traffic decisions. - `IPSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Name string` Display name for the app. - `SourceSubnets []string` IPv4 CIDRs to associate with traffic decisions. (IPv6 CIDRs are currently unsupported) - `Type string` Category of the app. ### Example ```go package main import ( "context" "fmt" "github.com/cloudflare/cloudflare-go" "github.com/cloudflare/cloudflare-go/magic_transit" "github.com/cloudflare/cloudflare-go/option" ) func main() { client := cloudflare.NewClient( option.WithAPIToken("Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY"), ) app, err := client.MagicTransit.Apps.Delete( context.TODO(), "023e105f4ecef8ad9ca31a8372d0c353", magic_transit.AppDeleteParams{ AccountID: cloudflare.F("023e105f4ecef8ad9ca31a8372d0c353"), }, ) if err != nil { panic(err.Error()) } fmt.Printf("%+v\n", app.AccountAppID) } ``` #### Response ```json { "errors": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "messages": [ { "code": 1000, "message": "message", "documentation_url": "documentation_url", "source": { "pointer": "pointer" } } ], "result": { "account_app_id": "ac60d3d0435248289d446cedd870bcf4", "hostnames": [ "auth.cloudflare.com" ], "ip_subnets": [ "192.0.2.0/24" ], "name": "Cloudflare Dashboard", "source_subnets": [ "192.0.2.0/24" ], "type": "Development" }, "success": true } ```