Skip to content

Latest commit

 

History

History
368 lines (242 loc) · 11.3 KB

ResourceAPI.md

File metadata and controls

368 lines (242 loc) · 11.3 KB

ResourceAPI

Note

All URIs are relative to https://api.fastly.com

Method HTTP request Description
CreateResource POST /service/{service_id}/version/{version_id}/resource Create a resource link
DeleteResource DELETE /service/{service_id}/version/{version_id}/resource/{id} Delete a resource link
GetResource GET /service/{service_id}/version/{version_id}/resource/{id} Display a resource link
ListResources GET /service/{service_id}/version/{version_id}/resource List resource links
UpdateResource PUT /service/{service_id}/version/{version_id}/resource/{id} Update a resource link

CreateResource

Create a resource link

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.
    versionID := int32(56) // int32 | Integer identifying a service version.
    resourceID := "resourceId_example" // string | The ID of the underlying linked resource. (optional)
    name := "name_example" // string | The name of the resource link. (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ResourceAPI.CreateResource(ctx, serviceID, versionID).ResourceID(resourceID).Name(name).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ResourceAPI.CreateResource`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `CreateResource`: ResourceResponse
    fmt.Fprintf(os.Stdout, "Response from `ResourceAPI.CreateResource`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.
versionID int32 Integer identifying a service version.

Other Parameters

Other parameters are passed through a pointer to a apiCreateResourceRequest struct via the builder pattern

Name Type Description Notes
resourceID string The ID of the underlying linked resource. name

Return type

ResourceResponse

Authorization

API Token

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

Back to top | Back to API list | Back to README

DeleteResource

Delete a resource link

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.
    versionID := int32(56) // int32 | Integer identifying a service version.
    id := "id_example" // string | An alphanumeric string identifying the resource link.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ResourceAPI.DeleteResource(ctx, serviceID, versionID, id).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ResourceAPI.DeleteResource`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `DeleteResource`: InlineResponse200
    fmt.Fprintf(os.Stdout, "Response from `ResourceAPI.DeleteResource`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.
versionID int32 Integer identifying a service version.
id string An alphanumeric string identifying the resource link.

Other Parameters

Other parameters are passed through a pointer to a apiDeleteResourceRequest struct via the builder pattern

Name Type Description Notes

Return type

InlineResponse200

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

GetResource

Display a resource link

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.
    versionID := int32(56) // int32 | Integer identifying a service version.
    id := "id_example" // string | An alphanumeric string identifying the resource link.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ResourceAPI.GetResource(ctx, serviceID, versionID, id).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ResourceAPI.GetResource`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `GetResource`: ResourceResponse
    fmt.Fprintf(os.Stdout, "Response from `ResourceAPI.GetResource`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.
versionID int32 Integer identifying a service version.
id string An alphanumeric string identifying the resource link.

Other Parameters

Other parameters are passed through a pointer to a apiGetResourceRequest struct via the builder pattern

Name Type Description Notes

Return type

ResourceResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

ListResources

List resource links

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.
    versionID := int32(56) // int32 | Integer identifying a service version.

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ResourceAPI.ListResources(ctx, serviceID, versionID).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ResourceAPI.ListResources`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `ListResources`: []ResourceResponse
    fmt.Fprintf(os.Stdout, "Response from `ResourceAPI.ListResources`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.
versionID int32 Integer identifying a service version.

Other Parameters

Other parameters are passed through a pointer to a apiListResourcesRequest struct via the builder pattern

Name Type Description Notes

Return type

[]ResourceResponse

Authorization

API Token

HTTP request headers

  • Content-Type: Not defined
  • Accept: application/json

Back to top | Back to API list | Back to README

UpdateResource

Update a resource link

Example

package main

import (
    "context"
    "fmt"
    "os"
    "github.com/fastly/fastly-go/fastly"
)

func main() {
    serviceID := "serviceId_example" // string | Alphanumeric string identifying the service.
    versionID := int32(56) // int32 | Integer identifying a service version.
    id := "id_example" // string | An alphanumeric string identifying the resource link.
    resourceID := "resourceId_example" // string | The ID of the underlying linked resource. (optional)
    name := "name_example" // string | The name of the resource link. (optional)

    cfg := fastly.NewConfiguration()
    apiClient := fastly.NewAPIClient(cfg)
    ctx := fastly.NewAPIKeyContextFromEnv("FASTLY_API_TOKEN")
    resp, r, err := apiClient.ResourceAPI.UpdateResource(ctx, serviceID, versionID, id).ResourceID(resourceID).Name(name).Execute()
    if err != nil {
        fmt.Fprintf(os.Stderr, "Error when calling `ResourceAPI.UpdateResource`: %v\n", err)
        fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
    }
    // response from `UpdateResource`: ResourceResponse
    fmt.Fprintf(os.Stdout, "Response from `ResourceAPI.UpdateResource`: %v\n", resp)
}

Path Parameters

Name Type Description Notes
ctx context.Context context for authentication, logging, cancellation, deadlines, tracing, etc.
serviceID string Alphanumeric string identifying the service.
versionID int32 Integer identifying a service version.
id string An alphanumeric string identifying the resource link.

Other Parameters

Other parameters are passed through a pointer to a apiUpdateResourceRequest struct via the builder pattern

Name Type Description Notes
resourceID string The ID of the underlying linked resource. name

Return type

ResourceResponse

Authorization

API Token

HTTP request headers

  • Content-Type: application/x-www-form-urlencoded
  • Accept: application/json

Back to top | Back to API list | Back to README