blob: 7b04711f88f2cecc1ea3e64a833bad9914fa2f85 [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
elinuxhenrik4f1dda22022-05-02 16:44:31 +020040sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\DddTrafficDescriptor/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
41mv temp.yaml TS29571_CommonData.yaml
42sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\CivicAddress/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
43mv temp.yaml TS29571_CommonData.yaml
44sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\GeographicArea/{s/^\( *\).*/ \1/;x;d;}' TS29571_CommonData.yaml >temp.yaml
45mv temp.yaml TS29571_CommonData.yaml
elinuxhenrikc727c842022-02-11 08:29:36 +010046sed '/accessTokenError.*/,+3d' TS29571_CommonData.yaml >temp.yaml
47mv temp.yaml TS29571_CommonData.yaml
48sed '/accessTokenRequest.*/,+3d' TS29571_CommonData.yaml >temp.yaml
49mv temp.yaml TS29571_CommonData.yaml
elinuxhenrik51423442022-04-25 15:36:13 +020050
51sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\moAssistanceDataTypes/{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;/\RelativeCartesianLocation/{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;/\Local2dPointUncertaintyEllipse/{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;/\Local3dPointUncertaintyEllipsoid/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
58mv temp.yaml TS29572_Nlmf_Location.yaml
59sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\oneOf/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
60mv temp.yaml TS29572_Nlmf_Location.yaml
61sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\ueAreaInd/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
62mv temp.yaml TS29572_Nlmf_Location.yaml
63sed -e 'H;x;/^\( *\)\n\1/{s/\n.*//;x;d;}' -e 's/.*//;x;/\UeAreaIndication/{s/^\( *\).*/ \1/;x;d;}' TS29572_Nlmf_Location.yaml >temp.yaml
64mv temp.yaml TS29572_Nlmf_Location.yaml
65sed '/connectivitystate.*/,+2d' TS29572_Nlmf_Location.yaml >temp.yaml
66mv temp.yaml TS29572_Nlmf_Location.yaml
67
elinuxhenrik667fbf32022-02-18 11:10:07 +010068sed '/oneOf.*/,+2d' TS29222_CAPIF_Publish_Service_API.yaml >temp.yaml
69mv temp.yaml TS29222_CAPIF_Publish_Service_API.yaml
elinuxhenrik51423442022-04-25 15:36:13 +020070
71sed '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."
72mv temp.yaml TS29222_CAPIF_Discover_Service_API.yaml
73
elinuxhenrik587d71d2022-03-23 17:44:46 +010074cat TS29222_CAPIF_Security_API.yaml | sed -E 's/( AccessTokenReq*)\:/\1:| type: object/' | tr '|' '\n' > temp.yaml
75mv temp.yaml TS29222_CAPIF_Security_API.yaml
76
77cd $cwd
78
79cd internal/enumfixer
80go build .
81./enumfixer -apidir=../readonly/api
elinuxhenrikc727c842022-02-11 08:29:36 +010082
83cd $cwd
84
elinuxhenrik498e5c42022-04-28 09:54:05 +020085go install github.com/deepmap/oapi-codegen/cmd/oapi-codegen
elinuxhenrikfd7b7d02022-04-19 14:04:29 +020086PATH=$PATH:~/go/bin
87
elinuxhenrikc727c842022-02-11 08:29:36 +010088oapi-codegen --config internal/readonly/common/generator_settings.yaml internal/readonly/api/TS29122_CommonData.yaml
89oapi-codegen --config internal/readonly/common29571/generator_settings.yaml internal/readonly/api/TS29571_CommonData.yaml
elinuxhenrik51423442022-04-25 15:36:13 +020090oapi-codegen --config internal/readonly/nlfm/generator_settings.yaml internal/readonly/api/TS29572_Nlmf_Location.yaml
elinuxhenrikd1cc5712022-02-17 14:50:50 +010091oapi-codegen --config internal/readonly/publishserviceapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Publish_Service_API.yaml
92oapi-codegen --config internal/readonly/publishserviceapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Publish_Service_API.yaml
93oapi-codegen --config internal/readonly/invokermanagementapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_API_Invoker_Management_API.yaml
94oapi-codegen --config internal/readonly/invokermanagementapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_API_Invoker_Management_API.yaml
95oapi-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 +010096oapi-codegen --config internal/readonly/providermanagementapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_API_Provider_Management_API.yaml
97oapi-codegen --config internal/readonly/discoverserviceapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Discover_Service_API.yaml
elinuxhenrikd6134d52022-03-08 16:05:44 +010098oapi-codegen --config internal/readonly/discoverserviceapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Discover_Service_API.yaml
elinuxhenrik76aff482022-03-16 10:28:44 +010099oapi-codegen --config internal/readonly/securityapi/generator_settings_types.yaml internal/readonly/api/TS29222_CAPIF_Security_API.yaml
100oapi-codegen --config internal/readonly/securityapi/generator_settings_server.yaml internal/readonly/api/TS29222_CAPIF_Security_API.yaml
elinuxhenrikd6134d52022-03-08 16:05:44 +0100101
elinuxhenrik4f1dda22022-05-02 16:44:31 +0200102go generate ./...
103go test ./...