github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/swr/v2/domains/Update.go (about)

     1  package domains
     2  
     3  import (
     4  	"fmt"
     5  
     6  	"github.com/opentelekomcloud/gophertelekomcloud"
     7  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     8  )
     9  
    10  type UpdateOpts struct {
    11  	// Organization name
    12  	Namespace string `json:"-" required:"true"`
    13  	// Image repository name
    14  	Repository string `json:"-" required:"true"`
    15  	// Name of the account used for image sharing
    16  	AccessDomain string `json:"-" required:"true"`
    17  	// Currently, only the read permission is supported.
    18  	Permit string `json:"permit"`
    19  	// Valid until (UTC). If the sharing is permanent, the value is forever. Otherwise, the sharing is valid until 00:00:00 of the next day.
    20  	Deadline string `json:"deadline"`
    21  	// Description. This parameter is left blank by default.
    22  	Description string `json:"description,omitempty"`
    23  }
    24  
    25  func Update(client *golangsdk.ServiceClient, opts UpdateOpts) (err error) {
    26  	b, err := build.RequestBody(opts, "")
    27  	if err != nil {
    28  		return
    29  	}
    30  
    31  	// PATCH /v2/manage/namespaces/{namespace}/repositories/{repository}/access-domains/{access_domain}
    32  	url := fmt.Sprintf("%s/%s", client.ServiceURL("manage", "namespaces", opts.Namespace, "repos", opts.Repository, "access-domains"), opts.AccessDomain)
    33  	_, err = client.Patch(url, b, nil, &golangsdk.RequestOpts{
    34  		OkCodes: []int{201},
    35  	})
    36  	return
    37  }