b7e6a929814e846e8ac5f8fcd35f21de6823f759
[ric-plt/a1.git] / a1-go / pkg / restapi / operations / a1_mediator / a1_controller_create_policy_type_parameters.go
1 /*
2 ==================================================================================
3   Copyright (c) 2021 Samsung
4
5    Licensed under the Apache License, Version 2.0 (the "License");
6    you may not use this file except in compliance with the License.
7    You may obtain a copy of the License at
8
9        http://www.apache.org/licenses/LICENSE-2.0
10
11    Unless required by applicable law or agreed to in writing, software
12    distributed under the License is distributed on an "AS IS" BASIS,
13    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14    See the License for the specific language governing permissions and
15    limitations under the License.
16
17    This source code is part of the near-RT RIC (RAN Intelligent Controller)
18    platform project (RICP).
19 ==================================================================================
20 */
21 // Code generated by go-swagger; DO NOT EDIT.
22
23 package a1_mediator
24
25 // This file was generated by the swagger tool.
26 // Editing this file might prove futile when you re-run the swagger generate command
27
28 import (
29         "net/http"
30
31         "github.com/go-openapi/errors"
32         "github.com/go-openapi/runtime"
33         "github.com/go-openapi/runtime/middleware"
34         "github.com/go-openapi/strfmt"
35         "github.com/go-openapi/swag"
36         "github.com/go-openapi/validate"
37
38         "subh.com/a1-go/pkg/models"
39 )
40
41 // NewA1ControllerCreatePolicyTypeParams creates a new A1ControllerCreatePolicyTypeParams object
42 // no default values defined in spec.
43 func NewA1ControllerCreatePolicyTypeParams() A1ControllerCreatePolicyTypeParams {
44
45         return A1ControllerCreatePolicyTypeParams{}
46 }
47
48 // A1ControllerCreatePolicyTypeParams contains all the bound params for the a1 controller create policy type operation
49 // typically these are obtained from a http.Request
50 //
51 // swagger:parameters a1.controller.create_policy_type
52 type A1ControllerCreatePolicyTypeParams struct {
53
54         // HTTP Request Object
55         HTTPRequest *http.Request `json:"-"`
56
57         /*
58           In: body
59         */
60         Body *models.PolicyTypeSchema
61         /*represents a policy type identifier. Currently this is restricted to an integer range.
62
63           Required: true
64           Maximum: 2.147483647e+09
65           Minimum: 1
66           In: path
67         */
68         PolicyTypeID int64
69 }
70
71 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
72 // for simple values it will use straight method calls.
73 //
74 // To ensure default values, the struct must have been initialized with NewA1ControllerCreatePolicyTypeParams() beforehand.
75 func (o *A1ControllerCreatePolicyTypeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
76         var res []error
77
78         o.HTTPRequest = r
79
80         if runtime.HasBody(r) {
81                 defer r.Body.Close()
82                 var body models.PolicyTypeSchema
83                 if err := route.Consumer.Consume(r.Body, &body); err != nil {
84                         res = append(res, errors.NewParseError("body", "body", "", err))
85                 } else {
86                         // validate body object
87                         if err := body.Validate(route.Formats); err != nil {
88                                 res = append(res, err)
89                         }
90
91                         if len(res) == 0 {
92                                 o.Body = &body
93                         }
94                 }
95         }
96         rPolicyTypeID, rhkPolicyTypeID, _ := route.Params.GetOK("policy_type_id")
97         if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
98                 res = append(res, err)
99         }
100
101         if len(res) > 0 {
102                 return errors.CompositeValidationError(res...)
103         }
104         return nil
105 }
106
107 // bindPolicyTypeID binds and validates parameter PolicyTypeID from path.
108 func (o *A1ControllerCreatePolicyTypeParams) bindPolicyTypeID(rawData []string, hasKey bool, formats strfmt.Registry) error {
109         var raw string
110         if len(rawData) > 0 {
111                 raw = rawData[len(rawData)-1]
112         }
113
114         // Required: true
115         // Parameter is provided by construction from the route
116
117         value, err := swag.ConvertInt64(raw)
118         if err != nil {
119                 return errors.InvalidType("policy_type_id", "path", "int64", raw)
120         }
121         o.PolicyTypeID = value
122
123         if err := o.validatePolicyTypeID(formats); err != nil {
124                 return err
125         }
126
127         return nil
128 }
129
130 // validatePolicyTypeID carries on validations for parameter PolicyTypeID
131 func (o *A1ControllerCreatePolicyTypeParams) validatePolicyTypeID(formats strfmt.Registry) error {
132
133         if err := validate.MinimumInt("policy_type_id", "path", int64(o.PolicyTypeID), 1, false); err != nil {
134                 return err
135         }
136
137         if err := validate.MaximumInt("policy_type_id", "path", int64(o.PolicyTypeID), 2.147483647e+09, false); err != nil {
138                 return err
139         }
140
141         return nil
142 }