github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dis/v2/streams/CreatePolicyRule.go (about)

     1  package streams
     2  
     3  import (
     4  	golangsdk "github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/internal/build"
     6  )
     7  
     8  type CreatePolicyRuleOpts struct {
     9  	// Name of the stream for which you want to add an authorization policy.
    10  	// Maximum: 64
    11  	StreamName string `json:"stream_name" required:"true"`
    12  	// Unique ID of the stream.
    13  	StreamId string `json:"stream_id"`
    14  	// Authorized users.
    15  	// If the permission is granted to a specified tenant, the format is domainName.*.
    16  	// If the permission is granted to a specified sub-user of a tenant, the format is domainName.userName.
    17  	// Multiple accounts can be added and separated by commas (,),
    18  	// for example, domainName1.userName1,do mainName2.userName2.
    19  	PrincipalName string `json:"principal_name"`
    20  	// Authorization operation type.
    21  	// - putRecords: upload data.
    22  	// - getRecords: download data.
    23  	// Enumeration values:
    24  	// putRecords
    25  	// getRecords
    26  	ActionType string `json:"action_type"`
    27  	// Authorization impact type.
    28  	// - accept: The authorization operation is allowed.
    29  	// Enumeration values:
    30  	// - accept
    31  	Effect string `json:"effect"`
    32  }
    33  
    34  func CreatePolicyRule(client *golangsdk.ServiceClient, opts CreatePolicyRuleOpts) error {
    35  	b, err := build.RequestBody(opts, "")
    36  	if err != nil {
    37  		return err
    38  	}
    39  
    40  	// POST /v2/{project_id}/streams/{stream_name}/policies
    41  	_, err = client.Post(client.ServiceURL("streams", opts.StreamName, "policies"), b, nil, &golangsdk.RequestOpts{
    42  		OkCodes: []int{200},
    43  	})
    44  	return err
    45  }