github.com/opentelekomcloud/gophertelekomcloud@v0.9.3/openstack/dns/v2/zones/results.go (about)

     1  package zones
     2  
     3  import (
     4  	"github.com/opentelekomcloud/gophertelekomcloud"
     5  	"github.com/opentelekomcloud/gophertelekomcloud/pagination"
     6  )
     7  
     8  type commonResult struct {
     9  	golangsdk.Result
    10  }
    11  
    12  // Extract interprets a GetResult, CreateResult or UpdateResult as a Zone.
    13  // An error is returned if the original call or the extraction failed.
    14  func (r commonResult) Extract() (*Zone, error) {
    15  	var s *Zone
    16  	err := r.ExtractInto(&s)
    17  	return s, err
    18  }
    19  
    20  // CreateResult is the result of a Create request. Call its Extract method
    21  // to interpret the result as a Zone.
    22  type CreateResult struct {
    23  	commonResult
    24  }
    25  
    26  // GetResult is the result of a Get request. Call its Extract method
    27  // to interpret the result as a Zone.
    28  type GetResult struct {
    29  	commonResult
    30  }
    31  
    32  // UpdateResult is the result of an Update request. Call its Extract method
    33  // to interpret the result as a Zone.
    34  type UpdateResult struct {
    35  	commonResult
    36  }
    37  
    38  // DeleteResult is the result of a Delete request. Call its ExtractErr method
    39  // to determine if the request succeeded or failed.
    40  type DeleteResult struct {
    41  	commonResult
    42  }
    43  
    44  // ZonePage is a single page of Zone results.
    45  type ZonePage struct {
    46  	pagination.LinkedPageBase
    47  }
    48  
    49  // IsEmpty returns true if the page contains no results.
    50  func (r ZonePage) IsEmpty() (bool, error) {
    51  	s, err := ExtractZones(r)
    52  	return len(s) == 0, err
    53  }
    54  
    55  // ExtractZones extracts a slice of Zones from a List result.
    56  func ExtractZones(r pagination.Page) ([]Zone, error) {
    57  	var s struct {
    58  		Zones []Zone `json:"zones"`
    59  	}
    60  	err := (r.(ZonePage)).ExtractInto(&s)
    61  	return s.Zones, err
    62  }
    63  
    64  // Zone represents a DNS zone.
    65  type Zone struct {
    66  	// ID uniquely identifies this zone amongst all other zones, including those
    67  	// not accessible to the current tenant.
    68  	ID string `json:"id"`
    69  
    70  	// PoolID is the ID for the pool hosting this zone.
    71  	PoolID string `json:"pool_id"`
    72  
    73  	// ProjectID identifies the project/tenant owning this resource.
    74  	ProjectID string `json:"project_id"`
    75  
    76  	// Name is the DNS Name for the zone.
    77  	Name string `json:"name"`
    78  
    79  	// Email for the zone. Used in SOA records for the zone.
    80  	Email string `json:"email"`
    81  
    82  	// Description for this zone.
    83  	Description string `json:"description"`
    84  
    85  	// TTL is the Time to Live for the zone.
    86  	TTL int `json:"ttl"`
    87  
    88  	// Serial is the current serial number for the zone.
    89  	Serial int `json:"serial"`
    90  
    91  	// Status is the status of the resource.
    92  	Status string `json:"status"`
    93  
    94  	ZoneType string `json:"zone_type"`
    95  
    96  	RecordNum int `json:"record_num"`
    97  
    98  	// Masters is the servers for slave servers to get DNS information from.
    99  	Masters []string `json:"masters"`
   100  
   101  	// CreatedAt is the date when the zone was created.
   102  	CreatedAt string `json:"created_at"`
   103  
   104  	// UpdatedAt is the date when the last change was made to the zone.
   105  	UpdatedAt string `json:"updated_at"`
   106  
   107  	// Links includes HTTP references to the itself, useful for passing along
   108  	// to other APIs that might want a server reference.
   109  	Links map[string]interface{} `json:"links"`
   110  
   111  	// Routers associate with the Zone
   112  	Routers []RouterResult `json:"routers"`
   113  }
   114  
   115  type RouterResult struct {
   116  	RouterID     string `json:"router_id"`
   117  	RouterRegion string `json:"router_region"`
   118  	Status       string `json:"status"`
   119  }
   120  
   121  // AssociateResult is the response from AssociateZone
   122  type AssociateResult struct {
   123  	commonResult
   124  }
   125  
   126  // DisassociateResult is the response from DisassociateZone
   127  type DisassociateResult struct {
   128  	commonResult
   129  }