github.com/sacloud/iaas-api-go@v1.12.0/internal/define/license.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  	licenseAPIName     = "License"
    27  	licenseAPIPathName = "license"
    28  )
    29  
    30  var licenseAPI = &dsl.Resource{
    31  	Name:       licenseAPIName,
    32  	PathName:   licenseAPIPathName,
    33  	PathSuffix: dsl.CloudAPISuffix,
    34  	IsGlobal:   true,
    35  	Operations: dsl.Operations{
    36  		// find
    37  		ops.Find(licenseAPIName, licenseNakedType, findParameter, licenseView),
    38  
    39  		// create
    40  		ops.Create(licenseAPIName, licenseNakedType, licenseCreateParam, licenseView),
    41  
    42  		// read
    43  		ops.Read(licenseAPIName, licenseNakedType, licenseView),
    44  
    45  		// update
    46  		ops.Update(licenseAPIName, licenseNakedType, licenseUpdateParam, licenseView),
    47  
    48  		// delete
    49  		ops.Delete(licenseAPIName),
    50  	},
    51  }
    52  
    53  var (
    54  	licenseNakedType = meta.Static(naked.License{})
    55  
    56  	licenseView = &dsl.Model{
    57  		Name:      licenseAPIName,
    58  		NakedType: licenseNakedType,
    59  		Fields: []*dsl.FieldDesc{
    60  			fields.ID(),
    61  			fields.Name(),
    62  			fields.LicenseInfoID(),
    63  			fields.LicenseInfoName(),
    64  			fields.CreatedAt(),
    65  			fields.ModifiedAt(),
    66  		},
    67  	}
    68  
    69  	licenseCreateParam = &dsl.Model{
    70  		Name:      names.CreateParameterName(licenseAPIName),
    71  		NakedType: licenseNakedType,
    72  		Fields: []*dsl.FieldDesc{
    73  			fields.Name(),
    74  			fields.LicenseInfoID(),
    75  		},
    76  	}
    77  
    78  	licenseUpdateParam = &dsl.Model{
    79  		Name:      names.UpdateParameterName(licenseAPIName),
    80  		NakedType: licenseNakedType,
    81  		Fields: []*dsl.FieldDesc{
    82  			fields.Name(),
    83  		},
    84  	}
    85  )