webMethods API Gateway Subscription 기능 사용 (10.7)
>> Subscription -> Pending Request -> Approve 기능 사용
- Elasticsearch API 활용
- https://esbook.kimjmin.net/05-search/5.1-query-dsl (match_phrase)
- Setting

- Approval configuration
- Create application > Enable 설정
- Subscribe package > Enable 설정

- User management
- 특정 유저 생성 후 -> Group -> Teams 생성으로 권한 할당
- 유저만으로도 생성 가능 (sjh2 테스트)
- Subscription request 생성
- Request

- Request Header

- sjh2 / sjh2 계정으로 호출
- Request Body ( JSON )
{"applicationName": "Application_PSTM_2","packageId": "f368a77f-cca2-424e-82d0-4e3e2356859d","planId": "2a2af9d5-9c02-4a8e-9dd6-9712fe72be19","requesterId": "newOwner123123","applicationDescription": "desc","otherRequesterDetails": {},"redirectURIs": ["http://192.168.1.143:5555/"],"requesterComment": "laborum commodo dolore deserunt","requesterEmail": "nisi ul","requesterFirstName": "est sed ut nulla","requesterLastName": "mollit ipsum eiusmod","requesterName": "pending_request_name"}
- PackageId, PlanId 값만 Gateway 의 각 인덱스 id 값과 동일하다면 호출 가능
- Response
- 500 Service Error
{"$errorDump": "Server error occurred","$errorInfo": {"$errorDump": "Server error occurred","$error": "Application doesn't exist for applicationId - 3c4b0710-c03a-4137-a174-677e86e07cef","$localizedError": "Application doesn't exist for applicationId - 3c4b0710-c03a-4137-a174-677e86e07cef","$errorType": "com.softwareag.pg.exceptions.BadRequestException","$service": "apigateway.subscriptions:_post","$user": "sjh2","$time": "Wed Feb 09 19:48:55 EST 2022","$pipeline": {"applicationName": "Application_PSTM_2","packageId": "f368a77f-cca2-424e-82d0-4e3e2356859d","planId": "2a2af9d5-9c02-4a8e-9dd6-9712fe72be19","requesterId": "newOwner123123","applicationDescription": "desc","otherRequesterDetails": {},"redirectURIs": ["http://192.168.1.143:5555/"],"requesterComment": "laborum commodo dolore deserunt","requesterEmail": "nisi ul","requesterFirstName": "est sed ut nulla","requesterLastName": "mollit ipsum eiusmod","requesterName": "pending_request_name"},"$callStack": "[ >>>$service=apigateway.subscriptions:createSubscription, $currentPath=<<< , >>>$service=apigateway.subscriptions:_post, $currentPath=/0<<< ]"},"$error": "Application doesn't exist for applicationId - 3c4b0710-c03a-4137-a174-677e86e07cef","$errorType": "com.softwareag.pg.exceptions.BadRequestException"}
>> $error 값의 applicationId 값 : 3c4b0710-c03a-4137-a174-677e86e07cef 활용
- 해당 Approval Request 검색
- {GW_IP}:9240/gateway_default_approvalrequest-000001/_search
- 위에서 얻은 application id 로 Search (자동 생성 후 approvalEventPayloadAsString 안에 입력 됨 )
- Request

