Skip to content

Barbican V1: Allow multiple ACL types in one request #1763

@kayrus

Description

@kayrus

Current implementation supports one call per type. Even though it is not yet supported in Barbican to have an ACL type other than "read", for the future it would be nice to handle multiple ACL types at one call and avoid complex logic in dependent applications. I expect gophercloud to construct json request like:

{
  "read": {
    "project-access": false,
    "users": [
      "GG27dVwR9gBMnsOaRoJ1DFJmZfdVjIdW"
    ]
  },
  "write": {
    "project-access": true,
    "users": [
      "35t0SzHNIpfiCWppFNpcyDmPQCsESiB1"
    ]
  }
}`

I propose the following modification to

// SetOpts represents options to set an ACL on a resource.
type SetOpts []SetOpt

// ToACLSetMap formats a SetOpts into a set request.
func (opts SetOpts) ToACLSetMap() (map[string]interface{}, error) {
        b := make(map[string]interface{})
        for _, v := range opts {
                m, err := gophercloud.BuildRequestBody(v, v.Type)
                if err != nil {
                        return nil, err
                }
                b[v.Type] = m[v.Type]
        }
        return b, nil
}

https://github.com/openstack/barbican/blob/c40ef6f7d865858a26b934be52e193ab2fb3fd26/barbican/common/validators.py#L45

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions