github.com/sacloud/iaas-api-go@v1.12.0/helper/query/types.go (about)

     1  // Copyright 2016-2022 The sacloud/iaas-api-go Authors
     2  //
     3  // Licensed under the Apache License, Version 2.0 (the "License");
     4  // you may not use this file except in compliance with the License.
     5  // You may obtain a copy of the License at
     6  //
     7  //      http://www.apache.org/licenses/LICENSE-2.0
     8  //
     9  // Unless required by applicable law or agreed to in writing, software
    10  // distributed under the License is distributed on an "AS IS" BASIS,
    11  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    12  // See the License for the specific language governing permissions and
    13  // limitations under the License.
    14  
    15  package query
    16  
    17  import (
    18  	"context"
    19  
    20  	"github.com/sacloud/iaas-api-go"
    21  	"github.com/sacloud/iaas-api-go/types"
    22  )
    23  
    24  // ArchiveFinder アーカイブ検索インターフェース
    25  type ArchiveFinder interface {
    26  	Find(ctx context.Context, zone string, conditions *iaas.FindCondition) (*iaas.ArchiveFindResult, error)
    27  }
    28  
    29  // NoteFinder スタートアップスクリプト(Note)検索インターフェース
    30  type NoteFinder interface {
    31  	Find(ctx context.Context, conditions *iaas.FindCondition) (*iaas.NoteFindResult, error)
    32  }
    33  
    34  // ArchiveSourceReader アーカイブソースを取得するためのインターフェース
    35  type ArchiveSourceReader struct {
    36  	ArchiveReader ArchiveReader
    37  	DiskReader    DiskReader
    38  }
    39  
    40  // NewArchiveSourceReader デフォルトのリーダーを返す
    41  func NewArchiveSourceReader(caller iaas.APICaller) *ArchiveSourceReader {
    42  	return &ArchiveSourceReader{
    43  		ArchiveReader: iaas.NewArchiveOp(caller),
    44  		DiskReader:    iaas.NewDiskOp(caller),
    45  	}
    46  }
    47  
    48  // ServerPlanFinder .
    49  type ServerPlanFinder interface {
    50  	Find(ctx context.Context, zone string, conditions *iaas.FindCondition) (*iaas.ServerPlanFindResult, error)
    51  }
    52  
    53  // ServerSourceReader サーバのコピー元情報を参照するためのリーダー
    54  type ServerSourceReader struct {
    55  	ServerReader  ServerReader
    56  	ArchiveReader ArchiveReader
    57  	DiskReader    DiskReader
    58  }
    59  
    60  // NewServerSourceReader デフォルトのリーダーを返す
    61  func NewServerSourceReader(caller iaas.APICaller) *ServerSourceReader {
    62  	return &ServerSourceReader{
    63  		ServerReader:  iaas.NewServerOp(caller),
    64  		ArchiveReader: iaas.NewArchiveOp(caller),
    65  		DiskReader:    iaas.NewDiskOp(caller),
    66  	}
    67  }
    68  
    69  // ServerReader サーバ参照インターフェース
    70  type ServerReader interface {
    71  	Read(ctx context.Context, zone string, id types.ID) (*iaas.Server, error)
    72  }
    73  
    74  // ArchiveReader アーカイブ参照インターフェース
    75  type ArchiveReader interface {
    76  	Read(ctx context.Context, zone string, id types.ID) (*iaas.Archive, error)
    77  }
    78  
    79  // DiskReader ディスク参照インターフェース
    80  type DiskReader interface {
    81  	Read(ctx context.Context, zone string, id types.ID) (*iaas.Disk, error)
    82  }