github.com/sacloud/iaas-api-go@v1.12.0/internal/define/auth_status.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  	"net/http"
    19  
    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  	"github.com/sacloud/iaas-api-go/types"
    24  )
    25  
    26  const (
    27  	authStatusAPIName  = "AuthStatus"
    28  	authStatusPathName = "auth-status"
    29  )
    30  
    31  var authStatusAPI = &dsl.Resource{
    32  	Name:       authStatusAPIName,
    33  	PathName:   authStatusPathName,
    34  	PathSuffix: dsl.CloudAPISuffix,
    35  	IsGlobal:   true,
    36  	Operations: dsl.Operations{
    37  		{
    38  			ResourceName: authStatusAPIName,
    39  			Name:         "Read",
    40  			Method:       http.MethodGet,
    41  			PathFormat:   dsl.DefaultPathFormat,
    42  			ResponseEnvelope: dsl.ResponseEnvelope(
    43  				&dsl.EnvelopePayloadDesc{
    44  					Name: authStatusAPIName,
    45  					Type: authStatusNakedType,
    46  				},
    47  			),
    48  			Results: dsl.Results{
    49  				{
    50  					SourceField: authStatusAPIName,
    51  					DestField:   authStatusView.Name,
    52  					IsPlural:    false,
    53  					Model:       authStatusView,
    54  				},
    55  			},
    56  		},
    57  	},
    58  }
    59  
    60  var (
    61  	authStatusNakedType = meta.Static(naked.AuthStatus{})
    62  	authStatusView      = &dsl.Model{
    63  		Name:      "AuthStatus",
    64  		NakedType: authStatusNakedType,
    65  		Fields: []*dsl.FieldDesc{
    66  			fields.Def("AccountID", meta.TypeID, mapConvTag("Account.ID")),
    67  			fields.Def("AccountName", meta.TypeString, mapConvTag("Account.Name")),
    68  			fields.Def("AccountCode", meta.TypeString, mapConvTag("Account.Code")),
    69  			fields.Def("AccountClass", meta.TypeString, mapConvTag("Account.Class")),
    70  			fields.Def("MemberCode", meta.TypeString, mapConvTag("Member.Code")),
    71  			fields.Def("MemberClass", meta.TypeString, mapConvTag("Member.Class")),
    72  			fields.Def("AuthClass", meta.Static(types.EAuthClass(""))),
    73  			fields.Def("AuthMethod", meta.Static(types.EAuthMethod(""))),
    74  			fields.Def("IsAPIKey", meta.TypeFlag),
    75  			fields.Def("ExternalPermission", meta.Static(types.ExternalPermission(""))),
    76  			fields.Def("OperationPenalty", meta.Static(types.EOperationPenalty(""))),
    77  			fields.Def("Permission", meta.Static(types.EPermission(""))),
    78  		},
    79  	}
    80  )