Policy status notification handling - initial rollup
[ric-plt/a1.git] / 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         "context"
30         "net/http"
31
32         "github.com/go-openapi/errors"
33         "github.com/go-openapi/runtime"
34         "github.com/go-openapi/runtime/middleware"
35         "github.com/go-openapi/strfmt"
36         "github.com/go-openapi/swag"
37         "github.com/go-openapi/validate"
38
39         "gerrit.o-ran-sc.org/r/ric-plt/a1/pkg/models"
40 )
41
42 // NewA1ControllerCreatePolicyTypeParams creates a new A1ControllerCreatePolicyTypeParams object
43 //
44 // There are no default values defined in the spec.
45 func NewA1ControllerCreatePolicyTypeParams() A1ControllerCreatePolicyTypeParams {
46
47         return A1ControllerCreatePolicyTypeParams{}
48 }
49
50 // A1ControllerCreatePolicyTypeParams contains all the bound params for the a1 controller create policy type operation
51 // typically these are obtained from a http.Request
52 //
53 // swagger:parameters a1.controller.create_policy_type
54 type A1ControllerCreatePolicyTypeParams struct {
55
56         // HTTP Request Object
57         HTTPRequest *http.Request `json:"-"`
58
59         /*
60           In: body
61         */
62         Body *models.PolicyTypeSchema
63         /*represents a policy type identifier. Currently this is restricted to an integer range.
64
65           Required: true
66           Maximum: 2.147483647e+09
67           Minimum: 1
68           In: path
69         */
70         PolicyTypeID int64
71 }
72
73 // BindRequest both binds and validates a request, it assumes that complex things implement a Validatable(strfmt.Registry) error interface
74 // for simple values it will use straight method calls.
75 //
76 // To ensure default values, the struct must have been initialized with NewA1ControllerCreatePolicyTypeParams() beforehand.
77 func (o *A1ControllerCreatePolicyTypeParams) BindRequest(r *http.Request, route *middleware.MatchedRoute) error {
78         var res []error
79
80         o.HTTPRequest = r
81
82         if runtime.HasBody(r) {
83                 defer r.Body.Close()
84                 var body models.PolicyTypeSchema
85                 if err := route.Consumer.Consume(r.Body, &body); err != nil {
86                         res = append(res, errors.NewParseError("body", "body", "", err))
87                 } else {
88                         // validate body object
89                         if err := body.Validate(route.Formats); err != nil {
90                                 res = append(res, err)
91                         }
92
93                         ctx := validate.WithOperationRequest(context.Background())
94                         if err := body.ContextValidate(ctx, route.Formats); err != nil {
95                                 res = append(res, err)
96                         }
97
98                         if len(res) == 0 {
99                                 o.Body = &body
100                         }
101                 }
102         }
103
104         rPolicyTypeID, rhkPolicyTypeID, _ := route.Params.GetOK("policy_type_id")
105         if err := o.bindPolicyTypeID(rPolicyTypeID, rhkPolicyTypeID, route.Formats); err != nil {
106                 res = append(res, err)
107         }
108         if len(res) > 0 {
109                 return errors.CompositeValidationError(res...)
110         }
111         return nil
112 }
113
114 // bindPolicyTypeID binds and validates parameter PolicyTypeID from path.
115 func (o *A1ControllerCreatePolicyTypeParams) bindPolicyTypeID(rawData []string, hasKey bool, formats strfmt.Registry) error {
116         var raw string
117         if len(rawData) > 0 {
118                 raw = rawData[len(rawData)-1]
119         }
120
121         // Required: true
122         // Parameter is provided by construction from the route
123
124         value, err := swag.ConvertInt64(raw)
125         if err != nil {
126                 return errors.InvalidType("policy_type_id", "path", "int64", raw)
127         }
128         o.PolicyTypeID = value
129
130         if err := o.validatePolicyTypeID(formats); err != nil {
131                 return err
132         }
133
134         return nil
135 }
136
137 // validatePolicyTypeID carries on validations for parameter PolicyTypeID
138 func (o *A1ControllerCreatePolicyTypeParams) validatePolicyTypeID(formats strfmt.Registry) error {
139
140         if err := validate.MinimumInt("policy_type_id", "path", o.PolicyTypeID, 1, false); err != nil {
141                 return err
142         }
143
144         if err := validate.MaximumInt("policy_type_id", "path", o.PolicyTypeID, 2.147483647e+09, false); err != nil {
145                 return err
146         }
147
148         return nil
149 }