df6bd5e9e9cbf7f9e99da4a9c57e0e19fa83a9fd
[ric-plt/a1.git] / pkg / restapi / operations / a1_mediator / a1_controller_create_or_replace_policy_instance_urlbuilder.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 generate command
27
28 import (
29         "errors"
30         "net/url"
31         golangswaggerpaths "path"
32         "strings"
33
34         "github.com/go-openapi/swag"
35 )
36
37 // A1ControllerCreateOrReplacePolicyInstanceURL generates an URL for the a1 controller create or replace policy instance operation
38 type A1ControllerCreateOrReplacePolicyInstanceURL struct {
39         PolicyInstanceID string
40         PolicyTypeID     int64
41
42         NotificationDestination *string
43
44         _basePath string
45         // avoid unkeyed usage
46         _ struct{}
47 }
48
49 // WithBasePath sets the base path for this url builder, only required when it's different from the
50 // base path specified in the swagger spec.
51 // When the value of the base path is an empty string
52 func (o *A1ControllerCreateOrReplacePolicyInstanceURL) WithBasePath(bp string) *A1ControllerCreateOrReplacePolicyInstanceURL {
53         o.SetBasePath(bp)
54         return o
55 }
56
57 // SetBasePath sets the base path for this url builder, only required when it's different from the
58 // base path specified in the swagger spec.
59 // When the value of the base path is an empty string
60 func (o *A1ControllerCreateOrReplacePolicyInstanceURL) SetBasePath(bp string) {
61         o._basePath = bp
62 }
63
64 // Build a url path and query string
65 func (o *A1ControllerCreateOrReplacePolicyInstanceURL) Build() (*url.URL, error) {
66         var _result url.URL
67
68         var _path = "/a1-p/policytypes/{policy_type_id}/policies/{policy_instance_id}"
69
70         policyInstanceID := o.PolicyInstanceID
71         if policyInstanceID != "" {
72                 _path = strings.Replace(_path, "{policy_instance_id}", policyInstanceID, -1)
73         } else {
74                 return nil, errors.New("policyInstanceId is required on A1ControllerCreateOrReplacePolicyInstanceURL")
75         }
76
77         policyTypeID := swag.FormatInt64(o.PolicyTypeID)
78         if policyTypeID != "" {
79                 _path = strings.Replace(_path, "{policy_type_id}", policyTypeID, -1)
80         } else {
81                 return nil, errors.New("policyTypeId is required on A1ControllerCreateOrReplacePolicyInstanceURL")
82         }
83
84         _basePath := o._basePath
85         _result.Path = golangswaggerpaths.Join(_basePath, _path)
86
87         qs := make(url.Values)
88
89         var notificationDestinationQ string
90         if o.NotificationDestination != nil {
91                 notificationDestinationQ = *o.NotificationDestination
92         }
93         if notificationDestinationQ != "" {
94                 qs.Set("notificationDestination", notificationDestinationQ)
95         }
96
97         _result.RawQuery = qs.Encode()
98
99         return &_result, nil
100 }
101
102 // Must is a helper function to panic when the url builder returns an error
103 func (o *A1ControllerCreateOrReplacePolicyInstanceURL) Must(u *url.URL, err error) *url.URL {
104         if err != nil {
105                 panic(err)
106         }
107         if u == nil {
108                 panic("url can't be nil")
109         }
110         return u
111 }
112
113 // String returns the string representation of the path with query string
114 func (o *A1ControllerCreateOrReplacePolicyInstanceURL) String() string {
115         return o.Must(o.Build()).String()
116 }
117
118 // BuildFull builds a full url with scheme, host, path and query string
119 func (o *A1ControllerCreateOrReplacePolicyInstanceURL) BuildFull(scheme, host string) (*url.URL, error) {
120         if scheme == "" {
121                 return nil, errors.New("scheme is required for a full url on A1ControllerCreateOrReplacePolicyInstanceURL")
122         }
123         if host == "" {
124                 return nil, errors.New("host is required for a full url on A1ControllerCreateOrReplacePolicyInstanceURL")
125         }
126
127         base, err := o.Build()
128         if err != nil {
129                 return nil, err
130         }
131
132         base.Scheme = scheme
133         base.Host = host
134         return base, nil
135 }
136
137 // StringFull returns the string representation of a complete url
138 func (o *A1ControllerCreateOrReplacePolicyInstanceURL) StringFull(scheme, host string) string {
139         return o.Must(o.BuildFull(scheme, host)).String()
140 }