github.com/sacloud/iaas-api-go@v1.12.0/internal/define/icon.go (about)

     1  // Copyright 2022-2023 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 define
    16  
    17  import (
    18  	"github.com/sacloud/iaas-api-go/internal/define/names"
    19  	"github.com/sacloud/iaas-api-go/internal/define/ops"
    20  	"github.com/sacloud/iaas-api-go/internal/dsl"
    21  	"github.com/sacloud/iaas-api-go/internal/dsl/meta"
    22  	"github.com/sacloud/iaas-api-go/naked"
    23  )
    24  
    25  const (
    26  	iconAPIName     = "Icon"
    27  	iconAPIPathName = "icon"
    28  )
    29  
    30  // iconAPI アイコンAPI
    31  //
    32  // Note: libsacloudでは画像データ取得(GET /icon/:id?Size=[small|medium|large])はサポートしない。
    33  var iconAPI = &dsl.Resource{
    34  	Name:       iconAPIName,
    35  	PathName:   iconAPIPathName,
    36  	PathSuffix: dsl.CloudAPISuffix,
    37  	IsGlobal:   true,
    38  	Operations: dsl.Operations{
    39  		// find
    40  		ops.Find(iconAPIName, iconNakedType, findParameter, iconView),
    41  
    42  		// create
    43  		ops.Create(iconAPIName, iconNakedType, iconCreateParam, iconView),
    44  
    45  		// read
    46  		ops.Read(iconAPIName, iconNakedType, iconView),
    47  
    48  		// update
    49  		ops.Update(iconAPIName, iconNakedType, iconUpdateParam, iconView),
    50  
    51  		// delete
    52  		ops.Delete(iconAPIName),
    53  	},
    54  }
    55  
    56  var (
    57  	iconNakedType = meta.Static(naked.Icon{})
    58  
    59  	iconView = &dsl.Model{
    60  		Name:      iconAPIName,
    61  		NakedType: iconNakedType,
    62  		Fields: []*dsl.FieldDesc{
    63  			fields.ID(),
    64  			fields.Name(),
    65  			fields.Tags(),
    66  			fields.Availability(),
    67  			fields.Scope(),
    68  			fields.IconURL(),
    69  			fields.CreatedAt(),
    70  			fields.ModifiedAt(),
    71  		},
    72  	}
    73  	iconCreateParam = &dsl.Model{
    74  		Name:      names.CreateParameterName(iconAPIName),
    75  		NakedType: iconNakedType,
    76  		Fields: []*dsl.FieldDesc{
    77  			fields.Name(),
    78  			fields.Tags(),
    79  			fields.IconImage(),
    80  		},
    81  	}
    82  
    83  	iconUpdateParam = &dsl.Model{
    84  		Name:      names.UpdateParameterName(iconAPIName),
    85  		NakedType: iconNakedType,
    86  		Fields: []*dsl.FieldDesc{
    87  			fields.Name(),
    88  			fields.Tags(),
    89  		},
    90  	}
    91  )