github.com/sacloud/iaas-api-go@v1.12.0/internal/define/note.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  	noteAPIName     = "Note"
    27  	noteAPIPathName = "note"
    28  )
    29  
    30  var noteAPI = &dsl.Resource{
    31  	Name:       noteAPIName,
    32  	PathName:   noteAPIPathName,
    33  	PathSuffix: dsl.CloudAPISuffix,
    34  	IsGlobal:   true,
    35  	Operations: dsl.Operations{
    36  		// find
    37  		ops.Find(noteAPIName, noteNakedType, findParameter, noteView),
    38  
    39  		// create
    40  		ops.Create(noteAPIName, noteNakedType, noteCreateParam, noteView),
    41  
    42  		// read
    43  		ops.Read(noteAPIName, noteNakedType, noteView),
    44  
    45  		// update
    46  		ops.Update(noteAPIName, noteNakedType, noteUpdateParam, noteView),
    47  
    48  		// delete
    49  		ops.Delete(noteAPIName),
    50  	},
    51  }
    52  
    53  var (
    54  	noteNakedType = meta.Static(naked.Note{})
    55  
    56  	noteView = &dsl.Model{
    57  		Name:      noteAPIName,
    58  		NakedType: noteNakedType,
    59  		Fields: []*dsl.FieldDesc{
    60  			fields.ID(),
    61  			fields.Name(),
    62  			fields.Description(),
    63  			fields.Tags(),
    64  			fields.Availability(),
    65  			fields.Scope(),
    66  			fields.NoteClass(),
    67  			fields.NoteContent(),
    68  			fields.IconID(),
    69  			fields.CreatedAt(),
    70  			fields.ModifiedAt(),
    71  		},
    72  	}
    73  
    74  	noteCreateParam = &dsl.Model{
    75  		Name:      names.CreateParameterName(noteAPIName),
    76  		NakedType: noteNakedType,
    77  		Fields: []*dsl.FieldDesc{
    78  			fields.Name(),
    79  			fields.Tags(),
    80  			fields.IconID(),
    81  			fields.NoteClass(),
    82  			fields.NoteContent(),
    83  		},
    84  	}
    85  
    86  	noteUpdateParam = &dsl.Model{
    87  		Name:      names.UpdateParameterName(noteAPIName),
    88  		NakedType: noteNakedType,
    89  		Fields: []*dsl.FieldDesc{
    90  			fields.Name(),
    91  			fields.Tags(),
    92  			fields.IconID(),
    93  			fields.NoteClass(),
    94  			fields.NoteContent(),
    95  		},
    96  	}
    97  )