github.com/huaweicloud/golangsdk@v0.0.0-20210831081626-d823fe11ceba/openstack/blockstorage/extensions/quotasets/results.go (about)

     1  package quotasets
     2  
     3  import (
     4  	"github.com/huaweicloud/golangsdk"
     5  	"github.com/huaweicloud/golangsdk/pagination"
     6  )
     7  
     8  // QuotaSet is a set of operational limits that allow for control of block
     9  // storage usage.
    10  type QuotaSet struct {
    11  	// ID is project associated with this QuotaSet.
    12  	ID string `json:"id"`
    13  
    14  	// Volumes is the number of volumes that are allowed for each project.
    15  	Volumes int `json:"volumes"`
    16  
    17  	// Snapshots is the number of snapshots that are allowed for each project.
    18  	Snapshots int `json:"snapshots"`
    19  
    20  	// Gigabytes is the size (GB) of volumes and snapshots that are allowed for
    21  	// each project.
    22  	Gigabytes int `json:"gigabytes"`
    23  
    24  	// PerVolumeGigabytes is the size (GB) of volumes and snapshots that are
    25  	// allowed for each project and the specifed volume type.
    26  	PerVolumeGigabytes int `json:"per_volume_gigabytes"`
    27  
    28  	// Backups is the number of backups that are allowed for each project.
    29  	Backups int `json:"backups"`
    30  
    31  	// BackupGigabytes is the size (GB) of backups that are allowed for each
    32  	// project.
    33  	BackupGigabytes int `json:"backup_gigabytes"`
    34  }
    35  
    36  // QuotaUsageSet represents details of both operational limits of block
    37  // storage resources and the current usage of those resources.
    38  type QuotaUsageSet struct {
    39  	// ID is the project ID associated with this QuotaUsageSet.
    40  	ID string `json:"id"`
    41  
    42  	// Volumes is the volume usage information for this project, including
    43  	// in_use, limit, reserved and allocated attributes. Note: allocated
    44  	// attribute is available only when nested quota is enabled.
    45  	Volumes QuotaUsage `json:"volumes"`
    46  
    47  	// Snapshots is the snapshot usage information for this project, including
    48  	// in_use, limit, reserved and allocated attributes. Note: allocated
    49  	// attribute is available only when nested quota is enabled.
    50  	Snapshots QuotaUsage `json:"snapshots"`
    51  
    52  	// Gigabytes is the size (GB) usage information of volumes and snapshots
    53  	// for this project, including in_use, limit, reserved and allocated
    54  	// attributes. Note: allocated attribute is available only when nested
    55  	// quota is enabled.
    56  	Gigabytes QuotaUsage `json:"gigabytes"`
    57  
    58  	// PerVolumeGigabytes is the size (GB) usage information for each volume,
    59  	// including in_use, limit, reserved and allocated attributes. Note:
    60  	// allocated attribute is available only when nested quota is enabled and
    61  	// only limit is meaningful here.
    62  	PerVolumeGigabytes QuotaUsage `json:"per_volume_gigabytes"`
    63  
    64  	// Backups is the backup usage information for this project, including
    65  	// in_use, limit, reserved and allocated attributes. Note: allocated
    66  	// attribute is available only when nested quota is enabled.
    67  	Backups QuotaUsage `json:"backups"`
    68  
    69  	// BackupGigabytes is the size (GB) usage information of backup for this
    70  	// project, including in_use, limit, reserved and allocated attributes.
    71  	// Note: allocated attribute is available only when nested quota is
    72  	// enabled.
    73  	BackupGigabytes QuotaUsage `json:"backup_gigabytes"`
    74  }
    75  
    76  // QuotaUsage is a set of details about a single operational limit that allows
    77  // for control of block storage usage.
    78  type QuotaUsage struct {
    79  	// InUse is the current number of provisioned resources of the given type.
    80  	InUse int `json:"in_use"`
    81  
    82  	// Allocated is the current number of resources of a given type allocated
    83  	// for use.  It is only available when nested quota is enabled.
    84  	Allocated int `json:"allocated"`
    85  
    86  	// Reserved is a transitional state when a claim against quota has been made
    87  	// but the resource is not yet fully online.
    88  	Reserved int `json:"reserved"`
    89  
    90  	// Limit is the maximum number of a given resource that can be
    91  	// allocated/provisioned.  This is what "quota" usually refers to.
    92  	Limit int `json:"limit"`
    93  }
    94  
    95  // QuotaSetPage stores a single page of all QuotaSet results from a List call.
    96  type QuotaSetPage struct {
    97  	pagination.SinglePageBase
    98  }
    99  
   100  // IsEmpty determines whether or not a QuotaSetsetPage is empty.
   101  func (r QuotaSetPage) IsEmpty() (bool, error) {
   102  	ks, err := ExtractQuotaSets(r)
   103  	return len(ks) == 0, err
   104  }
   105  
   106  // ExtractQuotaSets interprets a page of results as a slice of QuotaSets.
   107  func ExtractQuotaSets(r pagination.Page) ([]QuotaSet, error) {
   108  	var s struct {
   109  		QuotaSets []QuotaSet `json:"quotas"`
   110  	}
   111  	err := (r.(QuotaSetPage)).ExtractInto(&s)
   112  	return s.QuotaSets, err
   113  }
   114  
   115  type quotaResult struct {
   116  	golangsdk.Result
   117  }
   118  
   119  // Extract is a method that attempts to interpret any QuotaSet resource response
   120  // as a QuotaSet struct.
   121  func (r quotaResult) Extract() (*QuotaSet, error) {
   122  	var s struct {
   123  		QuotaSet *QuotaSet `json:"quota_set"`
   124  	}
   125  	err := r.ExtractInto(&s)
   126  	return s.QuotaSet, err
   127  }
   128  
   129  // GetResult is the response from a Get operation. Call its Extract method to
   130  // interpret it as a QuotaSet.
   131  type GetResult struct {
   132  	quotaResult
   133  }
   134  
   135  // UpdateResult is the response from a Update operation. Call its Extract method
   136  // to interpret it as a QuotaSet.
   137  type UpdateResult struct {
   138  	quotaResult
   139  }
   140  
   141  type quotaUsageResult struct {
   142  	golangsdk.Result
   143  }
   144  
   145  // GetUsageResult is the response from a Get operation. Call its Extract
   146  // method to interpret it as a QuotaSet.
   147  type GetUsageResult struct {
   148  	quotaUsageResult
   149  }
   150  
   151  // Extract is a method that attempts to interpret any QuotaUsageSet resource
   152  // response as a set of QuotaUsageSet structs.
   153  func (r quotaUsageResult) Extract() (QuotaUsageSet, error) {
   154  	var s struct {
   155  		QuotaUsageSet QuotaUsageSet `json:"quota_set"`
   156  	}
   157  	err := r.ExtractInto(&s)
   158  	return s.QuotaUsageSet, err
   159  }
   160  
   161  // DeleteResult is the response from a Delete operation. Call its ExtractErr
   162  // method to determine if the request succeeded or failed.
   163  type DeleteResult struct {
   164  	golangsdk.ErrResult
   165  }