blob: e4a6db7426b053062cd883b75dda63fc4c0298ec [file] [log] [blame]
elinuxhenrikc727c842022-02-11 08:29:36 +01001# -
2# ========================LICENSE_START=================================
3# O-RAN-SC
4# %%
5# Copyright (C) 2022: Nordix Foundation
6# %%
7# Licensed under the Apache License, Version 2.0 (the "License");
8# you may not use this file except in compliance with the License.
9# You may obtain a copy of the License at
10#
11# http://www.apache.org/licenses/LICENSE-2.0
12#
13# Unless required by applicable law or agreed to in writing, software
14# distributed under the License is distributed on an "AS IS" BASIS,
15# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16# See the License for the specific language governing permissions and
17# limitations under the License.
18# ========================LICENSE_END===================================
19#
20
21cwd=$(pwd)
22
23mkdir internal/readonly/api
24
elinuxhenrik51423442022-04-25 15:36:13 +020025curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.222/29222-h40.zip -o internal/readonly/api/apidef.zip
26curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.122/29122-h50.zip -o internal/readonly/api/commonapidef.zip
27curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.571/29571-h50.zip -o internal/readonly/api/common29571apidef.zip
28curl https://www.3gpp.org/ftp/Specs/archive/29_series/29.572/29572-h40.zip -o internal/readonly/api/common29572apidef.zip
elinuxhenrikc727c842022-02-11 08:29:36 +010029
30cd internal/readonly/api/
31
32jar xvf apidef.zip
33jar xvf commonapidef.zip
34jar xvf common29571apidef.zip
elinuxhenrik51423442022-04-25 15:36:13 +020035jar xvf common29572apidef.zip
elinuxhenrikc727c842022-02-11 08:29:36 +010036
elinuxhenrik3969edc2022-04-29 09:28:51 +020037sed '/nwAreaInfo.*/,+1d' TS29122_CommonData.yaml >temp.yaml
elinuxhenrikc727c842022-02-11 08:29:36 +010038mv temp.yaml TS29122_CommonData.yaml
elinuxhenrik51423442022-04-25 15:36:13 +020039
elinuxhenrikc727c842022-02-11 08:29:36 +010040sed '/accessTokenError.*/,+3d' TS29571_CommonData.yaml >temp.yaml
41mv temp.yaml TS29571_CommonData.yaml
42sed '/accessTokenRequest.*/,+3d' TS29571_CommonData.yaml >temp.yaml
43mv temp.yaml TS29571_CommonData.yaml
elinuxhenrik51423442022-04-25 15:36:13 +020044
45sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\moAssistanceDataTypes/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
46mv temp.yaml TS29572_Nlmf_Location.yaml
47sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\RelativeCartesianLocation/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
48mv temp.yaml TS29572_Nlmf_Location.yaml
49sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\Local2dPointUncertaintyEllipse/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
50mv temp.yaml TS29572_Nlmf_Location.yaml
51sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\Local3dPointUncertaintyEllipsoid/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
52mv temp.yaml TS29572_Nlmf_Location.yaml
53sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\oneOf/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
54mv temp.yaml TS29572_Nlmf_Location.yaml
55sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\ueAreaInd/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
56mv temp.yaml TS29572_Nlmf_Location.yaml
57sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\UeAreaIndication/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
58mv temp.yaml TS29572_Nlmf_Location.yaml
59sed '/connectivitystate.*/,+2d' TS29572_Nlmf_Location.yaml >temp.yaml
60mv temp.yaml TS29572_Nlmf_Location.yaml
61
elinuxhenrik667fbf32022-02-18 11:10:07 +010062sed '/oneOf.*/,+2d' TS29222_CAPIF_Publish_Service_API.yaml >temp.yaml
63mv temp.yaml TS29222_CAPIF_Publish_Service_API.yaml
elinuxhenrik51423442022-04-25 15:36:13 +020064
65sed '64,68d' TS29222_CAPIF_Discover_Service_API.yaml >temp.yaml # Remove parameter preferred-aef-loc since it doesn't follow the OpenApi specification, "The behavior for nested objects and arrays is undefined."
66mv temp.yaml TS29222_CAPIF_Discover_Service_API.yaml
67
elinuxhenrik587d71d2022-03-23 17:44:46 +010068cat TS29222_CAPIF_Security_API.yaml | sed -E 's/( AccessTokenReq*)\:/\1:| type: object/' | tr '|' '\n' > temp.yaml
69mv temp.yaml TS29222_CAPIF_Security_API.yaml
70
71cd $cwd
72
73cd internal/enumfixer
74go build .
75./enumfixer -apidir=../readonly/api
elinuxhenrikc727c842022-02-11 08:29:36 +010076
77cd $cwd
78
elinuxhenrik498e5c42022-04-28 09:54:05 +020079go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen
elinuxhenrikfd7b7d02022-04-19 14:04:29 +020080PATH=$PATH:~/go/bin
81
elinuxhenrikc727c842022-02-11 08:29:36 +010082oapi-codegen --config internal/readonly/common/generator_settings.yaml internal/readonly/api/TS29122_CommonData.yaml
83oapi-codegen --config internal/readonly/common29571/generator_settings.yaml internal/readonly/api/TS29571_CommonData.yaml
elinuxhenrik51423442022-04-25 15:36:13 +020084oapi-codegen --config internal/readonly/nlfm/generator_settings.yaml internal/readonly/api/TS29572_Nlmf_Location.yaml
elinuxhenrikd1cc5712022-02-17 14:50:50 +010085oapi-codegen --config internal/readonly/publishserviceapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Publish_Service_API.yaml
86oapi-codegen --config internal/readonly/publishserviceapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Publish_Service_API.yaml
87oapi-codegen --config internal/readonly/invokermanagementapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_API_Invoker_Management_API.yaml
88oapi-codegen --config internal/readonly/invokermanagementapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_API_Invoker_Management_API.yaml
89oapi-codegen --config internal/readonly/providermanagementapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_API_Provider_Management_API.yaml
elinuxhenrikc9e4b972022-02-18 16:42:05 +010090oapi-codegen --config internal/readonly/providermanagementapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_API_Provider_Management_API.yaml
91oapi-codegen --config internal/readonly/discoverserviceapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Discover_Service_API.yaml
elinuxhenrikd6134d52022-03-08 16:05:44 +010092oapi-codegen --config internal/readonly/discoverserviceapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Discover_Service_API.yaml
elinuxhenrik76aff482022-03-16 10:28:44 +010093oapi-codegen --config internal/readonly/securityapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Security_API.yaml
94oapi-codegen --config internal/readonly/securityapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Security_API.yaml
elinuxhenrikd6134d52022-03-08 16:05:44 +010095
96go generate ./...