All Products
Search
Document Center

Media asset category

Last Updated: Jul 11, 2019

Initialize a client

Initialize a client before using the SDK. For more information, see InitVodClient.

Create a category

For more information about the request and response parameters, see AddCategory.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyAddCategory(client *vod.Client) (response *vod.AddCategoryResponse, err error) {
    request := vod.CreateAddCategoryRequest()
    request.CateName = "sample category name"
    request.ParentId = "-1"
    request.AcceptFormat = "JSON"

    return client.AddCategory(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyAddCategory(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
    fmt.Println(response.Category.CateId)
}

Modify a category

For more information about the request and response parameters, see UpdateCategory.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyUpdateCategory(client *vod.Client) (response *vod.UpdateCategoryResponse, err error) {
    request := vod.CreateUpdateCategoryRequest()
    request.CateId = "<CateId>"
    request.CateName = "sample category name"
    request.AcceptFormat = "JSON"

    return client.UpdateCategory(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>")
    if err ! = nil {
        panic(err)
    }

    response, err := MyUpdateCategory(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
}

Delete a category

For more information about the request and response parameters, see DeleteCategory.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyDeleteCategory(client *vod.Client) (response *vod.DeleteCategoryResponse, err error) {
    request := vod.CreateDeleteCategoryRequest()
    request.CateId = "<CateId>"
    request.AcceptFormat = "JSON"

    return client.DeleteCategory(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyDeleteCategory(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
}

Query a category and its subcategories

For more information about the request and response parameters, see GetCategories.

package main

import (
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk"
    "github.com/aliyun/alibaba-cloud-sdk-go/services/vod"
    "github.com/aliyun/alibaba-cloud-sdk-go/sdk/auth/credentials"
    "fmt"
)

func MyGetCategories(client *vod.Client) (response *vod.GetCategoriesResponse, err error) {
    request := vod.CreateGetCategoriesRequest()
    request.CateId = "<CateId>"
    request.PageNo = "1"
    request.PageSize = "20"
    request.AcceptFormat = "JSON"

    return client.GetCategories(request)
}

func main() {
    client, err := InitVodClient("<accessKeyId>", "<accessKeySecret>") 
    if err ! = nil {
        panic(err)
    }

    response, err := MyGetCategories(client)
    if err ! = nil {
        panic(err)
    }

    fmt.Println(response.GetHttpContentString())
}