...

Source file src/github.com/Azure/azure-sdk-for-go/storage/storagepolicy.go

Documentation: github.com/Azure/azure-sdk-for-go/storage

     1  package storage
     2  
     3  // Copyright (c) Microsoft Corporation. All rights reserved.
     4  // Licensed under the MIT License. See License.txt in the project root for license information.
     5  
     6  import (
     7  	"strings"
     8  	"time"
     9  )
    10  
    11  // AccessPolicyDetailsXML has specifics about an access policy
    12  // annotated with XML details.
    13  type AccessPolicyDetailsXML struct {
    14  	StartTime  time.Time `xml:"Start"`
    15  	ExpiryTime time.Time `xml:"Expiry"`
    16  	Permission string    `xml:"Permission"`
    17  }
    18  
    19  // SignedIdentifier is a wrapper for a specific policy
    20  type SignedIdentifier struct {
    21  	ID           string                 `xml:"Id"`
    22  	AccessPolicy AccessPolicyDetailsXML `xml:"AccessPolicy"`
    23  }
    24  
    25  // SignedIdentifiers part of the response from GetPermissions call.
    26  type SignedIdentifiers struct {
    27  	SignedIdentifiers []SignedIdentifier `xml:"SignedIdentifier"`
    28  }
    29  
    30  // AccessPolicy is the response type from the GetPermissions call.
    31  type AccessPolicy struct {
    32  	SignedIdentifiersList SignedIdentifiers `xml:"SignedIdentifiers"`
    33  }
    34  
    35  // convertAccessPolicyToXMLStructs converts between AccessPolicyDetails which is a struct better for API usage to the
    36  // AccessPolicy struct which will get converted to XML.
    37  func convertAccessPolicyToXMLStructs(id string, startTime time.Time, expiryTime time.Time, permissions string) SignedIdentifier {
    38  	return SignedIdentifier{
    39  		ID: id,
    40  		AccessPolicy: AccessPolicyDetailsXML{
    41  			StartTime:  startTime.UTC().Round(time.Second),
    42  			ExpiryTime: expiryTime.UTC().Round(time.Second),
    43  			Permission: permissions,
    44  		},
    45  	}
    46  }
    47  
    48  func updatePermissions(permissions, permission string) bool {
    49  	return strings.Contains(permissions, permission)
    50  }
    51  

View as plain text