- Request Body (JSON)
{"query" : {"match_phrase":{"approvalEventPayloadAsString" : "3c4b0710-c03a-4137-a174-677e86e07cef"}}}
- Response
{"took": 11,"timed_out": false,"_shards": {"total": 1,"successful": 1,"skipped": 0,"failed": 0},"hits": {"total": {"value": 1,"relation": "eq"},"max_score": 1.4510403,"hits": [{"_index": "gateway_default_approvalrequest-000001","_type": "_doc","_id": "0cabb128-388b-4b41-a2a8-9dcf78be0340","_score": 1.4510403,"_source": {"id": "0cabb128-388b-4b41-a2a8-9dcf78be0340","approversGroupId": "Administrators","approvalEvent": "subscribePackage","requestorId": "sjh2","requestorName": "sjh2","requestorFirstName": "sjh2","requestorLastName": "sjh2","requestorMail": "sjh2@cudo.co.kr","mode": "anyone","created": "1644454134999","lastUpdated": "1644454134999","status": "pending","requesterComment": "","approvalEventPayloadAsString": "{\"owner\":\"\",\"isSuspended\":false,\"teams\":[],\"identifiers\":[],\"packageId\":\"f368a77f-cca2-424e-82d0-4e3e2356859d\",\"description\":\"\",\"planName\":\"PLAN4\",\"subscription\":true,\"jsOrigins\":[],\"version\":\"1.0\",\"authStrategyIds\":[\"20102d2f-9ec8-4b27-84f0-60e24bb56e09\"],\"lastUpdated\":0,\"siteURLs\":[],\"provider\":\"APIPORTAL\",\"shell\":false,\"name\":\"\",\"planId\":\"2a2af9d5-9c02-4a8e-9dd6-9712fe72be19\",\"packageName\":\"Package4\",\"applicationID\":\"3c4b0710-c03a-4137-a174-677e86e07cef\"}","approvers": [{"id": "Administrator","name": "Administrator","firstName": "Administrator","lastName": "","status": "pending"}],"properties": {"planName": "PLAN4","packageName": "Package4","approvalEventType": "subscribePackage"}}}]}}
>> "_id": "0cabb128-388b-4b41-a2a8-9dcf78be0340"
>> 검색으로 얻은 "approvalEventPayloadAsString": 값 이용
- Approval Request 인덱스의 데이터 Upsert
- {GW_IP}:9240/gateway_default_approvalrequest-000001/_update/{approval request id}
- ex ) 192.168.1.143:9240/gateway_default_approvalrequest-000001/_update/0cabb128-388b-4b41-a2a8-9dcf78be0340
- 기존 approvalEventPayloadAsString 값 Owner, Name 수정 필요
"{\"owner\":\"\",\"isSuspended\":false,\"teams\":[],\"identifiers\":[],\"packageId\":\"f368a77f-cca2-424e-82d0-4e3e2356859d\",\"description\":\"\",\"planName\":\"PLAN4\",\"subscription\":true,\"jsOrigins\":[],\"version\":\"1.0\",\"authStrategyIds\":[\"f130e258-0ec8-4fe4-9775-fb14aba2eb4b\"],\"lastUpdated\":0,\"siteURLs\":[],\"provider\":\"APIPORTAL\",\"shell\":false,\"name\":\"\",\"planId\":\"2a2af9d5-9c02-4a8e-9dd6-9712fe72be19\",\"packageName\":\"Package4\",\"applicationID\":\"d7eb7dab-1603-4871-a503-8b4a46c6bc37\"}"
- Request

- owner : Owner 이름
- name : AppName
- Request Body (JSON)
{"doc" : {"approvalEventPayloadAsString" : "{\"owner\":\"sjh2\",\"isSuspended\":false,\"teams\":[],\"identifiers\":[],\"packageId\":\"f368a77f-cca2-424e-82d0-4e3e2356859d\",\"description\":\"\",\"planName\":\"PLAN4\",\"subscription\":true,\"jsOrigins\":[],\"version\":\"1.0\",\"authStrategyIds\":[\"f130e258-0ec8-4fe4-9775-fb14aba2eb4b\"],\"lastUpdated\":0,\"siteURLs\":[],\"provider\":\"APIPORTAL\",\"shell\":false,\"name\":\"\",\"planId\":\"2a2af9d5-9c02-4a8e-9dd6-9712fe72be19\",\"packageName\":\"Package4\",\"applicationID\":\"d7eb7dab-1603-4871-a503-8b4a46c6bc37\"}"},"doc_as_upsert":true}
- Response
{"_index": "gateway_default_approvalrequest-000001","_type": "_doc","_id": "7913aee4-f600-4cd2-914a-5d42df337d2b","_version": 2,"result": "updated","_shards": {"total": 2,"successful": 1,"failed": 0},"_seq_no": 183,"_primary_term": 6}