diff --git a/.openapi-generator/FILES b/.openapi-generator/FILES index 5a4b9a89..51e74d6f 100644 --- a/.openapi-generator/FILES +++ b/.openapi-generator/FILES @@ -44,16 +44,34 @@ docs/CreateAsyncBulkLookupResponse.md docs/CreateAsyncBulkLookupResponseData.md docs/CreateCall.md docs/CreateCallResponse.md +docs/CreateEndpointRequestBase.md +docs/CreateEndpointResponse.md +docs/CreateEndpointResponseObject.md docs/CreateMessageRequestError.md docs/CreateMultiChannelMessageResponse.md docs/CreateSyncLookupResponse.md docs/CreateSyncLookupResponseData.md +docs/CreateWebRtcConnectionRequest.md docs/DeactivationEventEnum.md +docs/Device.md +docs/DeviceStatusEnum.md docs/DisconnectCallback.md docs/Diversion.md docs/DtmfCallback.md +docs/Endpoint.md +docs/EndpointDirectionEnum.md +docs/EndpointEvent.md +docs/EndpointEventTypeEnum.md +docs/EndpointResponse.md +docs/EndpointStatusEnum.md +docs/EndpointTypeEnum.md +docs/Endpoints.md +docs/EndpointsApi.md docs/Error.md +docs/Error1.md +docs/Error1Source.md docs/ErrorObject.md +docs/ErrorResponse.md docs/ErrorSource.md docs/FailureWebhook.md docs/FieldError.md @@ -69,8 +87,10 @@ docs/InitiateCallback.md docs/LatestMessageDeliveryStatusEnum.md docs/LineTypeEnum.md docs/Link.md +docs/Link1.md docs/LinkSchema.md docs/LinksObject.md +docs/ListEndpointsResponse.md docs/ListMessageDirectionEnum.md docs/ListMessageItem.md docs/LookupErrorResponse.md @@ -118,6 +138,7 @@ docs/MultiChannelMessageContent.md docs/MultiChannelMessageRequest.md docs/MultiChannelMessageResponseData.md docs/OptInWorkflow.md +docs/Page.md docs/PageInfo.md docs/PhoneNumberLookupApi.md docs/PriorityEnum.md @@ -148,6 +169,8 @@ docs/RecordingTranscriptions.md docs/RecordingsApi.md docs/RedirectCallback.md docs/RedirectMethodEnum.md +docs/SipConnectionMetadata.md +docs/SipCredentials.md docs/SmsMessageContent.md docs/StandaloneCardOrientationEnum.md docs/StatisticsApi.md @@ -214,6 +237,7 @@ src/main/java/com/bandwidth/sdk/ServerVariable.java src/main/java/com/bandwidth/sdk/StringUtil.java src/main/java/com/bandwidth/sdk/api/CallsApi.java src/main/java/com/bandwidth/sdk/api/ConferencesApi.java +src/main/java/com/bandwidth/sdk/api/EndpointsApi.java src/main/java/com/bandwidth/sdk/api/MediaApi.java src/main/java/com/bandwidth/sdk/api/MessagesApi.java src/main/java/com/bandwidth/sdk/api/MfaApi.java @@ -271,16 +295,33 @@ src/main/java/com/bandwidth/sdk/model/CreateAsyncBulkLookupResponse.java src/main/java/com/bandwidth/sdk/model/CreateAsyncBulkLookupResponseData.java src/main/java/com/bandwidth/sdk/model/CreateCall.java src/main/java/com/bandwidth/sdk/model/CreateCallResponse.java +src/main/java/com/bandwidth/sdk/model/CreateEndpointRequestBase.java +src/main/java/com/bandwidth/sdk/model/CreateEndpointResponse.java +src/main/java/com/bandwidth/sdk/model/CreateEndpointResponseObject.java src/main/java/com/bandwidth/sdk/model/CreateMessageRequestError.java src/main/java/com/bandwidth/sdk/model/CreateMultiChannelMessageResponse.java src/main/java/com/bandwidth/sdk/model/CreateSyncLookupResponse.java src/main/java/com/bandwidth/sdk/model/CreateSyncLookupResponseData.java +src/main/java/com/bandwidth/sdk/model/CreateWebRtcConnectionRequest.java src/main/java/com/bandwidth/sdk/model/DeactivationEventEnum.java +src/main/java/com/bandwidth/sdk/model/Device.java +src/main/java/com/bandwidth/sdk/model/DeviceStatusEnum.java src/main/java/com/bandwidth/sdk/model/DisconnectCallback.java src/main/java/com/bandwidth/sdk/model/Diversion.java src/main/java/com/bandwidth/sdk/model/DtmfCallback.java +src/main/java/com/bandwidth/sdk/model/Endpoint.java +src/main/java/com/bandwidth/sdk/model/EndpointDirectionEnum.java +src/main/java/com/bandwidth/sdk/model/EndpointEvent.java +src/main/java/com/bandwidth/sdk/model/EndpointEventTypeEnum.java +src/main/java/com/bandwidth/sdk/model/EndpointResponse.java +src/main/java/com/bandwidth/sdk/model/EndpointStatusEnum.java +src/main/java/com/bandwidth/sdk/model/EndpointTypeEnum.java +src/main/java/com/bandwidth/sdk/model/Endpoints.java src/main/java/com/bandwidth/sdk/model/Error.java +src/main/java/com/bandwidth/sdk/model/Error1.java +src/main/java/com/bandwidth/sdk/model/Error1Source.java src/main/java/com/bandwidth/sdk/model/ErrorObject.java +src/main/java/com/bandwidth/sdk/model/ErrorResponse.java src/main/java/com/bandwidth/sdk/model/ErrorSource.java src/main/java/com/bandwidth/sdk/model/FailureWebhook.java src/main/java/com/bandwidth/sdk/model/FieldError.java @@ -296,8 +337,10 @@ src/main/java/com/bandwidth/sdk/model/InitiateCallback.java src/main/java/com/bandwidth/sdk/model/LatestMessageDeliveryStatusEnum.java src/main/java/com/bandwidth/sdk/model/LineTypeEnum.java src/main/java/com/bandwidth/sdk/model/Link.java +src/main/java/com/bandwidth/sdk/model/Link1.java src/main/java/com/bandwidth/sdk/model/LinkSchema.java src/main/java/com/bandwidth/sdk/model/LinksObject.java +src/main/java/com/bandwidth/sdk/model/ListEndpointsResponse.java src/main/java/com/bandwidth/sdk/model/ListMessageDirectionEnum.java src/main/java/com/bandwidth/sdk/model/ListMessageItem.java src/main/java/com/bandwidth/sdk/model/LookupErrorResponse.java @@ -341,6 +384,7 @@ src/main/java/com/bandwidth/sdk/model/MultiChannelMessageContent.java src/main/java/com/bandwidth/sdk/model/MultiChannelMessageRequest.java src/main/java/com/bandwidth/sdk/model/MultiChannelMessageResponseData.java src/main/java/com/bandwidth/sdk/model/OptInWorkflow.java +src/main/java/com/bandwidth/sdk/model/Page.java src/main/java/com/bandwidth/sdk/model/PageInfo.java src/main/java/com/bandwidth/sdk/model/PriorityEnum.java src/main/java/com/bandwidth/sdk/model/ProductTypeEnum.java @@ -369,6 +413,8 @@ src/main/java/com/bandwidth/sdk/model/RecordingTranscriptionMetadata.java src/main/java/com/bandwidth/sdk/model/RecordingTranscriptions.java src/main/java/com/bandwidth/sdk/model/RedirectCallback.java src/main/java/com/bandwidth/sdk/model/RedirectMethodEnum.java +src/main/java/com/bandwidth/sdk/model/SipConnectionMetadata.java +src/main/java/com/bandwidth/sdk/model/SipCredentials.java src/main/java/com/bandwidth/sdk/model/SmsMessageContent.java src/main/java/com/bandwidth/sdk/model/StandaloneCardOrientationEnum.java src/main/java/com/bandwidth/sdk/model/StatusCallback.java diff --git a/README.md b/README.md index 11380861..186a0e7f 100644 --- a/README.md +++ b/README.md @@ -143,6 +143,11 @@ Class | Method | HTTP request | Description *ConferencesApi* | [**updateConference**](docs/ConferencesApi.md#updateConference) | **POST** /accounts/{accountId}/conferences/{conferenceId} | Update Conference *ConferencesApi* | [**updateConferenceBxml**](docs/ConferencesApi.md#updateConferenceBxml) | **PUT** /accounts/{accountId}/conferences/{conferenceId}/bxml | Update Conference BXML *ConferencesApi* | [**updateConferenceMember**](docs/ConferencesApi.md#updateConferenceMember) | **PUT** /accounts/{accountId}/conferences/{conferenceId}/members/{memberId} | Update Conference Member +*EndpointsApi* | [**createEndpoint**](docs/EndpointsApi.md#createEndpoint) | **POST** /accounts/{accountId}/endpoints | Create Endpoint +*EndpointsApi* | [**deleteEndpoint**](docs/EndpointsApi.md#deleteEndpoint) | **DELETE** /accounts/{accountId}/endpoints/{endpointId} | Delete Endpoint +*EndpointsApi* | [**getEndpoint**](docs/EndpointsApi.md#getEndpoint) | **GET** /accounts/{accountId}/endpoints/{endpointId} | Get Endpoint +*EndpointsApi* | [**listEndpoints**](docs/EndpointsApi.md#listEndpoints) | **GET** /accounts/{accountId}/endpoints | List Endpoints +*EndpointsApi* | [**updateEndpointBxml**](docs/EndpointsApi.md#updateEndpointBxml) | **PUT** /accounts/{accountId}/endpoints/{endpointId}/bxml | Update Endpoint BXML *MediaApi* | [**deleteMedia**](docs/MediaApi.md#deleteMedia) | **DELETE** /users/{accountId}/media/{mediaId} | Delete Media *MediaApi* | [**getMedia**](docs/MediaApi.md#getMedia) | **GET** /users/{accountId}/media/{mediaId} | Get Media *MediaApi* | [**listMedia**](docs/MediaApi.md#listMedia) | **GET** /users/{accountId}/media | List Media @@ -222,16 +227,33 @@ Class | Method | HTTP request | Description - [CreateAsyncBulkLookupResponseData](docs/CreateAsyncBulkLookupResponseData.md) - [CreateCall](docs/CreateCall.md) - [CreateCallResponse](docs/CreateCallResponse.md) + - [CreateEndpointRequestBase](docs/CreateEndpointRequestBase.md) + - [CreateEndpointResponse](docs/CreateEndpointResponse.md) + - [CreateEndpointResponseObject](docs/CreateEndpointResponseObject.md) - [CreateMessageRequestError](docs/CreateMessageRequestError.md) - [CreateMultiChannelMessageResponse](docs/CreateMultiChannelMessageResponse.md) - [CreateSyncLookupResponse](docs/CreateSyncLookupResponse.md) - [CreateSyncLookupResponseData](docs/CreateSyncLookupResponseData.md) + - [CreateWebRtcConnectionRequest](docs/CreateWebRtcConnectionRequest.md) - [DeactivationEventEnum](docs/DeactivationEventEnum.md) + - [Device](docs/Device.md) + - [DeviceStatusEnum](docs/DeviceStatusEnum.md) - [DisconnectCallback](docs/DisconnectCallback.md) - [Diversion](docs/Diversion.md) - [DtmfCallback](docs/DtmfCallback.md) + - [Endpoint](docs/Endpoint.md) + - [EndpointDirectionEnum](docs/EndpointDirectionEnum.md) + - [EndpointEvent](docs/EndpointEvent.md) + - [EndpointEventTypeEnum](docs/EndpointEventTypeEnum.md) + - [EndpointResponse](docs/EndpointResponse.md) + - [EndpointStatusEnum](docs/EndpointStatusEnum.md) + - [EndpointTypeEnum](docs/EndpointTypeEnum.md) + - [Endpoints](docs/Endpoints.md) - [Error](docs/Error.md) + - [Error1](docs/Error1.md) + - [Error1Source](docs/Error1Source.md) - [ErrorObject](docs/ErrorObject.md) + - [ErrorResponse](docs/ErrorResponse.md) - [ErrorSource](docs/ErrorSource.md) - [FailureWebhook](docs/FailureWebhook.md) - [FieldError](docs/FieldError.md) @@ -247,8 +269,10 @@ Class | Method | HTTP request | Description - [LatestMessageDeliveryStatusEnum](docs/LatestMessageDeliveryStatusEnum.md) - [LineTypeEnum](docs/LineTypeEnum.md) - [Link](docs/Link.md) + - [Link1](docs/Link1.md) - [LinkSchema](docs/LinkSchema.md) - [LinksObject](docs/LinksObject.md) + - [ListEndpointsResponse](docs/ListEndpointsResponse.md) - [ListMessageDirectionEnum](docs/ListMessageDirectionEnum.md) - [ListMessageItem](docs/ListMessageItem.md) - [LookupErrorResponse](docs/LookupErrorResponse.md) @@ -292,6 +316,7 @@ Class | Method | HTTP request | Description - [MultiChannelMessageRequest](docs/MultiChannelMessageRequest.md) - [MultiChannelMessageResponseData](docs/MultiChannelMessageResponseData.md) - [OptInWorkflow](docs/OptInWorkflow.md) + - [Page](docs/Page.md) - [PageInfo](docs/PageInfo.md) - [PriorityEnum](docs/PriorityEnum.md) - [ProductTypeEnum](docs/ProductTypeEnum.md) @@ -320,6 +345,8 @@ Class | Method | HTTP request | Description - [RecordingTranscriptions](docs/RecordingTranscriptions.md) - [RedirectCallback](docs/RedirectCallback.md) - [RedirectMethodEnum](docs/RedirectMethodEnum.md) + - [SipConnectionMetadata](docs/SipConnectionMetadata.md) + - [SipCredentials](docs/SipCredentials.md) - [SmsMessageContent](docs/SmsMessageContent.md) - [StandaloneCardOrientationEnum](docs/StandaloneCardOrientationEnum.md) - [StatusCallback](docs/StatusCallback.md) diff --git a/api/openapi.yaml b/api/openapi.yaml index 58e13dcf..7e6de6fd 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -24,6 +24,7 @@ tags: - name: MFA - name: Phone Number Lookup - name: Toll-Free Verification +- name: Endpoints paths: /users/{accountId}/media: get: @@ -5812,6 +5813,579 @@ paths: servers: - description: Production url: https://api.bandwidth.com/api/v2 + /accounts/{accountId}/endpoints: + get: + description: Returns a list of endpoints associated with the specified account. + operationId: listEndpoints + parameters: + - description: Your Bandwidth Account ID. + explode: false + in: path + name: accountId + required: true + schema: + example: "5500123" + type: string + style: simple + - description: The type of endpoint. + explode: true + in: query + name: type + required: false + schema: + $ref: "#/components/schemas/endpointTypeEnum" + style: form + - description: The status of the endpoint. + explode: true + in: query + name: status + required: false + schema: + $ref: "#/components/schemas/endpointStatusEnum" + style: form + - description: The cursor to use for pagination. This is the value of the `next` + link in the previous response. + explode: true + in: query + name: afterCursor + required: false + schema: + example: TWF5IHRoZSBmb3JjZSBiZSB3aXRoIHlvdQ== + type: string + style: form + - description: The maximum number of endpoints to return in the response. + explode: true + in: query + name: limit + required: false + schema: + default: 100 + example: 2 + maximum: 1000 + minimum: 1 + type: integer + style: form + responses: + "200": + content: + application/json: + examples: + listEndpointsResponseExample: + $ref: "#/components/examples/listEndpointsResponseExample" + schema: + $ref: "#/components/schemas/listEndpointsResponse" + description: OK + "400": + content: + application/json: + examples: + badRequestErrorExample: + $ref: "#/components/examples/badRequestErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Bad Request + "401": + content: + application/json: + examples: + unauthorizedErrorExample: + $ref: "#/components/examples/unauthorizedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unauthorized + "403": + content: + application/json: + examples: + forbiddenErrorExample: + $ref: "#/components/examples/forbiddenErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Forbidden + "404": + content: + application/json: + examples: + notFoundErrorExample: + $ref: "#/components/examples/notFoundErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Not Found + "405": + content: + application/json: + examples: + methodNotAllowedErrorExample: + $ref: "#/components/examples/methodNotAllowedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Method Not Allowed + "415": + content: + application/json: + examples: + unsuppotedMediaTypeErrorExample: + $ref: "#/components/examples/unsupportedMediaTypeErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unsupported Media Type + "429": + content: + application/json: + examples: + tooManyRequestsErrorExample: + $ref: "#/components/examples/tooManyRequestsErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Too Many Requests + "500": + content: + application/json: + examples: + serviceUnavailableErrorExample: + $ref: "#/components/examples/serviceUnavailableErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Service Unavailable + summary: List Endpoints + tags: + - Endpoints + x-accepts: + - application/json + post: + callbacks: + endpointEventCallback: + $ref: "#/components/callbacks/endpointEvent" + description: Creates a new Endpoint for the specified account. + operationId: createEndpoint + parameters: + - description: Your Bandwidth Account ID. + explode: false + in: path + name: accountId + required: true + schema: + example: "5500123" + type: string + style: simple + requestBody: + $ref: "#/components/requestBodies/createEndpointRequest" + responses: + "201": + content: + application/json: + examples: + createEndpointResponseExample: + $ref: "#/components/examples/createEndpointResponseExample" + schema: + $ref: "#/components/schemas/createEndpointResponse" + description: Created + "400": + content: + application/json: + examples: + badRequestErrorExample: + $ref: "#/components/examples/badRequestErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Bad Request + "401": + content: + application/json: + examples: + unauthorizedErrorExample: + $ref: "#/components/examples/unauthorizedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unauthorized + "403": + content: + application/json: + examples: + forbiddenErrorExample: + $ref: "#/components/examples/forbiddenErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Forbidden + "404": + content: + application/json: + examples: + notFoundErrorExample: + $ref: "#/components/examples/notFoundErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Not Found + "405": + content: + application/json: + examples: + methodNotAllowedErrorExample: + $ref: "#/components/examples/methodNotAllowedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Method Not Allowed + "415": + content: + application/json: + examples: + unsuppotedMediaTypeErrorExample: + $ref: "#/components/examples/unsupportedMediaTypeErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unsupported Media Type + "429": + content: + application/json: + examples: + tooManyRequestsErrorExample: + $ref: "#/components/examples/tooManyRequestsErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Too Many Requests + "500": + content: + application/json: + examples: + serviceUnavailableErrorExample: + $ref: "#/components/examples/serviceUnavailableErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Service Unavailable + summary: Create Endpoint + tags: + - Endpoints + x-content-type: application/json + x-accepts: + - application/json + servers: + - description: Production + url: https://api.bandwidth.com/v2 + /accounts/{accountId}/endpoints/{endpointId}: + delete: + description: "Deletes the specified endpoint. If the endpoint is actively streaming\ + \ media, the media stream will be terminated." + operationId: deleteEndpoint + parameters: + - description: Your Bandwidth Account ID. + explode: false + in: path + name: accountId + required: true + schema: + example: "5500123" + type: string + style: simple + - description: BRTC Endpoint ID. + explode: false + in: path + name: endpointId + required: true + schema: + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: string + style: simple + responses: + "204": + description: No Content + "400": + content: + application/json: + examples: + badRequestErrorExample: + $ref: "#/components/examples/badRequestErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Bad Request + "401": + content: + application/json: + examples: + unauthorizedErrorExample: + $ref: "#/components/examples/unauthorizedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unauthorized + "403": + content: + application/json: + examples: + forbiddenErrorExample: + $ref: "#/components/examples/forbiddenErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Forbidden + "404": + content: + application/json: + examples: + notFoundErrorExample: + $ref: "#/components/examples/notFoundErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Not Found + "405": + content: + application/json: + examples: + methodNotAllowedErrorExample: + $ref: "#/components/examples/methodNotAllowedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Method Not Allowed + "415": + content: + application/json: + examples: + unsuppotedMediaTypeErrorExample: + $ref: "#/components/examples/unsupportedMediaTypeErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unsupported Media Type + "429": + content: + application/json: + examples: + tooManyRequestsErrorExample: + $ref: "#/components/examples/tooManyRequestsErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Too Many Requests + "500": + content: + application/json: + examples: + serviceUnavailableErrorExample: + $ref: "#/components/examples/serviceUnavailableErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Service Unavailable + summary: Delete Endpoint + tags: + - Endpoints + x-accepts: + - application/json + get: + description: Returns information about the specified endpoint. + operationId: getEndpoint + parameters: + - description: Your Bandwidth Account ID. + explode: false + in: path + name: accountId + required: true + schema: + example: "5500123" + type: string + style: simple + - description: BRTC Endpoint ID. + explode: false + in: path + name: endpointId + required: true + schema: + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: string + style: simple + responses: + "200": + content: + application/json: + examples: + getEndpointResponseExample: + $ref: "#/components/examples/getEndpointResponseExample" + schema: + $ref: "#/components/schemas/endpointResponse" + description: OK + "400": + content: + application/json: + examples: + badRequestErrorExample: + $ref: "#/components/examples/badRequestErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Bad Request + "401": + content: + application/json: + examples: + unauthorizedErrorExample: + $ref: "#/components/examples/unauthorizedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unauthorized + "403": + content: + application/json: + examples: + forbiddenErrorExample: + $ref: "#/components/examples/forbiddenErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Forbidden + "404": + content: + application/json: + examples: + notFoundErrorExample: + $ref: "#/components/examples/notFoundErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Not Found + "405": + content: + application/json: + examples: + methodNotAllowedErrorExample: + $ref: "#/components/examples/methodNotAllowedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Method Not Allowed + "415": + content: + application/json: + examples: + unsuppotedMediaTypeErrorExample: + $ref: "#/components/examples/unsupportedMediaTypeErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unsupported Media Type + "429": + content: + application/json: + examples: + tooManyRequestsErrorExample: + $ref: "#/components/examples/tooManyRequestsErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Too Many Requests + "500": + content: + application/json: + examples: + serviceUnavailableErrorExample: + $ref: "#/components/examples/serviceUnavailableErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Service Unavailable + summary: Get Endpoint + tags: + - Endpoints + x-accepts: + - application/json + servers: + - description: Production + url: https://api.bandwidth.com/v2 + /accounts/{accountId}/endpoints/{endpointId}/bxml: + put: + description: Updates the BXML for the specified endpoint. + operationId: updateEndpointBxml + parameters: + - description: Your Bandwidth Account ID. + explode: false + in: path + name: accountId + required: true + schema: + example: "5500123" + type: string + style: simple + - description: BRTC Endpoint ID. + explode: false + in: path + name: endpointId + required: true + schema: + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: string + style: simple + requestBody: + $ref: "#/components/requestBodies/updateEndpointBxmlRequest" + responses: + "204": + description: No Content + "400": + content: + application/json: + examples: + badRequestErrorExample: + $ref: "#/components/examples/badRequestErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Bad Request + "401": + content: + application/json: + examples: + unauthorizedErrorExample: + $ref: "#/components/examples/unauthorizedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unauthorized + "403": + content: + application/json: + examples: + forbiddenErrorExample: + $ref: "#/components/examples/forbiddenErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Forbidden + "404": + content: + application/json: + examples: + notFoundErrorExample: + $ref: "#/components/examples/notFoundErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Not Found + "405": + content: + application/json: + examples: + methodNotAllowedErrorExample: + $ref: "#/components/examples/methodNotAllowedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Method Not Allowed + "415": + content: + application/json: + examples: + unsuppotedMediaTypeErrorExample: + $ref: "#/components/examples/unsupportedMediaTypeErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unsupported Media Type + "429": + content: + application/json: + examples: + tooManyRequestsErrorExample: + $ref: "#/components/examples/tooManyRequestsErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Too Many Requests + "500": + content: + application/json: + examples: + serviceUnavailableErrorExample: + $ref: "#/components/examples/serviceUnavailableErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Service Unavailable + summary: Update Endpoint BXML + tags: + - Endpoints + x-content-type: application/xml + x-accepts: + - application/json + servers: + - description: Production + url: https://api.bandwidth.com/v2 components: callbacks: inboundCallback: @@ -5969,6 +6543,20 @@ components: $ref: "#/components/schemas/tfvError" description: Service Unavailable summary: TFV status updates sent to customer's webhook URL. + endpointEvent: + '{request.body#/eventCallbackUrl}': + post: + requestBody: + content: + application/json: + examples: + endpointDisconnectedEventExample: + $ref: "#/components/examples/endpointDisconnectedEventExample" + schema: + $ref: "#/components/schemas/endpointEvent" + responses: + "204": + description: Event was successfully received. examples: smsMessageReceivedCallbackExample: summary: An example of a sms message-received callback body. @@ -6387,6 +6975,200 @@ components: type: unexpected-error description: Unexpected error. Please contact Bandwidth Support if your requests are receiving this status code for an extended period of time. + listEndpointsResponseExample: + summary: List Endpoints Paginated Response + value: + links: + - href: https://api.bandwidth.com/v2/accounts/5500123/endpoints?type=SIP&status=CONNECTED&limit=2 + rel: self + method: GET + - href: https://api.bandwidth.com/v2/accounts/5500123/endpoints?type=SIP&status=CONNECTED&limit=2&afterCursor=TWF5IHRoZSBmb3JjZSBiZSB3aXRoIHlvdQ== + rel: next + method: GET + page: + pageSize: 2 + totalElements: 10 + totalPages: 5 + pageNumber: 0 + data: + - endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: WEBRTC + status: CONNECTED + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + tag: my-tag + - endpointId: e-2cb0-4a07-b215-b22865662d85-15ac29a2-1331029c + type: WEBRTC + status: CONNECTED + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + tag: my-tag + errors: [] + createEndpointResponseExample: + summary: Create Endpoint Response + value: + links: + - href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + rel: endpoint + method: GET + data: + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + token: xxxxx.yyyyy.zzzzz + type: WEBRTC + status: CONNECTED + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + devices: [] + tag: my-tag + errors: [] + getEndpointResponseExample: + summary: Get Endpoint Response + value: + links: + - href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + rel: self + method: GET + data: + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: WEBRTC + status: CONNECTED + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + devices: [] + tag: my-tag + errors: [] + createSipEndpointRequestExample: + summary: SIP Endpoint Example + value: + type: SIP + connectionMetadata: + ipAddress: 0.0.0.0 + port: 3000 + credentials: + username: username + password: '********' + uuiHeader: 123456;encoding=jwt + direction: INBOUND + eventCallbackUrl: https://myEventCallbackUrl.com/callbacks/bandwidth + eventFallbackUrl: https://fallback.myEventCallbackUrl.com/callbacks/bandwidth + tag: "{\"myTag\": \"myTagValue\"}" + createWeRtcEndpointExample: + summary: WebRTC Endpoint Example + value: + type: WEBRTC + direction: BIDIRECTIONAL + eventCallbackUrl: https://myEventCallbackUrl.com/callbacks/bandwidth + eventFallbackUrl: https://fallback.myEventCallbackUrl.com/callbacks/bandwidth + tag: "{\"myTag\": \"myTagValue\"}" + updateEndpointBxmlRequestExample: + summary: Update Endpoint BXML Request Example + value: + endpointDisconnectedEventExample: + summary: Endpoint Disconnected Event + value: + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: WEBRTC + status: DISCONNECTED + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + eventTime: 2021-01-01T00:00:00Z + eventType: DEVICE_DISCONNECTED + tag: my-tag + badRequestErrorExample: + summary: Bad Request Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: invalid_parameter + description: accountId must not contain any characters other than numbers. + code: "400" + source: + parameter: accountId + unauthorizedErrorExample: + summary: Unauthorized Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: unauthorized + description: The provided credentials are not authorized to access this + resource. + code: "401" + source: + header: Authorization + forbiddenErrorExample: + summary: Forbidden Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: forbidden + description: The provided credentials are not authorized to access this + resource. + code: "403" + source: + header: Authorization + notFoundErrorExample: + summary: Not Found Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: resource_not_found + description: The requested resource was not found. + code: "404" + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + methodNotAllowedErrorExample: + summary: Method Not Allowed Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: method_not_allowed + description: The requested method is not allowed on this resource. + code: "405" + source: + parameter: accountId + unsupportedMediaTypeErrorExample: + summary: Unsupported Media Type Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: unsupported_media_type + description: The provided media type is not supported. + code: "415" + source: + header: Content-Type + tooManyRequestsErrorExample: + summary: Too Many Requests Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: too_many_requests + description: The client has sent too many requests in a given amount of + time. + code: "429" + serviceUnavailableErrorExample: + summary: Service Unavailable Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: service_unavailable + description: The service is currently unavailable. + code: "500" parameters: accountId: description: Your Bandwidth Account ID. @@ -6968,6 +7750,68 @@ components: schema: type: string style: simple + accountId2: + description: Your Bandwidth Account ID. + explode: false + in: path + name: accountId + required: true + schema: + example: "5500123" + type: string + style: simple + endpointId: + description: BRTC Endpoint ID. + explode: false + in: path + name: endpointId + required: true + schema: + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: string + style: simple + endpointType: + description: The type of endpoint. + explode: true + in: query + name: type + required: false + schema: + $ref: "#/components/schemas/endpointTypeEnum" + style: form + endpointStatus: + description: The status of the endpoint. + explode: true + in: query + name: status + required: false + schema: + $ref: "#/components/schemas/endpointStatusEnum" + style: form + afterCursor: + description: The cursor to use for pagination. This is the value of the `next` + link in the previous response. + explode: true + in: query + name: afterCursor + required: false + schema: + example: TWF5IHRoZSBmb3JjZSBiZSB3aXRoIHlvdQ== + type: string + style: form + limit1: + description: The maximum number of endpoints to return in the response. + explode: true + in: query + name: limit + required: false + schema: + default: 100 + example: 2 + maximum: 1000 + minimum: 1 + type: integer + style: form requestBodies: createMessageRequest: content: @@ -7321,6 +8165,27 @@ components: description: Information about a webhook that Bandwidth should send upon the completion of event customer is trying to subscribe to. required: true + createEndpointRequest: + content: + application/json: + examples: + createWebRtcEndpointRequestExample: + $ref: "#/components/examples/createWeRtcEndpointExample" + schema: + $ref: "#/components/schemas/createEndpointRequest" + required: true + updateEndpointBxmlRequest: + content: + application/xml: + examples: + updateEndpointBxmlRequestExample: + $ref: "#/components/examples/updateEndpointBxmlRequestExample" + schema: + description: |- + The BXML document to update the endpoint with. This BXML document will be executed against the endpoint when it is updated. + For more information, please refer to our [BXML documentation](/docs/voice/bxml/). + type: string + required: true responses: createMessageResponse: content: @@ -7932,43 +8797,142 @@ components: description: Cannot find the requested resource. type: Not Found schema: - $ref: "#/components/schemas/tfvError" - description: Cannot find the requested resource. - tfvNotAllowedResponse: + $ref: "#/components/schemas/tfvError" + description: Cannot find the requested resource. + tfvNotAllowedResponse: + content: + application/json: + example: + description: Method is not allowed. + type: Method Not Allowed + schema: + $ref: "#/components/schemas/tfvError" + description: Method Not Allowed + tfvTooManyRequestsResponse: + content: + application/json: + example: + description: Throttling error. Too many requests. + type: Too Many Requests + schema: + $ref: "#/components/schemas/tfvError" + description: Too Many Requests + tfvServerErrorResponse: + content: + application/json: + example: + description: Internal Server Error. + type: Internal Server Error + schema: + $ref: "#/components/schemas/tfvError" + description: Internal Server Error + tfvServiceUnavailableResponse: + content: + application/json: + example: + description: Service Unavailable Error. + type: Service Unavailable + schema: + $ref: "#/components/schemas/tfvError" + description: Service Unavailable + listEndpointsResponse: + content: + application/json: + examples: + listEndpointsResponseExample: + $ref: "#/components/examples/listEndpointsResponseExample" + schema: + $ref: "#/components/schemas/listEndpointsResponse" + description: OK + createEndpointResponse: + content: + application/json: + examples: + createEndpointResponseExample: + $ref: "#/components/examples/createEndpointResponseExample" + schema: + $ref: "#/components/schemas/createEndpointResponse" + description: Created + getEndpointResponse: + content: + application/json: + examples: + getEndpointResponseExample: + $ref: "#/components/examples/getEndpointResponseExample" + schema: + $ref: "#/components/schemas/endpointResponse" + description: OK + badRequestErrorResponse: + content: + application/json: + examples: + badRequestErrorExample: + $ref: "#/components/examples/badRequestErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Bad Request + unauthorizedErrorResponse: + content: + application/json: + examples: + unauthorizedErrorExample: + $ref: "#/components/examples/unauthorizedErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Unauthorized + forbiddenErrorResponse: + content: + application/json: + examples: + forbiddenErrorExample: + $ref: "#/components/examples/forbiddenErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Forbidden + notFoundErrorResponse: + content: + application/json: + examples: + notFoundErrorExample: + $ref: "#/components/examples/notFoundErrorExample" + schema: + $ref: "#/components/schemas/errorResponse" + description: Not Found + methodNotAllowedErrorResponse: content: application/json: - example: - description: Method is not allowed. - type: Method Not Allowed + examples: + methodNotAllowedErrorExample: + $ref: "#/components/examples/methodNotAllowedErrorExample" schema: - $ref: "#/components/schemas/tfvError" + $ref: "#/components/schemas/errorResponse" description: Method Not Allowed - tfvTooManyRequestsResponse: + unsupportedMediaTypeErrorResponse: content: application/json: - example: - description: Throttling error. Too many requests. - type: Too Many Requests + examples: + unsuppotedMediaTypeErrorExample: + $ref: "#/components/examples/unsupportedMediaTypeErrorExample" schema: - $ref: "#/components/schemas/tfvError" - description: Too Many Requests - tfvServerErrorResponse: + $ref: "#/components/schemas/errorResponse" + description: Unsupported Media Type + tooManyRequestsErrorResponse: content: application/json: - example: - description: Internal Server Error. - type: Internal Server Error + examples: + tooManyRequestsErrorExample: + $ref: "#/components/examples/tooManyRequestsErrorExample" schema: - $ref: "#/components/schemas/tfvError" - description: Internal Server Error - tfvServiceUnavailableResponse: + $ref: "#/components/schemas/errorResponse" + description: Too Many Requests + serviceUnavailableErrorResponse: content: application/json: - example: - description: Service Unavailable Error. - type: Service Unavailable + examples: + serviceUnavailableErrorExample: + $ref: "#/components/examples/serviceUnavailableErrorExample" schema: - $ref: "#/components/schemas/tfvError" + $ref: "#/components/schemas/errorResponse" description: Service Unavailable schemas: applicationId: @@ -14785,6 +15749,574 @@ components: nullable: true pattern: "^[ -~]{16,64}$" type: string + endpointId: + description: The unique ID of the endpoint. + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: string + endpointStatusEnum: + enum: + - CONNECTED + - DISCONNECTED + type: string + deviceStatusEnum: + enum: + - CONNECTED + - DISCONNECTED + type: string + endpointTypeEnum: + enum: + - WEBRTC + type: string + endpointDirectionEnum: + enum: + - INBOUND + - OUTBOUND + - BIDIRECTIONAL + type: string + sipCredentials: + properties: + username: + description: The username for the SIP connection. + example: username + type: string + password: + description: The password for the SIP connection. + example: password + type: string + type: object + sipConnectionMetadata: + properties: + ipAddress: + description: The IP address of the SIP connection. + example: 192.168.0.0 + format: ipv4 + type: string + port: + description: The port of the SIP connection. + example: 5060 + type: integer + credentials: + $ref: "#/components/schemas/sipCredentials" + uuiHeader: + description: The User-to-User Information header for the SIP connection. + example: my-uui-header + type: string + title: SIP Connection + type: object + webRtcConnectionMetadata: + title: WebRTC Connection + type: object + endpointToken: + description: The json web token specific to the endpoint. Used to authenticate + the client with the media gateway. + example: xxxxx.yyyyy.zzzzz + type: string + endpointTag: + description: A tag for the endpoint. + example: my-tag + maximum: 1024 + type: string + device: + example: + creationTimestamp: 2021-01-01T00:00:00Z + deviceId: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: David's iPhone + status: CONNECTED + properties: + deviceId: + description: The unique ID of the device. + example: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: string + deviceName: + description: The name of the device. + example: David's iPhone + maximum: 1024 + type: string + status: + $ref: "#/components/schemas/deviceStatusEnum" + creationTimestamp: + description: The time the device was created. In ISO-8601 format. + example: 2021-01-01T00:00:00Z + format: date-time + type: string + required: + - creationTimestamp + - deviceId + - status + type: object + endpoints: + example: + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + tag: my-tag + type: WEBRTC + status: CONNECTED + properties: + endpointId: + description: The unique ID of the endpoint. + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: string + type: + $ref: "#/components/schemas/endpointTypeEnum" + status: + $ref: "#/components/schemas/endpointStatusEnum" + creationTimestamp: + description: The time the endpoint was created. In ISO-8601 format. + example: 2021-01-01T00:00:00Z + format: date-time + type: string + expirationTimestamp: + description: The time the endpoint token will expire. In ISO-8601 format. + Tokens last 24 hours. + example: 2021-01-02T00:00:00Z + format: date-time + type: string + tag: + description: A tag for the endpoint. + example: my-tag + maximum: 1024 + type: string + required: + - creationTimestamp + - endpointId + - expirationTimestamp + - status + - type + type: object + endpoint: + allOf: + - $ref: "#/components/schemas/endpoints" + - properties: + devices: + items: + $ref: "#/components/schemas/device" + type: array + type: object + example: + devices: + - creationTimestamp: 2021-01-01T00:00:00Z + deviceId: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: David's iPhone + status: CONNECTED + - creationTimestamp: 2021-01-01T00:00:00Z + deviceId: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: David's iPhone + status: CONNECTED + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + tag: my-tag + type: WEBRTC + status: CONNECTED + type: object + createWebRtcConnectionRequest: + allOf: + - $ref: "#/components/schemas/createEndpointRequestBase" + - properties: + connectionMetadata: + $ref: "#/components/schemas/webRtcConnectionMetadata" + type: object + createEndpointRequestBase: + properties: + type: + $ref: "#/components/schemas/endpointTypeEnum" + direction: + $ref: "#/components/schemas/endpointDirectionEnum" + eventCallbackUrl: + description: The URL to send event callbacks to. + example: https://myapp.com/callback + format: uri + type: string + eventFallbackUrl: + description: The URL to send event fallbacks to. + example: https://fallback.myapp.com/callback + format: uri + type: string + tag: + description: A tag for the endpoint. + example: my-tag + maximum: 1024 + type: string + required: + - direction + - type + type: object + createEndpointRequest: + $ref: "#/components/schemas/createWebRtcConnectionRequest" + createEndpointResponseObject: + allOf: + - $ref: "#/components/schemas/endpoint" + - properties: + token: + $ref: "#/components/schemas/endpointToken" + required: + - token + type: object + example: + devices: + - creationTimestamp: 2021-01-01T00:00:00Z + deviceId: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: David's iPhone + status: CONNECTED + - creationTimestamp: 2021-01-01T00:00:00Z + deviceId: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: David's iPhone + status: CONNECTED + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + tag: my-tag + type: WEBRTC + status: CONNECTED + token: xxxxx.yyyyy.zzzzz + endpointEventTypeEnum: + enum: + - DEVICE_CONNECTED + - DEVICE_DISCONNECTED + type: string + endpointEvent: + allOf: + - $ref: "#/components/schemas/endpoints" + - properties: + eventTime: + description: The time the event occurred. In ISO-8601 format. + example: 2021-01-01T00:00:00Z + format: date-time + type: string + eventType: + $ref: "#/components/schemas/endpointEventTypeEnum" + device: + $ref: "#/components/schemas/device" + required: + - eventTime + - eventType + type: object + description: An event that occurred on an endpoint. + link1: + example: + method: GET + rel: self + href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + properties: + href: + description: The full URL of the link. + example: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: string + rel: + description: The relationship of the link to the current resource. + example: self + type: string + method: + description: The HTTP method to use when making the request. + enum: + - GET + - POST + - DELETE + example: GET + type: string + type: object + page: + example: + pageNumber: 0 + totalPages: 10 + pageSize: 10 + totalElements: 100 + properties: + pageSize: + description: The number of items per page. + example: 10 + minimum: 0 + type: integer + totalElements: + description: The total number of items. + example: 100 + minimum: 0 + type: integer + totalPages: + description: The total number of pages. + example: 10 + minimum: 0 + type: integer + pageNumber: + description: The current page number. + example: 0 + minimum: 0 + type: integer + required: + - pageSize + type: object + error1: + example: + code: "404" + description: The requested resource was not found. + id: 59512d87-7a92-4040-8e4a-78fb772019b9 + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + type: resource.not_found + properties: + id: + description: A unique identifier for the error. + example: 59512d87-7a92-4040-8e4a-78fb772019b9 + format: uuid + type: string + type: + description: The type of error. + example: resource.not_found + type: string + description: + description: A description of the error. + example: The requested resource was not found. + type: string + code: + description: A code that uniquely identifies the error. + example: "404" + type: string + source: + $ref: "#/components/schemas/error1_source" + required: + - code + - description + - id + - type + type: object + listEndpointsResponse: + example: + data: + - endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + tag: my-tag + type: WEBRTC + status: CONNECTED + - endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + tag: my-tag + type: WEBRTC + status: CONNECTED + links: + - method: GET + rel: self + href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + - method: GET + rel: self + href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + page: + pageNumber: 0 + totalPages: 10 + pageSize: 10 + totalElements: 100 + errors: + - code: "404" + description: The requested resource was not found. + id: 59512d87-7a92-4040-8e4a-78fb772019b9 + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + type: resource.not_found + - code: "404" + description: The requested resource was not found. + id: 59512d87-7a92-4040-8e4a-78fb772019b9 + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + type: resource.not_found + properties: + links: + items: + $ref: "#/components/schemas/link1" + type: array + page: + $ref: "#/components/schemas/page" + data: + items: + $ref: "#/components/schemas/endpoints" + type: array + errors: + items: + $ref: "#/components/schemas/error1" + type: array + required: + - data + - errors + - links + type: object + endpointResponse: + example: + data: + devices: + - creationTimestamp: 2021-01-01T00:00:00Z + deviceId: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: David's iPhone + status: CONNECTED + - creationTimestamp: 2021-01-01T00:00:00Z + deviceId: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: David's iPhone + status: CONNECTED + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + tag: my-tag + type: WEBRTC + status: CONNECTED + links: + - method: GET + rel: self + href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + - method: GET + rel: self + href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + errors: + - code: "404" + description: The requested resource was not found. + id: 59512d87-7a92-4040-8e4a-78fb772019b9 + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + type: resource.not_found + - code: "404" + description: The requested resource was not found. + id: 59512d87-7a92-4040-8e4a-78fb772019b9 + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + type: resource.not_found + properties: + links: + items: + $ref: "#/components/schemas/link1" + type: array + data: + $ref: "#/components/schemas/endpoint" + errors: + items: + $ref: "#/components/schemas/error1" + type: array + required: + - data + - errors + - links + type: object + createEndpointResponse: + example: + data: + devices: + - creationTimestamp: 2021-01-01T00:00:00Z + deviceId: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: David's iPhone + status: CONNECTED + - creationTimestamp: 2021-01-01T00:00:00Z + deviceId: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: David's iPhone + status: CONNECTED + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + creationTimestamp: 2021-01-01T00:00:00Z + expirationTimestamp: 2021-01-02T00:00:00Z + tag: my-tag + type: WEBRTC + status: CONNECTED + token: xxxxx.yyyyy.zzzzz + links: + - method: GET + rel: self + href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + - method: GET + rel: self + href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + errors: + - code: "404" + description: The requested resource was not found. + id: 59512d87-7a92-4040-8e4a-78fb772019b9 + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + type: resource.not_found + - code: "404" + description: The requested resource was not found. + id: 59512d87-7a92-4040-8e4a-78fb772019b9 + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + type: resource.not_found + properties: + links: + items: + $ref: "#/components/schemas/link1" + type: array + data: + $ref: "#/components/schemas/createEndpointResponseObject" + errors: + items: + $ref: "#/components/schemas/error1" + type: array + required: + - data + - errors + - links + type: object + errorResponse: + example: + data: "{}" + links: + - method: GET + rel: self + href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + - method: GET + rel: self + href: https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + errors: + - code: "404" + description: The requested resource was not found. + id: 59512d87-7a92-4040-8e4a-78fb772019b9 + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + type: resource.not_found + - code: "404" + description: The requested resource was not found. + id: 59512d87-7a92-4040-8e4a-78fb772019b9 + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + type: resource.not_found + properties: + links: + items: + $ref: "#/components/schemas/link1" + type: array + data: + additionalProperties: false + nullable: true + type: object + errors: + items: + $ref: "#/components/schemas/error1" + type: array + required: + - data + - errors + - links + type: object rbmCardContent_media: allOf: - $ref: "#/components/schemas/rbmMessageContentFile" @@ -14942,6 +16474,31 @@ components: - password - username type: object + error1_source: + example: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + field: accountId + parameter: accountId + header: Authorization + properties: + parameter: + description: The URI parameter that caused the error. + example: accountId + type: string + field: + description: The request body field that caused the error. + example: accountId + type: string + header: + description: The header that caused the error. + example: Authorization + type: string + reference: + description: The resource ID or path to the resource (or non-existent resource) + causing the error. + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: string + type: object securitySchemes: Basic: description: |- diff --git a/bandwidth.yml b/bandwidth.yml index d7c32953..d5d32cf9 100644 --- a/bandwidth.yml +++ b/bandwidth.yml @@ -22,6 +22,7 @@ tags: - name: MFA - name: Phone Number Lookup - name: Toll-Free Verification + - name: Endpoints paths: /users/{accountId}/media: get: @@ -1682,6 +1683,165 @@ paths: '503': $ref: '#/components/responses/tfvServiceUnavailableResponse' servers: *ref_4 + /accounts/{accountId}/endpoints: + get: + tags: + - Endpoints + summary: List Endpoints + description: Returns a list of endpoints associated with the specified account. + operationId: listEndpoints + parameters: + - $ref: '#/components/parameters/accountId2' + - $ref: '#/components/parameters/endpointType' + - $ref: '#/components/parameters/endpointStatus' + - $ref: '#/components/parameters/afterCursor' + - $ref: '#/components/parameters/limit1' + responses: + '200': + $ref: '#/components/responses/listEndpointsResponse' + '400': + $ref: '#/components/responses/badRequestErrorResponse' + '401': + $ref: '#/components/responses/unauthorizedErrorResponse' + '403': + $ref: '#/components/responses/forbiddenErrorResponse' + '404': + $ref: '#/components/responses/notFoundErrorResponse' + '405': + $ref: '#/components/responses/methodNotAllowedErrorResponse' + '415': + $ref: '#/components/responses/unsupportedMediaTypeErrorResponse' + '429': + $ref: '#/components/responses/tooManyRequestsErrorResponse' + '500': + $ref: '#/components/responses/serviceUnavailableErrorResponse' + post: + tags: + - Endpoints + summary: Create Endpoint + description: Creates a new Endpoint for the specified account. + operationId: createEndpoint + parameters: + - $ref: '#/components/parameters/accountId2' + requestBody: + $ref: '#/components/requestBodies/createEndpointRequest' + responses: + '201': + $ref: '#/components/responses/createEndpointResponse' + '400': + $ref: '#/components/responses/badRequestErrorResponse' + '401': + $ref: '#/components/responses/unauthorizedErrorResponse' + '403': + $ref: '#/components/responses/forbiddenErrorResponse' + '404': + $ref: '#/components/responses/notFoundErrorResponse' + '405': + $ref: '#/components/responses/methodNotAllowedErrorResponse' + '415': + $ref: '#/components/responses/unsupportedMediaTypeErrorResponse' + '429': + $ref: '#/components/responses/tooManyRequestsErrorResponse' + '500': + $ref: '#/components/responses/serviceUnavailableErrorResponse' + callbacks: + endpointEventCallback: + $ref: '#/components/callbacks/endpointEvent' + servers: &ref_5 + - url: https://api.bandwidth.com/v2 + description: Production + /accounts/{accountId}/endpoints/{endpointId}: + get: + tags: + - Endpoints + summary: Get Endpoint + description: Returns information about the specified endpoint. + operationId: getEndpoint + parameters: + - $ref: '#/components/parameters/accountId2' + - $ref: '#/components/parameters/endpointId' + responses: + '200': + $ref: '#/components/responses/getEndpointResponse' + '400': + $ref: '#/components/responses/badRequestErrorResponse' + '401': + $ref: '#/components/responses/unauthorizedErrorResponse' + '403': + $ref: '#/components/responses/forbiddenErrorResponse' + '404': + $ref: '#/components/responses/notFoundErrorResponse' + '405': + $ref: '#/components/responses/methodNotAllowedErrorResponse' + '415': + $ref: '#/components/responses/unsupportedMediaTypeErrorResponse' + '429': + $ref: '#/components/responses/tooManyRequestsErrorResponse' + '500': + $ref: '#/components/responses/serviceUnavailableErrorResponse' + delete: + tags: + - Endpoints + summary: Delete Endpoint + description: >- + Deletes the specified endpoint. If the endpoint is actively streaming + media, the media stream will be terminated. + operationId: deleteEndpoint + parameters: + - $ref: '#/components/parameters/accountId2' + - $ref: '#/components/parameters/endpointId' + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/badRequestErrorResponse' + '401': + $ref: '#/components/responses/unauthorizedErrorResponse' + '403': + $ref: '#/components/responses/forbiddenErrorResponse' + '404': + $ref: '#/components/responses/notFoundErrorResponse' + '405': + $ref: '#/components/responses/methodNotAllowedErrorResponse' + '415': + $ref: '#/components/responses/unsupportedMediaTypeErrorResponse' + '429': + $ref: '#/components/responses/tooManyRequestsErrorResponse' + '500': + $ref: '#/components/responses/serviceUnavailableErrorResponse' + servers: *ref_5 + /accounts/{accountId}/endpoints/{endpointId}/bxml: + put: + tags: + - Endpoints + summary: Update Endpoint BXML + description: Updates the BXML for the specified endpoint. + operationId: updateEndpointBxml + parameters: + - $ref: '#/components/parameters/accountId2' + - $ref: '#/components/parameters/endpointId' + requestBody: + $ref: '#/components/requestBodies/updateEndpointBxmlRequest' + responses: + '204': + description: No Content + '400': + $ref: '#/components/responses/badRequestErrorResponse' + '401': + $ref: '#/components/responses/unauthorizedErrorResponse' + '403': + $ref: '#/components/responses/forbiddenErrorResponse' + '404': + $ref: '#/components/responses/notFoundErrorResponse' + '405': + $ref: '#/components/responses/methodNotAllowedErrorResponse' + '415': + $ref: '#/components/responses/unsupportedMediaTypeErrorResponse' + '429': + $ref: '#/components/responses/tooManyRequestsErrorResponse' + '500': + $ref: '#/components/responses/serviceUnavailableErrorResponse' + servers: *ref_5 components: schemas: applicationId: @@ -6520,6 +6680,369 @@ components: nullable: true pattern: ^[ -~]{16,64}$ type: string + endpointId: + type: string + description: The unique ID of the endpoint. + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + endpointStatusEnum: + type: string + enum: + - CONNECTED + - DISCONNECTED + deviceStatusEnum: + type: string + enum: + - CONNECTED + - DISCONNECTED + endpointTypeEnum: + type: string + enum: + - WEBRTC + endpointDirectionEnum: + type: string + enum: + - INBOUND + - OUTBOUND + - BIDIRECTIONAL + sipCredentials: + type: object + properties: + username: + type: string + description: The username for the SIP connection. + example: username + password: + type: string + description: The password for the SIP connection. + example: password + sipConnectionMetadata: + title: SIP Connection + type: object + properties: + ipAddress: + type: string + format: ipv4 + description: The IP address of the SIP connection. + example: 192.168.0.0 + port: + type: integer + description: The port of the SIP connection. + example: 5060 + credentials: + $ref: '#/components/schemas/sipCredentials' + uuiHeader: + type: string + description: The User-to-User Information header for the SIP connection. + example: my-uui-header + webRtcConnectionMetadata: + title: WebRTC Connection + type: object + endpointToken: + type: string + description: >- + The json web token specific to the endpoint. Used to authenticate the + client with the media gateway. + example: xxxxx.yyyyy.zzzzz + endpointTag: + type: string + description: A tag for the endpoint. + example: my-tag + maximum: 1024 + device: + type: object + properties: + deviceId: + type: string + description: The unique ID of the device. + example: d-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + deviceName: + type: string + description: The name of the device. + maximum: 1024 + example: David's iPhone + status: + $ref: '#/components/schemas/deviceStatusEnum' + creationTimestamp: + type: string + format: date-time + description: The time the device was created. In ISO-8601 format. + example: '2021-01-01T00:00:00Z' + required: + - deviceId + - status + - creationTimestamp + endpoints: + type: object + properties: + endpointId: + $ref: '#/components/schemas/endpointId' + type: + $ref: '#/components/schemas/endpointTypeEnum' + status: + $ref: '#/components/schemas/endpointStatusEnum' + creationTimestamp: + type: string + format: date-time + description: The time the endpoint was created. In ISO-8601 format. + example: '2021-01-01T00:00:00Z' + expirationTimestamp: + type: string + format: date-time + description: >- + The time the endpoint token will expire. In ISO-8601 format. Tokens + last 24 hours. + example: '2021-01-02T00:00:00Z' + tag: + $ref: '#/components/schemas/endpointTag' + required: + - endpointId + - type + - status + - creationTimestamp + - expirationTimestamp + endpoint: + type: object + allOf: + - $ref: '#/components/schemas/endpoints' + - type: object + properties: + devices: + type: array + items: + $ref: '#/components/schemas/device' + createWebRtcConnectionRequest: + allOf: + - $ref: '#/components/schemas/createEndpointRequestBase' + - type: object + properties: + connectionMetadata: + $ref: '#/components/schemas/webRtcConnectionMetadata' + createEndpointRequestBase: + type: object + properties: + type: + $ref: '#/components/schemas/endpointTypeEnum' + direction: + $ref: '#/components/schemas/endpointDirectionEnum' + eventCallbackUrl: + type: string + format: uri + description: The URL to send event callbacks to. + example: https://myapp.com/callback + eventFallbackUrl: + type: string + format: uri + description: The URL to send event fallbacks to. + example: https://fallback.myapp.com/callback + tag: + $ref: '#/components/schemas/endpointTag' + required: + - type + - direction + createEndpointRequest: + oneOf: + - $ref: '#/components/schemas/createWebRtcConnectionRequest' + discriminator: + propertyName: type + mapping: + WEBRTC: '#/components/schemas/createWebRtcConnectionRequest' + createEndpointResponseObject: + allOf: + - $ref: '#/components/schemas/endpoint' + - type: object + properties: + token: + $ref: '#/components/schemas/endpointToken' + required: + - token + endpointEventTypeEnum: + type: string + enum: + - DEVICE_CONNECTED + - DEVICE_DISCONNECTED + endpointEvent: + description: An event that occurred on an endpoint. + allOf: + - $ref: '#/components/schemas/endpoints' + - type: object + properties: + eventTime: + type: string + format: date-time + description: The time the event occurred. In ISO-8601 format. + example: '2021-01-01T00:00:00Z' + eventType: + $ref: '#/components/schemas/endpointEventTypeEnum' + device: + $ref: '#/components/schemas/device' + required: + - eventType + - eventTime + link1: + type: object + properties: + href: + type: string + description: The full URL of the link. + example: >- + https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + rel: + type: string + description: The relationship of the link to the current resource. + example: self + method: + type: string + enum: + - GET + - POST + - DELETE + description: The HTTP method to use when making the request. + example: GET + page: + type: object + properties: + pageSize: + type: integer + description: The number of items per page. + minimum: 0 + example: 10 + totalElements: + type: integer + description: The total number of items. + minimum: 0 + example: 100 + totalPages: + type: integer + description: The total number of pages. + minimum: 0 + example: 10 + pageNumber: + type: integer + description: The current page number. + minimum: 0 + example: 0 + required: + - pageSize + error1: + type: object + properties: + id: + type: string + format: uuid + description: A unique identifier for the error. + example: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: + type: string + description: The type of error. + example: resource.not_found + description: + type: string + description: A description of the error. + example: The requested resource was not found. + code: + type: string + description: A code that uniquely identifies the error. + example: '404' + source: + type: object + properties: + parameter: + type: string + description: The URI parameter that caused the error. + example: accountId + field: + type: string + description: The request body field that caused the error. + example: accountId + header: + type: string + description: The header that caused the error. + example: Authorization + reference: + type: string + description: >- + The resource ID or path to the resource (or non-existent + resource) causing the error. + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + required: + - id + - type + - description + - code + listEndpointsResponse: + type: object + properties: + links: + type: array + items: + $ref: '#/components/schemas/link1' + page: + $ref: '#/components/schemas/page' + data: + type: array + items: + $ref: '#/components/schemas/endpoints' + errors: + type: array + items: + $ref: '#/components/schemas/error1' + required: + - links + - data + - errors + endpointResponse: + type: object + properties: + links: + type: array + items: + $ref: '#/components/schemas/link1' + data: + $ref: '#/components/schemas/endpoint' + errors: + type: array + items: + $ref: '#/components/schemas/error1' + required: + - links + - data + - errors + createEndpointResponse: + type: object + properties: + links: + type: array + items: + $ref: '#/components/schemas/link1' + data: + $ref: '#/components/schemas/createEndpointResponseObject' + errors: + type: array + items: + $ref: '#/components/schemas/error1' + required: + - links + - data + - errors + errorResponse: + type: object + properties: + links: + type: array + items: + $ref: '#/components/schemas/link1' + data: + type: object + nullable: true + additionalProperties: false + errors: + type: array + items: + $ref: '#/components/schemas/error1' + required: + - links + - data + - errors responses: createMessageResponse: description: Accepted @@ -7171,6 +7694,105 @@ components: example: description: Service Unavailable Error. type: Service Unavailable + listEndpointsResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/listEndpointsResponse' + examples: + listEndpointsResponseExample: + $ref: '#/components/examples/listEndpointsResponseExample' + createEndpointResponse: + description: Created + content: + application/json: + schema: + $ref: '#/components/schemas/createEndpointResponse' + examples: + createEndpointResponseExample: + $ref: '#/components/examples/createEndpointResponseExample' + getEndpointResponse: + description: OK + content: + application/json: + schema: + $ref: '#/components/schemas/endpointResponse' + examples: + getEndpointResponseExample: + $ref: '#/components/examples/getEndpointResponseExample' + badRequestErrorResponse: + description: Bad Request + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + examples: + badRequestErrorExample: + $ref: '#/components/examples/badRequestErrorExample' + unauthorizedErrorResponse: + description: Unauthorized + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + examples: + unauthorizedErrorExample: + $ref: '#/components/examples/unauthorizedErrorExample' + forbiddenErrorResponse: + description: Forbidden + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + examples: + forbiddenErrorExample: + $ref: '#/components/examples/forbiddenErrorExample' + notFoundErrorResponse: + description: Not Found + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + examples: + notFoundErrorExample: + $ref: '#/components/examples/notFoundErrorExample' + methodNotAllowedErrorResponse: + description: Method Not Allowed + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + examples: + methodNotAllowedErrorExample: + $ref: '#/components/examples/methodNotAllowedErrorExample' + unsupportedMediaTypeErrorResponse: + description: Unsupported Media Type + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + examples: + unsuppotedMediaTypeErrorExample: + $ref: '#/components/examples/unsupportedMediaTypeErrorExample' + tooManyRequestsErrorResponse: + description: Too Many Requests + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + examples: + tooManyRequestsErrorExample: + $ref: '#/components/examples/tooManyRequestsErrorExample' + serviceUnavailableErrorResponse: + description: Service Unavailable + content: + application/json: + schema: + $ref: '#/components/schemas/errorResponse' + examples: + serviceUnavailableErrorExample: + $ref: '#/components/examples/serviceUnavailableErrorExample' parameters: accountId: in: path @@ -7670,6 +8292,53 @@ components: type: string description: Webhook subscription ID example: 7bt57JcsVYJrN9K1OcV1Nu + accountId2: + name: accountId + in: path + required: true + schema: + type: string + example: '5500123' + description: Your Bandwidth Account ID. + endpointId: + name: endpointId + in: path + required: true + schema: + type: string + example: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + description: BRTC Endpoint ID. + endpointType: + name: type + in: query + schema: + $ref: '#/components/schemas/endpointTypeEnum' + description: The type of endpoint. + endpointStatus: + name: status + in: query + schema: + $ref: '#/components/schemas/endpointStatusEnum' + description: The status of the endpoint. + afterCursor: + name: afterCursor + in: query + schema: + type: string + example: TWF5IHRoZSBmb3JjZSBiZSB3aXRoIHlvdQ== + description: >- + The cursor to use for pagination. This is the value of the `next` link + in the previous response. + limit1: + name: limit + in: query + schema: + type: integer + minimum: 1 + maximum: 1000 + default: 100 + example: 2 + description: The maximum number of endpoints to return in the response. examples: smsMessageReceivedCallbackExample: summary: An example of a sms message-received callback body. @@ -8094,6 +8763,205 @@ components: Unexpected error. Please contact Bandwidth Support if your requests are receiving this status code for an extended period of time. + listEndpointsResponseExample: + summary: List Endpoints Paginated Response + value: + links: + - href: >- + https://api.bandwidth.com/v2/accounts/5500123/endpoints?type=SIP&status=CONNECTED&limit=2 + rel: self + method: GET + - href: >- + https://api.bandwidth.com/v2/accounts/5500123/endpoints?type=SIP&status=CONNECTED&limit=2&afterCursor=TWF5IHRoZSBmb3JjZSBiZSB3aXRoIHlvdQ== + rel: next + method: GET + page: + pageSize: 2 + totalElements: 10 + totalPages: 5 + pageNumber: 0 + data: + - endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: WEBRTC + status: CONNECTED + creationTimestamp: '2021-01-01T00:00:00Z' + expirationTimestamp: '2021-01-02T00:00:00Z' + tag: my-tag + - endpointId: e-2cb0-4a07-b215-b22865662d85-15ac29a2-1331029c + type: WEBRTC + status: CONNECTED + creationTimestamp: '2021-01-01T00:00:00Z' + expirationTimestamp: '2021-01-02T00:00:00Z' + tag: my-tag + errors: [] + createEndpointResponseExample: + summary: Create Endpoint Response + value: + links: + - href: >- + https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + rel: endpoint + method: GET + data: + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + token: xxxxx.yyyyy.zzzzz + type: WEBRTC + status: CONNECTED + creationTimestamp: '2021-01-01T00:00:00Z' + expirationTimestamp: '2021-01-02T00:00:00Z' + devices: [] + tag: my-tag + errors: [] + getEndpointResponseExample: + summary: Get Endpoint Response + value: + links: + - href: >- + https://api.bandwidth.com/v2/accounts/5500123/endpoints/e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + rel: self + method: GET + data: + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: WEBRTC + status: CONNECTED + creationTimestamp: '2021-01-01T00:00:00Z' + expirationTimestamp: '2021-01-02T00:00:00Z' + devices: [] + tag: my-tag + errors: [] + createSipEndpointRequestExample: + summary: SIP Endpoint Example + value: + type: SIP + connectionMetadata: + ipAddress: 0.0.0.0 + port: 3000 + credentials: + username: username + password: '********' + uuiHeader: 123456;encoding=jwt + direction: INBOUND + eventCallbackUrl: https://myEventCallbackUrl.com/callbacks/bandwidth + eventFallbackUrl: https://fallback.myEventCallbackUrl.com/callbacks/bandwidth + tag: '{"myTag": "myTagValue"}' + createWeRtcEndpointExample: + summary: WebRTC Endpoint Example + value: + type: WEBRTC + direction: BIDIRECTIONAL + eventCallbackUrl: https://myEventCallbackUrl.com/callbacks/bandwidth + eventFallbackUrl: https://fallback.myEventCallbackUrl.com/callbacks/bandwidth + tag: '{"myTag": "myTagValue"}' + updateEndpointBxmlRequestExample: + summary: Update Endpoint BXML Request Example + value: + endpointDisconnectedEventExample: + summary: Endpoint Disconnected Event + value: + endpointId: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + type: WEBRTC + status: DISCONNECTED + creationTimestamp: '2021-01-01T00:00:00Z' + expirationTimestamp: '2021-01-02T00:00:00Z' + eventTime: '2021-01-01T00:00:00Z' + eventType: DEVICE_DISCONNECTED + tag: my-tag + badRequestErrorExample: + summary: Bad Request Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: invalid_parameter + description: accountId must not contain any characters other than numbers. + code: '400' + source: + parameter: accountId + unauthorizedErrorExample: + summary: Unauthorized Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: unauthorized + description: >- + The provided credentials are not authorized to access this + resource. + code: '401' + source: + header: Authorization + forbiddenErrorExample: + summary: Forbidden Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: forbidden + description: >- + The provided credentials are not authorized to access this + resource. + code: '403' + source: + header: Authorization + notFoundErrorExample: + summary: Not Found Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: resource_not_found + description: The requested resource was not found. + code: '404' + source: + reference: e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85 + methodNotAllowedErrorExample: + summary: Method Not Allowed Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: method_not_allowed + description: The requested method is not allowed on this resource. + code: '405' + source: + parameter: accountId + unsupportedMediaTypeErrorExample: + summary: Unsupported Media Type Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: unsupported_media_type + description: The provided media type is not supported. + code: '415' + source: + header: Content-Type + tooManyRequestsErrorExample: + summary: Too Many Requests Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: too_many_requests + description: The client has sent too many requests in a given amount of time. + code: '429' + serviceUnavailableErrorExample: + summary: Service Unavailable Error Example + value: + links: [] + data: null + errors: + - id: 59512d87-7a92-4040-8e4a-78fb772019b9 + type: service_unavailable + description: The service is currently unavailable. + code: '500' requestBodies: createMessageRequest: content: @@ -8449,6 +9317,30 @@ components: application/json: schema: $ref: '#/components/schemas/webhookSubscriptionRequestSchema' + createEndpointRequest: + required: true + content: + application/json: + schema: + $ref: '#/components/schemas/createEndpointRequest' + examples: + createWebRtcEndpointRequestExample: + $ref: '#/components/examples/createWeRtcEndpointExample' + updateEndpointBxmlRequest: + required: true + content: + application/xml: + schema: + type: string + description: >- + The BXML document to update the endpoint with. This BXML document + will be executed against the endpoint when it is updated. + + For more information, please refer to our [BXML + documentation](/docs/voice/bxml/). + examples: + updateEndpointBxmlRequestExample: + $ref: '#/components/examples/updateEndpointBxmlRequestExample' securitySchemes: Basic: type: http @@ -8582,3 +9474,17 @@ components: $ref: '#/components/responses/tfvServerErrorResponse' '503': $ref: '#/components/responses/tfvServiceUnavailableResponse' + endpointEvent: + '{request.body#/eventCallbackUrl}': + post: + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/endpointEvent' + examples: + endpointDisconnectedEventExample: + $ref: '#/components/examples/endpointDisconnectedEventExample' + responses: + '204': + description: Event was successfully received. diff --git a/docs/CreateEndpointRequestBase.md b/docs/CreateEndpointRequestBase.md new file mode 100644 index 00000000..63c36223 --- /dev/null +++ b/docs/CreateEndpointRequestBase.md @@ -0,0 +1,17 @@ + + +# CreateEndpointRequestBase + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **EndpointTypeEnum** | | | +|**direction** | **EndpointDirectionEnum** | | | +|**eventCallbackUrl** | **URI** | The URL to send event callbacks to. | [optional] | +|**eventFallbackUrl** | **URI** | The URL to send event fallbacks to. | [optional] | +|**tag** | **String** | A tag for the endpoint. | [optional] | + + + diff --git a/docs/CreateEndpointResponse.md b/docs/CreateEndpointResponse.md new file mode 100644 index 00000000..aff840ea --- /dev/null +++ b/docs/CreateEndpointResponse.md @@ -0,0 +1,15 @@ + + +# CreateEndpointResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**links** | [**List<Link1>**](Link1.md) | | | +|**data** | [**CreateEndpointResponseObject**](CreateEndpointResponseObject.md) | | | +|**errors** | [**List<Error1>**](Error1.md) | | | + + + diff --git a/docs/CreateEndpointResponseObject.md b/docs/CreateEndpointResponseObject.md new file mode 100644 index 00000000..4506e590 --- /dev/null +++ b/docs/CreateEndpointResponseObject.md @@ -0,0 +1,20 @@ + + +# CreateEndpointResponseObject + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**endpointId** | **String** | The unique ID of the endpoint. | | +|**type** | **EndpointTypeEnum** | | | +|**status** | **EndpointStatusEnum** | | | +|**creationTimestamp** | **OffsetDateTime** | The time the endpoint was created. In ISO-8601 format. | | +|**expirationTimestamp** | **OffsetDateTime** | The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours. | | +|**tag** | **String** | A tag for the endpoint. | [optional] | +|**devices** | [**List<Device>**](Device.md) | | [optional] | +|**token** | **String** | The json web token specific to the endpoint. Used to authenticate the client with the media gateway. | | + + + diff --git a/docs/CreateWebRtcConnectionRequest.md b/docs/CreateWebRtcConnectionRequest.md new file mode 100644 index 00000000..70c3da9e --- /dev/null +++ b/docs/CreateWebRtcConnectionRequest.md @@ -0,0 +1,18 @@ + + +# CreateWebRtcConnectionRequest + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**type** | **EndpointTypeEnum** | | | +|**direction** | **EndpointDirectionEnum** | | | +|**eventCallbackUrl** | **URI** | The URL to send event callbacks to. | [optional] | +|**eventFallbackUrl** | **URI** | The URL to send event fallbacks to. | [optional] | +|**tag** | **String** | A tag for the endpoint. | [optional] | +|**connectionMetadata** | **Object** | | [optional] | + + + diff --git a/docs/Device.md b/docs/Device.md new file mode 100644 index 00000000..f3480867 --- /dev/null +++ b/docs/Device.md @@ -0,0 +1,16 @@ + + +# Device + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**deviceId** | **String** | The unique ID of the device. | | +|**deviceName** | **String** | The name of the device. | [optional] | +|**status** | **DeviceStatusEnum** | | | +|**creationTimestamp** | **OffsetDateTime** | The time the device was created. In ISO-8601 format. | | + + + diff --git a/docs/DeviceStatusEnum.md b/docs/DeviceStatusEnum.md new file mode 100644 index 00000000..555f3745 --- /dev/null +++ b/docs/DeviceStatusEnum.md @@ -0,0 +1,13 @@ + + +# DeviceStatusEnum + +## Enum + + +* `CONNECTED` (value: `"CONNECTED"`) + +* `DISCONNECTED` (value: `"DISCONNECTED"`) + + + diff --git a/docs/Endpoint.md b/docs/Endpoint.md new file mode 100644 index 00000000..645088d7 --- /dev/null +++ b/docs/Endpoint.md @@ -0,0 +1,19 @@ + + +# Endpoint + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**endpointId** | **String** | The unique ID of the endpoint. | | +|**type** | **EndpointTypeEnum** | | | +|**status** | **EndpointStatusEnum** | | | +|**creationTimestamp** | **OffsetDateTime** | The time the endpoint was created. In ISO-8601 format. | | +|**expirationTimestamp** | **OffsetDateTime** | The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours. | | +|**tag** | **String** | A tag for the endpoint. | [optional] | +|**devices** | [**List<Device>**](Device.md) | | [optional] | + + + diff --git a/docs/EndpointDirectionEnum.md b/docs/EndpointDirectionEnum.md new file mode 100644 index 00000000..1e74e06e --- /dev/null +++ b/docs/EndpointDirectionEnum.md @@ -0,0 +1,15 @@ + + +# EndpointDirectionEnum + +## Enum + + +* `INBOUND` (value: `"INBOUND"`) + +* `OUTBOUND` (value: `"OUTBOUND"`) + +* `BIDIRECTIONAL` (value: `"BIDIRECTIONAL"`) + + + diff --git a/docs/EndpointEvent.md b/docs/EndpointEvent.md new file mode 100644 index 00000000..5c844cb0 --- /dev/null +++ b/docs/EndpointEvent.md @@ -0,0 +1,22 @@ + + +# EndpointEvent + +An event that occurred on an endpoint. + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**endpointId** | **String** | The unique ID of the endpoint. | | +|**type** | **EndpointTypeEnum** | | | +|**status** | **EndpointStatusEnum** | | | +|**creationTimestamp** | **OffsetDateTime** | The time the endpoint was created. In ISO-8601 format. | | +|**expirationTimestamp** | **OffsetDateTime** | The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours. | | +|**tag** | **String** | A tag for the endpoint. | [optional] | +|**eventTime** | **OffsetDateTime** | The time the event occurred. In ISO-8601 format. | | +|**eventType** | **EndpointEventTypeEnum** | | | +|**device** | [**Device**](Device.md) | | [optional] | + + + diff --git a/docs/EndpointEventTypeEnum.md b/docs/EndpointEventTypeEnum.md new file mode 100644 index 00000000..c2aedec7 --- /dev/null +++ b/docs/EndpointEventTypeEnum.md @@ -0,0 +1,13 @@ + + +# EndpointEventTypeEnum + +## Enum + + +* `DEVICE_CONNECTED` (value: `"DEVICE_CONNECTED"`) + +* `DEVICE_DISCONNECTED` (value: `"DEVICE_DISCONNECTED"`) + + + diff --git a/docs/EndpointResponse.md b/docs/EndpointResponse.md new file mode 100644 index 00000000..d5615e9c --- /dev/null +++ b/docs/EndpointResponse.md @@ -0,0 +1,15 @@ + + +# EndpointResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**links** | [**List<Link1>**](Link1.md) | | | +|**data** | [**Endpoint**](Endpoint.md) | | | +|**errors** | [**List<Error1>**](Error1.md) | | | + + + diff --git a/docs/EndpointStatusEnum.md b/docs/EndpointStatusEnum.md new file mode 100644 index 00000000..49744c9a --- /dev/null +++ b/docs/EndpointStatusEnum.md @@ -0,0 +1,13 @@ + + +# EndpointStatusEnum + +## Enum + + +* `CONNECTED` (value: `"CONNECTED"`) + +* `DISCONNECTED` (value: `"DISCONNECTED"`) + + + diff --git a/docs/EndpointTypeEnum.md b/docs/EndpointTypeEnum.md new file mode 100644 index 00000000..f4753aaa --- /dev/null +++ b/docs/EndpointTypeEnum.md @@ -0,0 +1,11 @@ + + +# EndpointTypeEnum + +## Enum + + +* `WEBRTC` (value: `"WEBRTC"`) + + + diff --git a/docs/Endpoints.md b/docs/Endpoints.md new file mode 100644 index 00000000..9f50cf22 --- /dev/null +++ b/docs/Endpoints.md @@ -0,0 +1,18 @@ + + +# Endpoints + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**endpointId** | **String** | The unique ID of the endpoint. | | +|**type** | **EndpointTypeEnum** | | | +|**status** | **EndpointStatusEnum** | | | +|**creationTimestamp** | **OffsetDateTime** | The time the endpoint was created. In ISO-8601 format. | | +|**expirationTimestamp** | **OffsetDateTime** | The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours. | | +|**tag** | **String** | A tag for the endpoint. | [optional] | + + + diff --git a/docs/EndpointsApi.md b/docs/EndpointsApi.md new file mode 100644 index 00000000..e7fd945f --- /dev/null +++ b/docs/EndpointsApi.md @@ -0,0 +1,429 @@ +# EndpointsApi + +All URIs are relative to *http://localhost* + +| Method | HTTP request | Description | +|------------- | ------------- | -------------| +| [**createEndpoint**](EndpointsApi.md#createEndpoint) | **POST** /accounts/{accountId}/endpoints | Create Endpoint | +| [**deleteEndpoint**](EndpointsApi.md#deleteEndpoint) | **DELETE** /accounts/{accountId}/endpoints/{endpointId} | Delete Endpoint | +| [**getEndpoint**](EndpointsApi.md#getEndpoint) | **GET** /accounts/{accountId}/endpoints/{endpointId} | Get Endpoint | +| [**listEndpoints**](EndpointsApi.md#listEndpoints) | **GET** /accounts/{accountId}/endpoints | List Endpoints | +| [**updateEndpointBxml**](EndpointsApi.md#updateEndpointBxml) | **PUT** /accounts/{accountId}/endpoints/{endpointId}/bxml | Update Endpoint BXML | + + + +# **createEndpoint** +> CreateEndpointResponse createEndpoint(accountId, body) + +Create Endpoint + +Creates a new Endpoint for the specified account. + +### Example +```java +// Import classes: +import com.bandwidth.sdk.ApiClient; +import com.bandwidth.sdk.ApiException; +import com.bandwidth.sdk.Configuration; +import com.bandwidth.sdk.auth.*; +import com.bandwidth.sdk.models.*; +import com.bandwidth.sdk.api.EndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + // Configure HTTP basic authorization: Basic + HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic"); + Basic.setUsername("YOUR USERNAME"); + Basic.setPassword("YOUR PASSWORD"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + EndpointsApi apiInstance = new EndpointsApi(defaultClient); + String accountId = "5500123"; // String | Your Bandwidth Account ID. + CreateWebRtcConnectionRequest body = new CreateWebRtcConnectionRequest(); // CreateWebRtcConnectionRequest | + try { + CreateEndpointResponse result = apiInstance.createEndpoint(accountId, body); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling EndpointsApi#createEndpoint"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **accountId** | **String**| Your Bandwidth Account ID. | | +| **body** | **CreateWebRtcConnectionRequest**| | | + +### Return type + +[**CreateEndpointResponse**](CreateEndpointResponse.md) + +### Authorization + +[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: application/json + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **201** | Created | - | +| **400** | Bad Request | - | +| **401** | Unauthorized | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **405** | Method Not Allowed | - | +| **415** | Unsupported Media Type | - | +| **429** | Too Many Requests | - | +| **500** | Service Unavailable | - | + + +# **deleteEndpoint** +> deleteEndpoint(accountId, endpointId) + +Delete Endpoint + +Deletes the specified endpoint. If the endpoint is actively streaming media, the media stream will be terminated. + +### Example +```java +// Import classes: +import com.bandwidth.sdk.ApiClient; +import com.bandwidth.sdk.ApiException; +import com.bandwidth.sdk.Configuration; +import com.bandwidth.sdk.auth.*; +import com.bandwidth.sdk.models.*; +import com.bandwidth.sdk.api.EndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + // Configure HTTP basic authorization: Basic + HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic"); + Basic.setUsername("YOUR USERNAME"); + Basic.setPassword("YOUR PASSWORD"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + EndpointsApi apiInstance = new EndpointsApi(defaultClient); + String accountId = "5500123"; // String | Your Bandwidth Account ID. + String endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; // String | BRTC Endpoint ID. + try { + apiInstance.deleteEndpoint(accountId, endpointId); + } catch (ApiException e) { + System.err.println("Exception when calling EndpointsApi#deleteEndpoint"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **accountId** | **String**| Your Bandwidth Account ID. | | +| **endpointId** | **String**| BRTC Endpoint ID. | | + +### Return type + +null (empty response body) + +### Authorization + +[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **204** | No Content | - | +| **400** | Bad Request | - | +| **401** | Unauthorized | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **405** | Method Not Allowed | - | +| **415** | Unsupported Media Type | - | +| **429** | Too Many Requests | - | +| **500** | Service Unavailable | - | + + +# **getEndpoint** +> EndpointResponse getEndpoint(accountId, endpointId) + +Get Endpoint + +Returns information about the specified endpoint. + +### Example +```java +// Import classes: +import com.bandwidth.sdk.ApiClient; +import com.bandwidth.sdk.ApiException; +import com.bandwidth.sdk.Configuration; +import com.bandwidth.sdk.auth.*; +import com.bandwidth.sdk.models.*; +import com.bandwidth.sdk.api.EndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + // Configure HTTP basic authorization: Basic + HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic"); + Basic.setUsername("YOUR USERNAME"); + Basic.setPassword("YOUR PASSWORD"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + EndpointsApi apiInstance = new EndpointsApi(defaultClient); + String accountId = "5500123"; // String | Your Bandwidth Account ID. + String endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; // String | BRTC Endpoint ID. + try { + EndpointResponse result = apiInstance.getEndpoint(accountId, endpointId); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling EndpointsApi#getEndpoint"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **accountId** | **String**| Your Bandwidth Account ID. | | +| **endpointId** | **String**| BRTC Endpoint ID. | | + +### Return type + +[**EndpointResponse**](EndpointResponse.md) + +### Authorization + +[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **400** | Bad Request | - | +| **401** | Unauthorized | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **405** | Method Not Allowed | - | +| **415** | Unsupported Media Type | - | +| **429** | Too Many Requests | - | +| **500** | Service Unavailable | - | + + +# **listEndpoints** +> ListEndpointsResponse listEndpoints(accountId, type, status, afterCursor, limit) + +List Endpoints + +Returns a list of endpoints associated with the specified account. + +### Example +```java +// Import classes: +import com.bandwidth.sdk.ApiClient; +import com.bandwidth.sdk.ApiException; +import com.bandwidth.sdk.Configuration; +import com.bandwidth.sdk.auth.*; +import com.bandwidth.sdk.models.*; +import com.bandwidth.sdk.api.EndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + // Configure HTTP basic authorization: Basic + HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic"); + Basic.setUsername("YOUR USERNAME"); + Basic.setPassword("YOUR PASSWORD"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + EndpointsApi apiInstance = new EndpointsApi(defaultClient); + String accountId = "5500123"; // String | Your Bandwidth Account ID. + EndpointTypeEnum type = EndpointTypeEnum.fromValue("WEBRTC"); // EndpointTypeEnum | The type of endpoint. + EndpointStatusEnum status = EndpointStatusEnum.fromValue("CONNECTED"); // EndpointStatusEnum | The status of the endpoint. + String afterCursor = "TWF5IHRoZSBmb3JjZSBiZSB3aXRoIHlvdQ=="; // String | The cursor to use for pagination. This is the value of the `next` link in the previous response. + Integer limit = 100; // Integer | The maximum number of endpoints to return in the response. + try { + ListEndpointsResponse result = apiInstance.listEndpoints(accountId, type, status, afterCursor, limit); + System.out.println(result); + } catch (ApiException e) { + System.err.println("Exception when calling EndpointsApi#listEndpoints"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **accountId** | **String**| Your Bandwidth Account ID. | | +| **type** | [**EndpointTypeEnum**](.md)| The type of endpoint. | [optional] [enum: WEBRTC] | +| **status** | [**EndpointStatusEnum**](.md)| The status of the endpoint. | [optional] [enum: CONNECTED, DISCONNECTED] | +| **afterCursor** | **String**| The cursor to use for pagination. This is the value of the `next` link in the previous response. | [optional] | +| **limit** | **Integer**| The maximum number of endpoints to return in the response. | [optional] [default to 100] | + +### Return type + +[**ListEndpointsResponse**](ListEndpointsResponse.md) + +### Authorization + +[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: Not defined + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **200** | OK | - | +| **400** | Bad Request | - | +| **401** | Unauthorized | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **405** | Method Not Allowed | - | +| **415** | Unsupported Media Type | - | +| **429** | Too Many Requests | - | +| **500** | Service Unavailable | - | + + +# **updateEndpointBxml** +> updateEndpointBxml(accountId, endpointId, body) + +Update Endpoint BXML + +Updates the BXML for the specified endpoint. + +### Example +```java +// Import classes: +import com.bandwidth.sdk.ApiClient; +import com.bandwidth.sdk.ApiException; +import com.bandwidth.sdk.Configuration; +import com.bandwidth.sdk.auth.*; +import com.bandwidth.sdk.models.*; +import com.bandwidth.sdk.api.EndpointsApi; + +public class Example { + public static void main(String[] args) { + ApiClient defaultClient = Configuration.getDefaultApiClient(); + defaultClient.setBasePath("http://localhost"); + + // Configure HTTP basic authorization: Basic + HttpBasicAuth Basic = (HttpBasicAuth) defaultClient.getAuthentication("Basic"); + Basic.setUsername("YOUR USERNAME"); + Basic.setPassword("YOUR PASSWORD"); + + // Configure OAuth2 access token for authorization: OAuth2 + OAuth OAuth2 = (OAuth) defaultClient.getAuthentication("OAuth2"); + OAuth2.setAccessToken("YOUR ACCESS TOKEN"); + + EndpointsApi apiInstance = new EndpointsApi(defaultClient); + String accountId = "5500123"; // String | Your Bandwidth Account ID. + String endpointId = "e-15ac29a2-1331029c-2cb0-4a07-b215-b22865662d85"; // String | BRTC Endpoint ID. + String body = "body_example"; // String | + try { + apiInstance.updateEndpointBxml(accountId, endpointId, body); + } catch (ApiException e) { + System.err.println("Exception when calling EndpointsApi#updateEndpointBxml"); + System.err.println("Status code: " + e.getCode()); + System.err.println("Reason: " + e.getResponseBody()); + System.err.println("Response headers: " + e.getResponseHeaders()); + e.printStackTrace(); + } + } +} +``` + +### Parameters + +| Name | Type | Description | Notes | +|------------- | ------------- | ------------- | -------------| +| **accountId** | **String**| Your Bandwidth Account ID. | | +| **endpointId** | **String**| BRTC Endpoint ID. | | +| **body** | **String**| | | + +### Return type + +null (empty response body) + +### Authorization + +[Basic](../README.md#Basic), [OAuth2](../README.md#OAuth2) + +### HTTP request headers + + - **Content-Type**: application/xml + - **Accept**: application/json + +### HTTP response details +| Status code | Description | Response headers | +|-------------|-------------|------------------| +| **204** | No Content | - | +| **400** | Bad Request | - | +| **401** | Unauthorized | - | +| **403** | Forbidden | - | +| **404** | Not Found | - | +| **405** | Method Not Allowed | - | +| **415** | Unsupported Media Type | - | +| **429** | Too Many Requests | - | +| **500** | Service Unavailable | - | + diff --git a/docs/Error1.md b/docs/Error1.md new file mode 100644 index 00000000..60b9f5a6 --- /dev/null +++ b/docs/Error1.md @@ -0,0 +1,17 @@ + + +# Error1 + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**id** | **UUID** | A unique identifier for the error. | | +|**type** | **String** | The type of error. | | +|**description** | **String** | A description of the error. | | +|**code** | **String** | A code that uniquely identifies the error. | | +|**source** | [**Error1Source**](Error1Source.md) | | [optional] | + + + diff --git a/docs/Error1Source.md b/docs/Error1Source.md new file mode 100644 index 00000000..4665f119 --- /dev/null +++ b/docs/Error1Source.md @@ -0,0 +1,16 @@ + + +# Error1Source + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**parameter** | **String** | The URI parameter that caused the error. | [optional] | +|**field** | **String** | The request body field that caused the error. | [optional] | +|**header** | **String** | The header that caused the error. | [optional] | +|**reference** | **String** | The resource ID or path to the resource (or non-existent resource) causing the error. | [optional] | + + + diff --git a/docs/ErrorResponse.md b/docs/ErrorResponse.md new file mode 100644 index 00000000..fa7cb478 --- /dev/null +++ b/docs/ErrorResponse.md @@ -0,0 +1,15 @@ + + +# ErrorResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**links** | [**List<Link1>**](Link1.md) | | | +|**data** | **Object** | | | +|**errors** | [**List<Error1>**](Error1.md) | | | + + + diff --git a/docs/Link1.md b/docs/Link1.md new file mode 100644 index 00000000..e2023ab1 --- /dev/null +++ b/docs/Link1.md @@ -0,0 +1,25 @@ + + +# Link1 + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**href** | **String** | The full URL of the link. | [optional] | +|**rel** | **String** | The relationship of the link to the current resource. | [optional] | +|**method** | [**MethodEnum**](#MethodEnum) | The HTTP method to use when making the request. | [optional] | + + + +## Enum: MethodEnum + +| Name | Value | +|---- | -----| +| GET | "GET" | +| POST | "POST" | +| DELETE | "DELETE" | + + + diff --git a/docs/ListEndpointsResponse.md b/docs/ListEndpointsResponse.md new file mode 100644 index 00000000..cefcc63e --- /dev/null +++ b/docs/ListEndpointsResponse.md @@ -0,0 +1,16 @@ + + +# ListEndpointsResponse + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**links** | [**List<Link1>**](Link1.md) | | | +|**page** | [**Page**](Page.md) | | [optional] | +|**data** | [**List<Endpoints>**](Endpoints.md) | | | +|**errors** | [**List<Error1>**](Error1.md) | | | + + + diff --git a/docs/Page.md b/docs/Page.md new file mode 100644 index 00000000..f3b73f37 --- /dev/null +++ b/docs/Page.md @@ -0,0 +1,16 @@ + + +# Page + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**pageSize** | **Integer** | The number of items per page. | | +|**totalElements** | **Integer** | The total number of items. | [optional] | +|**totalPages** | **Integer** | The total number of pages. | [optional] | +|**pageNumber** | **Integer** | The current page number. | [optional] | + + + diff --git a/docs/SipConnectionMetadata.md b/docs/SipConnectionMetadata.md new file mode 100644 index 00000000..80eae945 --- /dev/null +++ b/docs/SipConnectionMetadata.md @@ -0,0 +1,16 @@ + + +# SipConnectionMetadata + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**ipAddress** | **String** | The IP address of the SIP connection. | [optional] | +|**port** | **Integer** | The port of the SIP connection. | [optional] | +|**credentials** | [**SipCredentials**](SipCredentials.md) | | [optional] | +|**uuiHeader** | **String** | The User-to-User Information header for the SIP connection. | [optional] | + + + diff --git a/docs/SipCredentials.md b/docs/SipCredentials.md new file mode 100644 index 00000000..6b73c986 --- /dev/null +++ b/docs/SipCredentials.md @@ -0,0 +1,14 @@ + + +# SipCredentials + + +## Properties + +| Name | Type | Description | Notes | +|------------ | ------------- | ------------- | -------------| +|**username** | **String** | The username for the SIP connection. | [optional] | +|**password** | **String** | The password for the SIP connection. | [optional] | + + + diff --git a/src/main/java/com/bandwidth/sdk/JSON.java b/src/main/java/com/bandwidth/sdk/JSON.java index 518e07dd..6d3b3e5c 100644 --- a/src/main/java/com/bandwidth/sdk/JSON.java +++ b/src/main/java/com/bandwidth/sdk/JSON.java @@ -180,15 +180,27 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateAsyncBulkLookupResponseData.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateCall.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateCallResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateEndpointRequestBase.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateEndpointResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateEndpointResponseObject.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateMessageRequestError.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateMultiChannelMessageResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateSyncLookupResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateSyncLookupResponseData.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.CreateWebRtcConnectionRequest.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Device.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.DisconnectCallback.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Diversion.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.DtmfCallback.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Endpoint.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.EndpointEvent.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.EndpointResponse.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Endpoints.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Error.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Error1.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Error1Source.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.ErrorObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.ErrorResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.ErrorSource.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.FailureWebhook.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.FieldError.CustomTypeAdapterFactory()); @@ -199,8 +211,10 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.InboundCallbackMessage.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.InitiateCallback.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Link.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Link1.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.LinkSchema.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.LinksObject.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.ListEndpointsResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.ListMessageItem.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.LookupErrorResponse.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.LookupErrorSchema.CustomTypeAdapterFactory()); @@ -238,6 +252,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelMessageRequest.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.MultiChannelMessageResponseData.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.OptInWorkflow.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.Page.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.PageInfo.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmActionBase.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RbmActionDial.CustomTypeAdapterFactory()); @@ -258,6 +273,8 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RecordingTranscriptionMetadata.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RecordingTranscriptions.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.RedirectCallback.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.SipConnectionMetadata.CustomTypeAdapterFactory()); + gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.SipCredentials.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.SmsMessageContent.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.StatusCallback.CustomTypeAdapterFactory()); gsonBuilder.registerTypeAdapterFactory(new com.bandwidth.sdk.model.StatusCallbackMessage.CustomTypeAdapterFactory()); diff --git a/src/main/java/com/bandwidth/sdk/api/EndpointsApi.java b/src/main/java/com/bandwidth/sdk/api/EndpointsApi.java new file mode 100644 index 00000000..807ba1ce --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/api/EndpointsApi.java @@ -0,0 +1,950 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.api; + +import com.bandwidth.sdk.ApiCallback; +import com.bandwidth.sdk.ApiClient; +import com.bandwidth.sdk.ApiException; +import com.bandwidth.sdk.ApiResponse; +import com.bandwidth.sdk.Configuration; +import com.bandwidth.sdk.Pair; +import com.bandwidth.sdk.ProgressRequestBody; +import com.bandwidth.sdk.ProgressResponseBody; + +import com.google.gson.reflect.TypeToken; + +import java.io.IOException; + + +import com.bandwidth.sdk.model.CreateEndpointResponse; +import com.bandwidth.sdk.model.CreateWebRtcConnectionRequest; +import com.bandwidth.sdk.model.EndpointResponse; +import com.bandwidth.sdk.model.EndpointStatusEnum; +import com.bandwidth.sdk.model.EndpointTypeEnum; +import com.bandwidth.sdk.model.ErrorResponse; +import com.bandwidth.sdk.model.ListEndpointsResponse; + +import java.lang.reflect.Type; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class EndpointsApi { + private ApiClient localVarApiClient; + private int localHostIndex; + private String localCustomBaseUrl; + + public EndpointsApi() { + this(Configuration.getDefaultApiClient()); + } + + public EndpointsApi(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public ApiClient getApiClient() { + return localVarApiClient; + } + + public void setApiClient(ApiClient apiClient) { + this.localVarApiClient = apiClient; + } + + public int getHostIndex() { + return localHostIndex; + } + + public void setHostIndex(int hostIndex) { + this.localHostIndex = hostIndex; + } + + public String getCustomBaseUrl() { + return localCustomBaseUrl; + } + + public void setCustomBaseUrl(String customBaseUrl) { + this.localCustomBaseUrl = customBaseUrl; + } + + /** + * Build call for createEndpoint + * @param accountId Your Bandwidth Account ID. (required) + * @param body (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call createEndpointCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull CreateWebRtcConnectionRequest body, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.bandwidth.com/v2" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/accounts/{accountId}/endpoints" + .replace("{" + "accountId" + "}", localVarApiClient.escapeString(accountId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/json" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "Basic", "OAuth2" }; + return localVarApiClient.buildCall(basePath, localVarPath, "POST", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call createEndpointValidateBeforeCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull CreateWebRtcConnectionRequest body, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException("Missing the required parameter 'accountId' when calling createEndpoint(Async)"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling createEndpoint(Async)"); + } + + return createEndpointCall(accountId, body, _callback); + + } + + /** + * Create Endpoint + * Creates a new Endpoint for the specified account. + * @param accountId Your Bandwidth Account ID. (required) + * @param body (required) + * @return CreateEndpointResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public CreateEndpointResponse createEndpoint(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull CreateWebRtcConnectionRequest body) throws ApiException { + ApiResponse localVarResp = createEndpointWithHttpInfo(accountId, body); + return localVarResp.getData(); + } + + /** + * Create Endpoint + * Creates a new Endpoint for the specified account. + * @param accountId Your Bandwidth Account ID. (required) + * @param body (required) + * @return ApiResponse<CreateEndpointResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public ApiResponse createEndpointWithHttpInfo(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull CreateWebRtcConnectionRequest body) throws ApiException { + okhttp3.Call localVarCall = createEndpointValidateBeforeCall(accountId, body, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Create Endpoint (asynchronously) + * Creates a new Endpoint for the specified account. + * @param accountId Your Bandwidth Account ID. (required) + * @param body (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
201 Created -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call createEndpointAsync(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull CreateWebRtcConnectionRequest body, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = createEndpointValidateBeforeCall(accountId, body, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for deleteEndpoint + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call deleteEndpointCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.bandwidth.com/v2" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/accounts/{accountId}/endpoints/{endpointId}" + .replace("{" + "accountId" + "}", localVarApiClient.escapeString(accountId.toString())) + .replace("{" + "endpointId" + "}", localVarApiClient.escapeString(endpointId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "Basic", "OAuth2" }; + return localVarApiClient.buildCall(basePath, localVarPath, "DELETE", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call deleteEndpointValidateBeforeCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException("Missing the required parameter 'accountId' when calling deleteEndpoint(Async)"); + } + + // verify the required parameter 'endpointId' is set + if (endpointId == null) { + throw new ApiException("Missing the required parameter 'endpointId' when calling deleteEndpoint(Async)"); + } + + return deleteEndpointCall(accountId, endpointId, _callback); + + } + + /** + * Delete Endpoint + * Deletes the specified endpoint. If the endpoint is actively streaming media, the media stream will be terminated. + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public void deleteEndpoint(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId) throws ApiException { + deleteEndpointWithHttpInfo(accountId, endpointId); + } + + /** + * Delete Endpoint + * Deletes the specified endpoint. If the endpoint is actively streaming media, the media stream will be terminated. + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public ApiResponse deleteEndpointWithHttpInfo(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId) throws ApiException { + okhttp3.Call localVarCall = deleteEndpointValidateBeforeCall(accountId, endpointId, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Delete Endpoint (asynchronously) + * Deletes the specified endpoint. If the endpoint is actively streaming media, the media stream will be terminated. + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call deleteEndpointAsync(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = deleteEndpointValidateBeforeCall(accountId, endpointId, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } + /** + * Build call for getEndpoint + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call getEndpointCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.bandwidth.com/v2" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/accounts/{accountId}/endpoints/{endpointId}" + .replace("{" + "accountId" + "}", localVarApiClient.escapeString(accountId.toString())) + .replace("{" + "endpointId" + "}", localVarApiClient.escapeString(endpointId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "Basic", "OAuth2" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call getEndpointValidateBeforeCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException("Missing the required parameter 'accountId' when calling getEndpoint(Async)"); + } + + // verify the required parameter 'endpointId' is set + if (endpointId == null) { + throw new ApiException("Missing the required parameter 'endpointId' when calling getEndpoint(Async)"); + } + + return getEndpointCall(accountId, endpointId, _callback); + + } + + /** + * Get Endpoint + * Returns information about the specified endpoint. + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @return EndpointResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public EndpointResponse getEndpoint(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId) throws ApiException { + ApiResponse localVarResp = getEndpointWithHttpInfo(accountId, endpointId); + return localVarResp.getData(); + } + + /** + * Get Endpoint + * Returns information about the specified endpoint. + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @return ApiResponse<EndpointResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public ApiResponse getEndpointWithHttpInfo(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId) throws ApiException { + okhttp3.Call localVarCall = getEndpointValidateBeforeCall(accountId, endpointId, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * Get Endpoint (asynchronously) + * Returns information about the specified endpoint. + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call getEndpointAsync(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = getEndpointValidateBeforeCall(accountId, endpointId, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for listEndpoints + * @param accountId Your Bandwidth Account ID. (required) + * @param type The type of endpoint. (optional) + * @param status The status of the endpoint. (optional) + * @param afterCursor The cursor to use for pagination. This is the value of the `next` link in the previous response. (optional) + * @param limit The maximum number of endpoints to return in the response. (optional, default to 100) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call listEndpointsCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nullable EndpointTypeEnum type, @javax.annotation.Nullable EndpointStatusEnum status, @javax.annotation.Nullable String afterCursor, @javax.annotation.Nullable Integer limit, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.bandwidth.com/v2" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = null; + + // create path and map variables + String localVarPath = "/accounts/{accountId}/endpoints" + .replace("{" + "accountId" + "}", localVarApiClient.escapeString(accountId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + if (type != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("type", type)); + } + + if (status != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("status", status)); + } + + if (afterCursor != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("afterCursor", afterCursor)); + } + + if (limit != null) { + localVarQueryParams.addAll(localVarApiClient.parameterToPair("limit", limit)); + } + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "Basic", "OAuth2" }; + return localVarApiClient.buildCall(basePath, localVarPath, "GET", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call listEndpointsValidateBeforeCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nullable EndpointTypeEnum type, @javax.annotation.Nullable EndpointStatusEnum status, @javax.annotation.Nullable String afterCursor, @javax.annotation.Nullable Integer limit, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException("Missing the required parameter 'accountId' when calling listEndpoints(Async)"); + } + + return listEndpointsCall(accountId, type, status, afterCursor, limit, _callback); + + } + + /** + * List Endpoints + * Returns a list of endpoints associated with the specified account. + * @param accountId Your Bandwidth Account ID. (required) + * @param type The type of endpoint. (optional) + * @param status The status of the endpoint. (optional) + * @param afterCursor The cursor to use for pagination. This is the value of the `next` link in the previous response. (optional) + * @param limit The maximum number of endpoints to return in the response. (optional, default to 100) + * @return ListEndpointsResponse + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public ListEndpointsResponse listEndpoints(@javax.annotation.Nonnull String accountId, @javax.annotation.Nullable EndpointTypeEnum type, @javax.annotation.Nullable EndpointStatusEnum status, @javax.annotation.Nullable String afterCursor, @javax.annotation.Nullable Integer limit) throws ApiException { + ApiResponse localVarResp = listEndpointsWithHttpInfo(accountId, type, status, afterCursor, limit); + return localVarResp.getData(); + } + + /** + * List Endpoints + * Returns a list of endpoints associated with the specified account. + * @param accountId Your Bandwidth Account ID. (required) + * @param type The type of endpoint. (optional) + * @param status The status of the endpoint. (optional) + * @param afterCursor The cursor to use for pagination. This is the value of the `next` link in the previous response. (optional) + * @param limit The maximum number of endpoints to return in the response. (optional, default to 100) + * @return ApiResponse<ListEndpointsResponse> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public ApiResponse listEndpointsWithHttpInfo(@javax.annotation.Nonnull String accountId, @javax.annotation.Nullable EndpointTypeEnum type, @javax.annotation.Nullable EndpointStatusEnum status, @javax.annotation.Nullable String afterCursor, @javax.annotation.Nullable Integer limit) throws ApiException { + okhttp3.Call localVarCall = listEndpointsValidateBeforeCall(accountId, type, status, afterCursor, limit, null); + Type localVarReturnType = new TypeToken(){}.getType(); + return localVarApiClient.execute(localVarCall, localVarReturnType); + } + + /** + * List Endpoints (asynchronously) + * Returns a list of endpoints associated with the specified account. + * @param accountId Your Bandwidth Account ID. (required) + * @param type The type of endpoint. (optional) + * @param status The status of the endpoint. (optional) + * @param afterCursor The cursor to use for pagination. This is the value of the `next` link in the previous response. (optional) + * @param limit The maximum number of endpoints to return in the response. (optional, default to 100) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
200 OK -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call listEndpointsAsync(@javax.annotation.Nonnull String accountId, @javax.annotation.Nullable EndpointTypeEnum type, @javax.annotation.Nullable EndpointStatusEnum status, @javax.annotation.Nullable String afterCursor, @javax.annotation.Nullable Integer limit, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = listEndpointsValidateBeforeCall(accountId, type, status, afterCursor, limit, _callback); + Type localVarReturnType = new TypeToken(){}.getType(); + localVarApiClient.executeAsync(localVarCall, localVarReturnType, _callback); + return localVarCall; + } + /** + * Build call for updateEndpointBxml + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @param body (required) + * @param _callback Callback for upload/download progress + * @return Call to execute + * @throws ApiException If fail to serialize the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call updateEndpointBxmlCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, @javax.annotation.Nonnull String body, final ApiCallback _callback) throws ApiException { + String basePath = null; + // Operation Servers + String[] localBasePaths = new String[] { "https://api.bandwidth.com/v2" }; + + // Determine Base Path to Use + if (localCustomBaseUrl != null){ + basePath = localCustomBaseUrl; + } else if ( localBasePaths.length > 0 ) { + basePath = localBasePaths[localHostIndex]; + } else { + basePath = null; + } + + Object localVarPostBody = body; + + // create path and map variables + String localVarPath = "/accounts/{accountId}/endpoints/{endpointId}/bxml" + .replace("{" + "accountId" + "}", localVarApiClient.escapeString(accountId.toString())) + .replace("{" + "endpointId" + "}", localVarApiClient.escapeString(endpointId.toString())); + + List localVarQueryParams = new ArrayList(); + List localVarCollectionQueryParams = new ArrayList(); + Map localVarHeaderParams = new HashMap(); + Map localVarCookieParams = new HashMap(); + Map localVarFormParams = new HashMap(); + + final String[] localVarAccepts = { + "application/json" + }; + final String localVarAccept = localVarApiClient.selectHeaderAccept(localVarAccepts); + if (localVarAccept != null) { + localVarHeaderParams.put("Accept", localVarAccept); + } + + final String[] localVarContentTypes = { + "application/xml" + }; + final String localVarContentType = localVarApiClient.selectHeaderContentType(localVarContentTypes); + if (localVarContentType != null) { + localVarHeaderParams.put("Content-Type", localVarContentType); + } + + String[] localVarAuthNames = new String[] { "Basic", "OAuth2" }; + return localVarApiClient.buildCall(basePath, localVarPath, "PUT", localVarQueryParams, localVarCollectionQueryParams, localVarPostBody, localVarHeaderParams, localVarCookieParams, localVarFormParams, localVarAuthNames, _callback); + } + + @SuppressWarnings("rawtypes") + private okhttp3.Call updateEndpointBxmlValidateBeforeCall(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, @javax.annotation.Nonnull String body, final ApiCallback _callback) throws ApiException { + // verify the required parameter 'accountId' is set + if (accountId == null) { + throw new ApiException("Missing the required parameter 'accountId' when calling updateEndpointBxml(Async)"); + } + + // verify the required parameter 'endpointId' is set + if (endpointId == null) { + throw new ApiException("Missing the required parameter 'endpointId' when calling updateEndpointBxml(Async)"); + } + + // verify the required parameter 'body' is set + if (body == null) { + throw new ApiException("Missing the required parameter 'body' when calling updateEndpointBxml(Async)"); + } + + return updateEndpointBxmlCall(accountId, endpointId, body, _callback); + + } + + /** + * Update Endpoint BXML + * Updates the BXML for the specified endpoint. + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @param body (required) + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public void updateEndpointBxml(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, @javax.annotation.Nonnull String body) throws ApiException { + updateEndpointBxmlWithHttpInfo(accountId, endpointId, body); + } + + /** + * Update Endpoint BXML + * Updates the BXML for the specified endpoint. + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @param body (required) + * @return ApiResponse<Void> + * @throws ApiException If fail to call the API, e.g. server error or cannot deserialize the response body + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public ApiResponse updateEndpointBxmlWithHttpInfo(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, @javax.annotation.Nonnull String body) throws ApiException { + okhttp3.Call localVarCall = updateEndpointBxmlValidateBeforeCall(accountId, endpointId, body, null); + return localVarApiClient.execute(localVarCall); + } + + /** + * Update Endpoint BXML (asynchronously) + * Updates the BXML for the specified endpoint. + * @param accountId Your Bandwidth Account ID. (required) + * @param endpointId BRTC Endpoint ID. (required) + * @param body (required) + * @param _callback The callback to be executed when the API call finishes + * @return The request call + * @throws ApiException If fail to process the API call, e.g. serializing the request body object + * @http.response.details + + + + + + + + + + + + +
Response Details
Status Code Description Response Headers
204 No Content -
400 Bad Request -
401 Unauthorized -
403 Forbidden -
404 Not Found -
405 Method Not Allowed -
415 Unsupported Media Type -
429 Too Many Requests -
500 Service Unavailable -
+ */ + public okhttp3.Call updateEndpointBxmlAsync(@javax.annotation.Nonnull String accountId, @javax.annotation.Nonnull String endpointId, @javax.annotation.Nonnull String body, final ApiCallback _callback) throws ApiException { + + okhttp3.Call localVarCall = updateEndpointBxmlValidateBeforeCall(accountId, endpointId, body, _callback); + localVarApiClient.executeAsync(localVarCall, _callback); + return localVarCall; + } +} diff --git a/src/main/java/com/bandwidth/sdk/model/CreateEndpointRequestBase.java b/src/main/java/com/bandwidth/sdk/model/CreateEndpointRequestBase.java new file mode 100644 index 00000000..ad5a33fc --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/CreateEndpointRequestBase.java @@ -0,0 +1,412 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.EndpointDirectionEnum; +import com.bandwidth.sdk.model.EndpointTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * CreateEndpointRequestBase + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class CreateEndpointRequestBase { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private EndpointTypeEnum type; + + public static final String SERIALIZED_NAME_DIRECTION = "direction"; + @SerializedName(SERIALIZED_NAME_DIRECTION) + @javax.annotation.Nonnull + private EndpointDirectionEnum direction; + + public static final String SERIALIZED_NAME_EVENT_CALLBACK_URL = "eventCallbackUrl"; + @SerializedName(SERIALIZED_NAME_EVENT_CALLBACK_URL) + @javax.annotation.Nullable + private URI eventCallbackUrl; + + public static final String SERIALIZED_NAME_EVENT_FALLBACK_URL = "eventFallbackUrl"; + @SerializedName(SERIALIZED_NAME_EVENT_FALLBACK_URL) + @javax.annotation.Nullable + private URI eventFallbackUrl; + + public static final String SERIALIZED_NAME_TAG = "tag"; + @SerializedName(SERIALIZED_NAME_TAG) + @javax.annotation.Nullable + private String tag; + + public CreateEndpointRequestBase() { + } + + public CreateEndpointRequestBase type(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public EndpointTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + } + + + public CreateEndpointRequestBase direction(@javax.annotation.Nonnull EndpointDirectionEnum direction) { + this.direction = direction; + return this; + } + + /** + * Get direction + * @return direction + */ + @javax.annotation.Nonnull + public EndpointDirectionEnum getDirection() { + return direction; + } + + public void setDirection(@javax.annotation.Nonnull EndpointDirectionEnum direction) { + this.direction = direction; + } + + + public CreateEndpointRequestBase eventCallbackUrl(@javax.annotation.Nullable URI eventCallbackUrl) { + this.eventCallbackUrl = eventCallbackUrl; + return this; + } + + /** + * The URL to send event callbacks to. + * @return eventCallbackUrl + */ + @javax.annotation.Nullable + public URI getEventCallbackUrl() { + return eventCallbackUrl; + } + + public void setEventCallbackUrl(@javax.annotation.Nullable URI eventCallbackUrl) { + this.eventCallbackUrl = eventCallbackUrl; + } + + + public CreateEndpointRequestBase eventFallbackUrl(@javax.annotation.Nullable URI eventFallbackUrl) { + this.eventFallbackUrl = eventFallbackUrl; + return this; + } + + /** + * The URL to send event fallbacks to. + * @return eventFallbackUrl + */ + @javax.annotation.Nullable + public URI getEventFallbackUrl() { + return eventFallbackUrl; + } + + public void setEventFallbackUrl(@javax.annotation.Nullable URI eventFallbackUrl) { + this.eventFallbackUrl = eventFallbackUrl; + } + + + public CreateEndpointRequestBase tag(@javax.annotation.Nullable String tag) { + this.tag = tag; + return this; + } + + /** + * A tag for the endpoint. + * @return tag + */ + @javax.annotation.Nullable + public String getTag() { + return tag; + } + + public void setTag(@javax.annotation.Nullable String tag) { + this.tag = tag; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateEndpointRequestBase instance itself + */ + public CreateEndpointRequestBase putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateEndpointRequestBase createEndpointRequestBase = (CreateEndpointRequestBase) o; + return Objects.equals(this.type, createEndpointRequestBase.type) && + Objects.equals(this.direction, createEndpointRequestBase.direction) && + Objects.equals(this.eventCallbackUrl, createEndpointRequestBase.eventCallbackUrl) && + Objects.equals(this.eventFallbackUrl, createEndpointRequestBase.eventFallbackUrl) && + Objects.equals(this.tag, createEndpointRequestBase.tag)&& + Objects.equals(this.additionalProperties, createEndpointRequestBase.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, direction, eventCallbackUrl, eventFallbackUrl, tag, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateEndpointRequestBase {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" direction: ").append(toIndentedString(direction)).append("\n"); + sb.append(" eventCallbackUrl: ").append(toIndentedString(eventCallbackUrl)).append("\n"); + sb.append(" eventFallbackUrl: ").append(toIndentedString(eventFallbackUrl)).append("\n"); + sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("type", "direction", "eventCallbackUrl", "eventFallbackUrl", "tag")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("type", "direction")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateEndpointRequestBase + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateEndpointRequestBase.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreateEndpointRequestBase is not found in the empty JSON string", CreateEndpointRequestBase.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateEndpointRequestBase.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `type` + EndpointTypeEnum.validateJsonElement(jsonObj.get("type")); + // validate the required field `direction` + EndpointDirectionEnum.validateJsonElement(jsonObj.get("direction")); + if ((jsonObj.get("eventCallbackUrl") != null && !jsonObj.get("eventCallbackUrl").isJsonNull()) && !jsonObj.get("eventCallbackUrl").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `eventCallbackUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("eventCallbackUrl").toString())); + } + if ((jsonObj.get("eventFallbackUrl") != null && !jsonObj.get("eventFallbackUrl").isJsonNull()) && !jsonObj.get("eventFallbackUrl").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `eventFallbackUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("eventFallbackUrl").toString())); + } + if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateEndpointRequestBase.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateEndpointRequestBase' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateEndpointRequestBase.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateEndpointRequestBase value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateEndpointRequestBase read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateEndpointRequestBase instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateEndpointRequestBase given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateEndpointRequestBase + * @throws IOException if the JSON string is invalid with respect to CreateEndpointRequestBase + */ + public static CreateEndpointRequestBase fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateEndpointRequestBase.class); + } + + /** + * Convert an instance of CreateEndpointRequestBase to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/CreateEndpointResponse.java b/src/main/java/com/bandwidth/sdk/model/CreateEndpointResponse.java new file mode 100644 index 00000000..611afcb9 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/CreateEndpointResponse.java @@ -0,0 +1,387 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.CreateEndpointResponseObject; +import com.bandwidth.sdk.model.Error1; +import com.bandwidth.sdk.model.Link1; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * CreateEndpointResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class CreateEndpointResponse { + public static final String SERIALIZED_NAME_LINKS = "links"; + @SerializedName(SERIALIZED_NAME_LINKS) + @javax.annotation.Nonnull + private List links = new ArrayList<>(); + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private CreateEndpointResponseObject data; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nonnull + private List errors = new ArrayList<>(); + + public CreateEndpointResponse() { + } + + public CreateEndpointResponse links(@javax.annotation.Nonnull List links) { + this.links = links; + return this; + } + + public CreateEndpointResponse addLinksItem(Link1 linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * @return links + */ + @javax.annotation.Nonnull + public List getLinks() { + return links; + } + + public void setLinks(@javax.annotation.Nonnull List links) { + this.links = links; + } + + + public CreateEndpointResponse data(@javax.annotation.Nonnull CreateEndpointResponseObject data) { + this.data = data; + return this; + } + + /** + * Get data + * @return data + */ + @javax.annotation.Nonnull + public CreateEndpointResponseObject getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull CreateEndpointResponseObject data) { + this.data = data; + } + + + public CreateEndpointResponse errors(@javax.annotation.Nonnull List errors) { + this.errors = errors; + return this; + } + + public CreateEndpointResponse addErrorsItem(Error1 errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + */ + @javax.annotation.Nonnull + public List getErrors() { + return errors; + } + + public void setErrors(@javax.annotation.Nonnull List errors) { + this.errors = errors; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateEndpointResponse instance itself + */ + public CreateEndpointResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateEndpointResponse createEndpointResponse = (CreateEndpointResponse) o; + return Objects.equals(this.links, createEndpointResponse.links) && + Objects.equals(this.data, createEndpointResponse.data) && + Objects.equals(this.errors, createEndpointResponse.errors)&& + Objects.equals(this.additionalProperties, createEndpointResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(links, data, errors, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateEndpointResponse {\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("links", "data", "errors")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("links", "data", "errors")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateEndpointResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateEndpointResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreateEndpointResponse is not found in the empty JSON string", CreateEndpointResponse.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateEndpointResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the json data is an array + if (!jsonObj.get("links").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `links` to be an array in the JSON string but got `%s`", jsonObj.get("links").toString())); + } + + JsonArray jsonArraylinks = jsonObj.getAsJsonArray("links"); + // validate the required field `links` (array) + for (int i = 0; i < jsonArraylinks.size(); i++) { + Link1.validateJsonElement(jsonArraylinks.get(i)); + }; + // validate the required field `data` + CreateEndpointResponseObject.validateJsonElement(jsonObj.get("data")); + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + // validate the required field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + Error1.validateJsonElement(jsonArrayerrors.get(i)); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateEndpointResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateEndpointResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateEndpointResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateEndpointResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateEndpointResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateEndpointResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateEndpointResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateEndpointResponse + * @throws IOException if the JSON string is invalid with respect to CreateEndpointResponse + */ + public static CreateEndpointResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateEndpointResponse.class); + } + + /** + * Convert an instance of CreateEndpointResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/CreateEndpointResponseObject.java b/src/main/java/com/bandwidth/sdk/model/CreateEndpointResponseObject.java new file mode 100644 index 00000000..e951cbac --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/CreateEndpointResponseObject.java @@ -0,0 +1,515 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.Device; +import com.bandwidth.sdk.model.EndpointStatusEnum; +import com.bandwidth.sdk.model.EndpointTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * CreateEndpointResponseObject + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class CreateEndpointResponseObject { + public static final String SERIALIZED_NAME_ENDPOINT_ID = "endpointId"; + @SerializedName(SERIALIZED_NAME_ENDPOINT_ID) + @javax.annotation.Nonnull + private String endpointId; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private EndpointTypeEnum type; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private EndpointStatusEnum status; + + public static final String SERIALIZED_NAME_CREATION_TIMESTAMP = "creationTimestamp"; + @SerializedName(SERIALIZED_NAME_CREATION_TIMESTAMP) + @javax.annotation.Nonnull + private OffsetDateTime creationTimestamp; + + public static final String SERIALIZED_NAME_EXPIRATION_TIMESTAMP = "expirationTimestamp"; + @SerializedName(SERIALIZED_NAME_EXPIRATION_TIMESTAMP) + @javax.annotation.Nonnull + private OffsetDateTime expirationTimestamp; + + public static final String SERIALIZED_NAME_TAG = "tag"; + @SerializedName(SERIALIZED_NAME_TAG) + @javax.annotation.Nullable + private String tag; + + public static final String SERIALIZED_NAME_DEVICES = "devices"; + @SerializedName(SERIALIZED_NAME_DEVICES) + @javax.annotation.Nullable + private List devices = new ArrayList<>(); + + public static final String SERIALIZED_NAME_TOKEN = "token"; + @SerializedName(SERIALIZED_NAME_TOKEN) + @javax.annotation.Nonnull + private String token; + + public CreateEndpointResponseObject() { + } + + public CreateEndpointResponseObject endpointId(@javax.annotation.Nonnull String endpointId) { + this.endpointId = endpointId; + return this; + } + + /** + * The unique ID of the endpoint. + * @return endpointId + */ + @javax.annotation.Nonnull + public String getEndpointId() { + return endpointId; + } + + public void setEndpointId(@javax.annotation.Nonnull String endpointId) { + this.endpointId = endpointId; + } + + + public CreateEndpointResponseObject type(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public EndpointTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + } + + + public CreateEndpointResponseObject status(@javax.annotation.Nonnull EndpointStatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + */ + @javax.annotation.Nonnull + public EndpointStatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull EndpointStatusEnum status) { + this.status = status; + } + + + public CreateEndpointResponseObject creationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + return this; + } + + /** + * The time the endpoint was created. In ISO-8601 format. + * @return creationTimestamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + + public CreateEndpointResponseObject expirationTimestamp(@javax.annotation.Nonnull OffsetDateTime expirationTimestamp) { + this.expirationTimestamp = expirationTimestamp; + return this; + } + + /** + * The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours. + * @return expirationTimestamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getExpirationTimestamp() { + return expirationTimestamp; + } + + public void setExpirationTimestamp(@javax.annotation.Nonnull OffsetDateTime expirationTimestamp) { + this.expirationTimestamp = expirationTimestamp; + } + + + public CreateEndpointResponseObject tag(@javax.annotation.Nullable String tag) { + this.tag = tag; + return this; + } + + /** + * A tag for the endpoint. + * @return tag + */ + @javax.annotation.Nullable + public String getTag() { + return tag; + } + + public void setTag(@javax.annotation.Nullable String tag) { + this.tag = tag; + } + + + public CreateEndpointResponseObject devices(@javax.annotation.Nullable List devices) { + this.devices = devices; + return this; + } + + public CreateEndpointResponseObject addDevicesItem(Device devicesItem) { + if (this.devices == null) { + this.devices = new ArrayList<>(); + } + this.devices.add(devicesItem); + return this; + } + + /** + * Get devices + * @return devices + */ + @javax.annotation.Nullable + public List getDevices() { + return devices; + } + + public void setDevices(@javax.annotation.Nullable List devices) { + this.devices = devices; + } + + + public CreateEndpointResponseObject token(@javax.annotation.Nonnull String token) { + this.token = token; + return this; + } + + /** + * The json web token specific to the endpoint. Used to authenticate the client with the media gateway. + * @return token + */ + @javax.annotation.Nonnull + public String getToken() { + return token; + } + + public void setToken(@javax.annotation.Nonnull String token) { + this.token = token; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateEndpointResponseObject instance itself + */ + public CreateEndpointResponseObject putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateEndpointResponseObject createEndpointResponseObject = (CreateEndpointResponseObject) o; + return Objects.equals(this.endpointId, createEndpointResponseObject.endpointId) && + Objects.equals(this.type, createEndpointResponseObject.type) && + Objects.equals(this.status, createEndpointResponseObject.status) && + Objects.equals(this.creationTimestamp, createEndpointResponseObject.creationTimestamp) && + Objects.equals(this.expirationTimestamp, createEndpointResponseObject.expirationTimestamp) && + Objects.equals(this.tag, createEndpointResponseObject.tag) && + Objects.equals(this.devices, createEndpointResponseObject.devices) && + Objects.equals(this.token, createEndpointResponseObject.token)&& + Objects.equals(this.additionalProperties, createEndpointResponseObject.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(endpointId, type, status, creationTimestamp, expirationTimestamp, tag, devices, token, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateEndpointResponseObject {\n"); + sb.append(" endpointId: ").append(toIndentedString(endpointId)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" creationTimestamp: ").append(toIndentedString(creationTimestamp)).append("\n"); + sb.append(" expirationTimestamp: ").append(toIndentedString(expirationTimestamp)).append("\n"); + sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" devices: ").append(toIndentedString(devices)).append("\n"); + sb.append(" token: ").append(toIndentedString(token)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("endpointId", "type", "status", "creationTimestamp", "expirationTimestamp", "tag", "devices", "token")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("endpointId", "type", "status", "creationTimestamp", "expirationTimestamp", "token")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateEndpointResponseObject + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateEndpointResponseObject.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreateEndpointResponseObject is not found in the empty JSON string", CreateEndpointResponseObject.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateEndpointResponseObject.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("endpointId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `endpointId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("endpointId").toString())); + } + // validate the required field `type` + EndpointTypeEnum.validateJsonElement(jsonObj.get("type")); + // validate the required field `status` + EndpointStatusEnum.validateJsonElement(jsonObj.get("status")); + if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + } + if (jsonObj.get("devices") != null && !jsonObj.get("devices").isJsonNull()) { + JsonArray jsonArraydevices = jsonObj.getAsJsonArray("devices"); + if (jsonArraydevices != null) { + // ensure the json data is an array + if (!jsonObj.get("devices").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `devices` to be an array in the JSON string but got `%s`", jsonObj.get("devices").toString())); + } + + // validate the optional field `devices` (array) + for (int i = 0; i < jsonArraydevices.size(); i++) { + Device.validateJsonElement(jsonArraydevices.get(i)); + }; + } + } + if (!jsonObj.get("token").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `token` to be a primitive type in the JSON string but got `%s`", jsonObj.get("token").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateEndpointResponseObject.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateEndpointResponseObject' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateEndpointResponseObject.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateEndpointResponseObject value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateEndpointResponseObject read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateEndpointResponseObject instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateEndpointResponseObject given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateEndpointResponseObject + * @throws IOException if the JSON string is invalid with respect to CreateEndpointResponseObject + */ + public static CreateEndpointResponseObject fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateEndpointResponseObject.class); + } + + /** + * Convert an instance of CreateEndpointResponseObject to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/CreateWebRtcConnectionRequest.java b/src/main/java/com/bandwidth/sdk/model/CreateWebRtcConnectionRequest.java new file mode 100644 index 00000000..bef608e2 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/CreateWebRtcConnectionRequest.java @@ -0,0 +1,438 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.EndpointDirectionEnum; +import com.bandwidth.sdk.model.EndpointTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.net.URI; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * CreateWebRtcConnectionRequest + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class CreateWebRtcConnectionRequest { + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private EndpointTypeEnum type; + + public static final String SERIALIZED_NAME_DIRECTION = "direction"; + @SerializedName(SERIALIZED_NAME_DIRECTION) + @javax.annotation.Nonnull + private EndpointDirectionEnum direction; + + public static final String SERIALIZED_NAME_EVENT_CALLBACK_URL = "eventCallbackUrl"; + @SerializedName(SERIALIZED_NAME_EVENT_CALLBACK_URL) + @javax.annotation.Nullable + private URI eventCallbackUrl; + + public static final String SERIALIZED_NAME_EVENT_FALLBACK_URL = "eventFallbackUrl"; + @SerializedName(SERIALIZED_NAME_EVENT_FALLBACK_URL) + @javax.annotation.Nullable + private URI eventFallbackUrl; + + public static final String SERIALIZED_NAME_TAG = "tag"; + @SerializedName(SERIALIZED_NAME_TAG) + @javax.annotation.Nullable + private String tag; + + public static final String SERIALIZED_NAME_CONNECTION_METADATA = "connectionMetadata"; + @SerializedName(SERIALIZED_NAME_CONNECTION_METADATA) + @javax.annotation.Nullable + private Object connectionMetadata; + + public CreateWebRtcConnectionRequest() { + } + + public CreateWebRtcConnectionRequest type(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public EndpointTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + } + + + public CreateWebRtcConnectionRequest direction(@javax.annotation.Nonnull EndpointDirectionEnum direction) { + this.direction = direction; + return this; + } + + /** + * Get direction + * @return direction + */ + @javax.annotation.Nonnull + public EndpointDirectionEnum getDirection() { + return direction; + } + + public void setDirection(@javax.annotation.Nonnull EndpointDirectionEnum direction) { + this.direction = direction; + } + + + public CreateWebRtcConnectionRequest eventCallbackUrl(@javax.annotation.Nullable URI eventCallbackUrl) { + this.eventCallbackUrl = eventCallbackUrl; + return this; + } + + /** + * The URL to send event callbacks to. + * @return eventCallbackUrl + */ + @javax.annotation.Nullable + public URI getEventCallbackUrl() { + return eventCallbackUrl; + } + + public void setEventCallbackUrl(@javax.annotation.Nullable URI eventCallbackUrl) { + this.eventCallbackUrl = eventCallbackUrl; + } + + + public CreateWebRtcConnectionRequest eventFallbackUrl(@javax.annotation.Nullable URI eventFallbackUrl) { + this.eventFallbackUrl = eventFallbackUrl; + return this; + } + + /** + * The URL to send event fallbacks to. + * @return eventFallbackUrl + */ + @javax.annotation.Nullable + public URI getEventFallbackUrl() { + return eventFallbackUrl; + } + + public void setEventFallbackUrl(@javax.annotation.Nullable URI eventFallbackUrl) { + this.eventFallbackUrl = eventFallbackUrl; + } + + + public CreateWebRtcConnectionRequest tag(@javax.annotation.Nullable String tag) { + this.tag = tag; + return this; + } + + /** + * A tag for the endpoint. + * @return tag + */ + @javax.annotation.Nullable + public String getTag() { + return tag; + } + + public void setTag(@javax.annotation.Nullable String tag) { + this.tag = tag; + } + + + public CreateWebRtcConnectionRequest connectionMetadata(@javax.annotation.Nullable Object connectionMetadata) { + this.connectionMetadata = connectionMetadata; + return this; + } + + /** + * Get connectionMetadata + * @return connectionMetadata + */ + @javax.annotation.Nullable + public Object getConnectionMetadata() { + return connectionMetadata; + } + + public void setConnectionMetadata(@javax.annotation.Nullable Object connectionMetadata) { + this.connectionMetadata = connectionMetadata; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the CreateWebRtcConnectionRequest instance itself + */ + public CreateWebRtcConnectionRequest putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + CreateWebRtcConnectionRequest createWebRtcConnectionRequest = (CreateWebRtcConnectionRequest) o; + return Objects.equals(this.type, createWebRtcConnectionRequest.type) && + Objects.equals(this.direction, createWebRtcConnectionRequest.direction) && + Objects.equals(this.eventCallbackUrl, createWebRtcConnectionRequest.eventCallbackUrl) && + Objects.equals(this.eventFallbackUrl, createWebRtcConnectionRequest.eventFallbackUrl) && + Objects.equals(this.tag, createWebRtcConnectionRequest.tag) && + Objects.equals(this.connectionMetadata, createWebRtcConnectionRequest.connectionMetadata)&& + Objects.equals(this.additionalProperties, createWebRtcConnectionRequest.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(type, direction, eventCallbackUrl, eventFallbackUrl, tag, connectionMetadata, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class CreateWebRtcConnectionRequest {\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" direction: ").append(toIndentedString(direction)).append("\n"); + sb.append(" eventCallbackUrl: ").append(toIndentedString(eventCallbackUrl)).append("\n"); + sb.append(" eventFallbackUrl: ").append(toIndentedString(eventFallbackUrl)).append("\n"); + sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" connectionMetadata: ").append(toIndentedString(connectionMetadata)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("type", "direction", "eventCallbackUrl", "eventFallbackUrl", "tag", "connectionMetadata")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("type", "direction")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to CreateWebRtcConnectionRequest + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!CreateWebRtcConnectionRequest.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in CreateWebRtcConnectionRequest is not found in the empty JSON string", CreateWebRtcConnectionRequest.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : CreateWebRtcConnectionRequest.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // validate the required field `type` + EndpointTypeEnum.validateJsonElement(jsonObj.get("type")); + // validate the required field `direction` + EndpointDirectionEnum.validateJsonElement(jsonObj.get("direction")); + if ((jsonObj.get("eventCallbackUrl") != null && !jsonObj.get("eventCallbackUrl").isJsonNull()) && !jsonObj.get("eventCallbackUrl").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `eventCallbackUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("eventCallbackUrl").toString())); + } + if ((jsonObj.get("eventFallbackUrl") != null && !jsonObj.get("eventFallbackUrl").isJsonNull()) && !jsonObj.get("eventFallbackUrl").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `eventFallbackUrl` to be a primitive type in the JSON string but got `%s`", jsonObj.get("eventFallbackUrl").toString())); + } + if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!CreateWebRtcConnectionRequest.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'CreateWebRtcConnectionRequest' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(CreateWebRtcConnectionRequest.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, CreateWebRtcConnectionRequest value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public CreateWebRtcConnectionRequest read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + CreateWebRtcConnectionRequest instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of CreateWebRtcConnectionRequest given an JSON string + * + * @param jsonString JSON string + * @return An instance of CreateWebRtcConnectionRequest + * @throws IOException if the JSON string is invalid with respect to CreateWebRtcConnectionRequest + */ + public static CreateWebRtcConnectionRequest fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, CreateWebRtcConnectionRequest.class); + } + + /** + * Convert an instance of CreateWebRtcConnectionRequest to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/Device.java b/src/main/java/com/bandwidth/sdk/model/Device.java new file mode 100644 index 00000000..3b1e46b3 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/Device.java @@ -0,0 +1,380 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.DeviceStatusEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * Device + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class Device { + public static final String SERIALIZED_NAME_DEVICE_ID = "deviceId"; + @SerializedName(SERIALIZED_NAME_DEVICE_ID) + @javax.annotation.Nonnull + private String deviceId; + + public static final String SERIALIZED_NAME_DEVICE_NAME = "deviceName"; + @SerializedName(SERIALIZED_NAME_DEVICE_NAME) + @javax.annotation.Nullable + private String deviceName; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private DeviceStatusEnum status; + + public static final String SERIALIZED_NAME_CREATION_TIMESTAMP = "creationTimestamp"; + @SerializedName(SERIALIZED_NAME_CREATION_TIMESTAMP) + @javax.annotation.Nonnull + private OffsetDateTime creationTimestamp; + + public Device() { + } + + public Device deviceId(@javax.annotation.Nonnull String deviceId) { + this.deviceId = deviceId; + return this; + } + + /** + * The unique ID of the device. + * @return deviceId + */ + @javax.annotation.Nonnull + public String getDeviceId() { + return deviceId; + } + + public void setDeviceId(@javax.annotation.Nonnull String deviceId) { + this.deviceId = deviceId; + } + + + public Device deviceName(@javax.annotation.Nullable String deviceName) { + this.deviceName = deviceName; + return this; + } + + /** + * The name of the device. + * @return deviceName + */ + @javax.annotation.Nullable + public String getDeviceName() { + return deviceName; + } + + public void setDeviceName(@javax.annotation.Nullable String deviceName) { + this.deviceName = deviceName; + } + + + public Device status(@javax.annotation.Nonnull DeviceStatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + */ + @javax.annotation.Nonnull + public DeviceStatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull DeviceStatusEnum status) { + this.status = status; + } + + + public Device creationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + return this; + } + + /** + * The time the device was created. In ISO-8601 format. + * @return creationTimestamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Device instance itself + */ + public Device putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Device device = (Device) o; + return Objects.equals(this.deviceId, device.deviceId) && + Objects.equals(this.deviceName, device.deviceName) && + Objects.equals(this.status, device.status) && + Objects.equals(this.creationTimestamp, device.creationTimestamp)&& + Objects.equals(this.additionalProperties, device.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(deviceId, deviceName, status, creationTimestamp, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Device {\n"); + sb.append(" deviceId: ").append(toIndentedString(deviceId)).append("\n"); + sb.append(" deviceName: ").append(toIndentedString(deviceName)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" creationTimestamp: ").append(toIndentedString(creationTimestamp)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("deviceId", "deviceName", "status", "creationTimestamp")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("deviceId", "status", "creationTimestamp")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Device + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Device.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Device is not found in the empty JSON string", Device.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Device.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("deviceId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `deviceId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("deviceId").toString())); + } + if ((jsonObj.get("deviceName") != null && !jsonObj.get("deviceName").isJsonNull()) && !jsonObj.get("deviceName").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `deviceName` to be a primitive type in the JSON string but got `%s`", jsonObj.get("deviceName").toString())); + } + // validate the required field `status` + DeviceStatusEnum.validateJsonElement(jsonObj.get("status")); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Device.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Device' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Device.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Device value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Device read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Device instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Device given an JSON string + * + * @param jsonString JSON string + * @return An instance of Device + * @throws IOException if the JSON string is invalid with respect to Device + */ + public static Device fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Device.class); + } + + /** + * Convert an instance of Device to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/DeviceStatusEnum.java b/src/main/java/com/bandwidth/sdk/model/DeviceStatusEnum.java new file mode 100644 index 00000000..8fc6fbca --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/DeviceStatusEnum.java @@ -0,0 +1,80 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets deviceStatusEnum + */ +@JsonAdapter(DeviceStatusEnum.Adapter.class) +public enum DeviceStatusEnum { + + CONNECTED("CONNECTED"), + + DISCONNECTED("DISCONNECTED"); + + private String value; + + DeviceStatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static DeviceStatusEnum fromValue(String value) { + for (DeviceStatusEnum b : DeviceStatusEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final DeviceStatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public DeviceStatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return DeviceStatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + DeviceStatusEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/Endpoint.java b/src/main/java/com/bandwidth/sdk/model/Endpoint.java new file mode 100644 index 00000000..1a6e1157 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/Endpoint.java @@ -0,0 +1,486 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.Device; +import com.bandwidth.sdk.model.EndpointStatusEnum; +import com.bandwidth.sdk.model.EndpointTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * Endpoint + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class Endpoint { + public static final String SERIALIZED_NAME_ENDPOINT_ID = "endpointId"; + @SerializedName(SERIALIZED_NAME_ENDPOINT_ID) + @javax.annotation.Nonnull + private String endpointId; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private EndpointTypeEnum type; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private EndpointStatusEnum status; + + public static final String SERIALIZED_NAME_CREATION_TIMESTAMP = "creationTimestamp"; + @SerializedName(SERIALIZED_NAME_CREATION_TIMESTAMP) + @javax.annotation.Nonnull + private OffsetDateTime creationTimestamp; + + public static final String SERIALIZED_NAME_EXPIRATION_TIMESTAMP = "expirationTimestamp"; + @SerializedName(SERIALIZED_NAME_EXPIRATION_TIMESTAMP) + @javax.annotation.Nonnull + private OffsetDateTime expirationTimestamp; + + public static final String SERIALIZED_NAME_TAG = "tag"; + @SerializedName(SERIALIZED_NAME_TAG) + @javax.annotation.Nullable + private String tag; + + public static final String SERIALIZED_NAME_DEVICES = "devices"; + @SerializedName(SERIALIZED_NAME_DEVICES) + @javax.annotation.Nullable + private List devices = new ArrayList<>(); + + public Endpoint() { + } + + public Endpoint endpointId(@javax.annotation.Nonnull String endpointId) { + this.endpointId = endpointId; + return this; + } + + /** + * The unique ID of the endpoint. + * @return endpointId + */ + @javax.annotation.Nonnull + public String getEndpointId() { + return endpointId; + } + + public void setEndpointId(@javax.annotation.Nonnull String endpointId) { + this.endpointId = endpointId; + } + + + public Endpoint type(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public EndpointTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + } + + + public Endpoint status(@javax.annotation.Nonnull EndpointStatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + */ + @javax.annotation.Nonnull + public EndpointStatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull EndpointStatusEnum status) { + this.status = status; + } + + + public Endpoint creationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + return this; + } + + /** + * The time the endpoint was created. In ISO-8601 format. + * @return creationTimestamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + + public Endpoint expirationTimestamp(@javax.annotation.Nonnull OffsetDateTime expirationTimestamp) { + this.expirationTimestamp = expirationTimestamp; + return this; + } + + /** + * The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours. + * @return expirationTimestamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getExpirationTimestamp() { + return expirationTimestamp; + } + + public void setExpirationTimestamp(@javax.annotation.Nonnull OffsetDateTime expirationTimestamp) { + this.expirationTimestamp = expirationTimestamp; + } + + + public Endpoint tag(@javax.annotation.Nullable String tag) { + this.tag = tag; + return this; + } + + /** + * A tag for the endpoint. + * @return tag + */ + @javax.annotation.Nullable + public String getTag() { + return tag; + } + + public void setTag(@javax.annotation.Nullable String tag) { + this.tag = tag; + } + + + public Endpoint devices(@javax.annotation.Nullable List devices) { + this.devices = devices; + return this; + } + + public Endpoint addDevicesItem(Device devicesItem) { + if (this.devices == null) { + this.devices = new ArrayList<>(); + } + this.devices.add(devicesItem); + return this; + } + + /** + * Get devices + * @return devices + */ + @javax.annotation.Nullable + public List getDevices() { + return devices; + } + + public void setDevices(@javax.annotation.Nullable List devices) { + this.devices = devices; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Endpoint instance itself + */ + public Endpoint putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Endpoint endpoint = (Endpoint) o; + return Objects.equals(this.endpointId, endpoint.endpointId) && + Objects.equals(this.type, endpoint.type) && + Objects.equals(this.status, endpoint.status) && + Objects.equals(this.creationTimestamp, endpoint.creationTimestamp) && + Objects.equals(this.expirationTimestamp, endpoint.expirationTimestamp) && + Objects.equals(this.tag, endpoint.tag) && + Objects.equals(this.devices, endpoint.devices)&& + Objects.equals(this.additionalProperties, endpoint.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(endpointId, type, status, creationTimestamp, expirationTimestamp, tag, devices, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Endpoint {\n"); + sb.append(" endpointId: ").append(toIndentedString(endpointId)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" creationTimestamp: ").append(toIndentedString(creationTimestamp)).append("\n"); + sb.append(" expirationTimestamp: ").append(toIndentedString(expirationTimestamp)).append("\n"); + sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" devices: ").append(toIndentedString(devices)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("endpointId", "type", "status", "creationTimestamp", "expirationTimestamp", "tag", "devices")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("endpointId", "type", "status", "creationTimestamp", "expirationTimestamp")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Endpoint + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Endpoint.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Endpoint is not found in the empty JSON string", Endpoint.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Endpoint.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("endpointId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `endpointId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("endpointId").toString())); + } + // validate the required field `type` + EndpointTypeEnum.validateJsonElement(jsonObj.get("type")); + // validate the required field `status` + EndpointStatusEnum.validateJsonElement(jsonObj.get("status")); + if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + } + if (jsonObj.get("devices") != null && !jsonObj.get("devices").isJsonNull()) { + JsonArray jsonArraydevices = jsonObj.getAsJsonArray("devices"); + if (jsonArraydevices != null) { + // ensure the json data is an array + if (!jsonObj.get("devices").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `devices` to be an array in the JSON string but got `%s`", jsonObj.get("devices").toString())); + } + + // validate the optional field `devices` (array) + for (int i = 0; i < jsonArraydevices.size(); i++) { + Device.validateJsonElement(jsonArraydevices.get(i)); + }; + } + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Endpoint.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Endpoint' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Endpoint.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Endpoint value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Endpoint read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Endpoint instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Endpoint given an JSON string + * + * @param jsonString JSON string + * @return An instance of Endpoint + * @throws IOException if the JSON string is invalid with respect to Endpoint + */ + public static Endpoint fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Endpoint.class); + } + + /** + * Convert an instance of Endpoint to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/EndpointDirectionEnum.java b/src/main/java/com/bandwidth/sdk/model/EndpointDirectionEnum.java new file mode 100644 index 00000000..f888df29 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/EndpointDirectionEnum.java @@ -0,0 +1,82 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets endpointDirectionEnum + */ +@JsonAdapter(EndpointDirectionEnum.Adapter.class) +public enum EndpointDirectionEnum { + + INBOUND("INBOUND"), + + OUTBOUND("OUTBOUND"), + + BIDIRECTIONAL("BIDIRECTIONAL"); + + private String value; + + EndpointDirectionEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EndpointDirectionEnum fromValue(String value) { + for (EndpointDirectionEnum b : EndpointDirectionEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EndpointDirectionEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EndpointDirectionEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EndpointDirectionEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EndpointDirectionEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/EndpointEvent.java b/src/main/java/com/bandwidth/sdk/model/EndpointEvent.java new file mode 100644 index 00000000..3b3a8b25 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/EndpointEvent.java @@ -0,0 +1,521 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.Device; +import com.bandwidth.sdk.model.EndpointEventTypeEnum; +import com.bandwidth.sdk.model.EndpointStatusEnum; +import com.bandwidth.sdk.model.EndpointTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * An event that occurred on an endpoint. + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class EndpointEvent { + public static final String SERIALIZED_NAME_ENDPOINT_ID = "endpointId"; + @SerializedName(SERIALIZED_NAME_ENDPOINT_ID) + @javax.annotation.Nonnull + private String endpointId; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private EndpointTypeEnum type; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private EndpointStatusEnum status; + + public static final String SERIALIZED_NAME_CREATION_TIMESTAMP = "creationTimestamp"; + @SerializedName(SERIALIZED_NAME_CREATION_TIMESTAMP) + @javax.annotation.Nonnull + private OffsetDateTime creationTimestamp; + + public static final String SERIALIZED_NAME_EXPIRATION_TIMESTAMP = "expirationTimestamp"; + @SerializedName(SERIALIZED_NAME_EXPIRATION_TIMESTAMP) + @javax.annotation.Nonnull + private OffsetDateTime expirationTimestamp; + + public static final String SERIALIZED_NAME_TAG = "tag"; + @SerializedName(SERIALIZED_NAME_TAG) + @javax.annotation.Nullable + private String tag; + + public static final String SERIALIZED_NAME_EVENT_TIME = "eventTime"; + @SerializedName(SERIALIZED_NAME_EVENT_TIME) + @javax.annotation.Nonnull + private OffsetDateTime eventTime; + + public static final String SERIALIZED_NAME_EVENT_TYPE = "eventType"; + @SerializedName(SERIALIZED_NAME_EVENT_TYPE) + @javax.annotation.Nonnull + private EndpointEventTypeEnum eventType; + + public static final String SERIALIZED_NAME_DEVICE = "device"; + @SerializedName(SERIALIZED_NAME_DEVICE) + @javax.annotation.Nullable + private Device device; + + public EndpointEvent() { + } + + public EndpointEvent endpointId(@javax.annotation.Nonnull String endpointId) { + this.endpointId = endpointId; + return this; + } + + /** + * The unique ID of the endpoint. + * @return endpointId + */ + @javax.annotation.Nonnull + public String getEndpointId() { + return endpointId; + } + + public void setEndpointId(@javax.annotation.Nonnull String endpointId) { + this.endpointId = endpointId; + } + + + public EndpointEvent type(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public EndpointTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + } + + + public EndpointEvent status(@javax.annotation.Nonnull EndpointStatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + */ + @javax.annotation.Nonnull + public EndpointStatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull EndpointStatusEnum status) { + this.status = status; + } + + + public EndpointEvent creationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + return this; + } + + /** + * The time the endpoint was created. In ISO-8601 format. + * @return creationTimestamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + + public EndpointEvent expirationTimestamp(@javax.annotation.Nonnull OffsetDateTime expirationTimestamp) { + this.expirationTimestamp = expirationTimestamp; + return this; + } + + /** + * The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours. + * @return expirationTimestamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getExpirationTimestamp() { + return expirationTimestamp; + } + + public void setExpirationTimestamp(@javax.annotation.Nonnull OffsetDateTime expirationTimestamp) { + this.expirationTimestamp = expirationTimestamp; + } + + + public EndpointEvent tag(@javax.annotation.Nullable String tag) { + this.tag = tag; + return this; + } + + /** + * A tag for the endpoint. + * @return tag + */ + @javax.annotation.Nullable + public String getTag() { + return tag; + } + + public void setTag(@javax.annotation.Nullable String tag) { + this.tag = tag; + } + + + public EndpointEvent eventTime(@javax.annotation.Nonnull OffsetDateTime eventTime) { + this.eventTime = eventTime; + return this; + } + + /** + * The time the event occurred. In ISO-8601 format. + * @return eventTime + */ + @javax.annotation.Nonnull + public OffsetDateTime getEventTime() { + return eventTime; + } + + public void setEventTime(@javax.annotation.Nonnull OffsetDateTime eventTime) { + this.eventTime = eventTime; + } + + + public EndpointEvent eventType(@javax.annotation.Nonnull EndpointEventTypeEnum eventType) { + this.eventType = eventType; + return this; + } + + /** + * Get eventType + * @return eventType + */ + @javax.annotation.Nonnull + public EndpointEventTypeEnum getEventType() { + return eventType; + } + + public void setEventType(@javax.annotation.Nonnull EndpointEventTypeEnum eventType) { + this.eventType = eventType; + } + + + public EndpointEvent device(@javax.annotation.Nullable Device device) { + this.device = device; + return this; + } + + /** + * Get device + * @return device + */ + @javax.annotation.Nullable + public Device getDevice() { + return device; + } + + public void setDevice(@javax.annotation.Nullable Device device) { + this.device = device; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EndpointEvent instance itself + */ + public EndpointEvent putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EndpointEvent endpointEvent = (EndpointEvent) o; + return Objects.equals(this.endpointId, endpointEvent.endpointId) && + Objects.equals(this.type, endpointEvent.type) && + Objects.equals(this.status, endpointEvent.status) && + Objects.equals(this.creationTimestamp, endpointEvent.creationTimestamp) && + Objects.equals(this.expirationTimestamp, endpointEvent.expirationTimestamp) && + Objects.equals(this.tag, endpointEvent.tag) && + Objects.equals(this.eventTime, endpointEvent.eventTime) && + Objects.equals(this.eventType, endpointEvent.eventType) && + Objects.equals(this.device, endpointEvent.device)&& + Objects.equals(this.additionalProperties, endpointEvent.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(endpointId, type, status, creationTimestamp, expirationTimestamp, tag, eventTime, eventType, device, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EndpointEvent {\n"); + sb.append(" endpointId: ").append(toIndentedString(endpointId)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" creationTimestamp: ").append(toIndentedString(creationTimestamp)).append("\n"); + sb.append(" expirationTimestamp: ").append(toIndentedString(expirationTimestamp)).append("\n"); + sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" eventTime: ").append(toIndentedString(eventTime)).append("\n"); + sb.append(" eventType: ").append(toIndentedString(eventType)).append("\n"); + sb.append(" device: ").append(toIndentedString(device)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("endpointId", "type", "status", "creationTimestamp", "expirationTimestamp", "tag", "eventTime", "eventType", "device")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("endpointId", "type", "status", "creationTimestamp", "expirationTimestamp", "eventTime", "eventType")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EndpointEvent + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EndpointEvent.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EndpointEvent is not found in the empty JSON string", EndpointEvent.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EndpointEvent.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("endpointId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `endpointId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("endpointId").toString())); + } + // validate the required field `type` + EndpointTypeEnum.validateJsonElement(jsonObj.get("type")); + // validate the required field `status` + EndpointStatusEnum.validateJsonElement(jsonObj.get("status")); + if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + } + // validate the required field `eventType` + EndpointEventTypeEnum.validateJsonElement(jsonObj.get("eventType")); + // validate the optional field `device` + if (jsonObj.get("device") != null && !jsonObj.get("device").isJsonNull()) { + Device.validateJsonElement(jsonObj.get("device")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EndpointEvent.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EndpointEvent' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EndpointEvent.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EndpointEvent value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public EndpointEvent read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EndpointEvent instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EndpointEvent given an JSON string + * + * @param jsonString JSON string + * @return An instance of EndpointEvent + * @throws IOException if the JSON string is invalid with respect to EndpointEvent + */ + public static EndpointEvent fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EndpointEvent.class); + } + + /** + * Convert an instance of EndpointEvent to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/EndpointEventTypeEnum.java b/src/main/java/com/bandwidth/sdk/model/EndpointEventTypeEnum.java new file mode 100644 index 00000000..c394e7ac --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/EndpointEventTypeEnum.java @@ -0,0 +1,80 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets endpointEventTypeEnum + */ +@JsonAdapter(EndpointEventTypeEnum.Adapter.class) +public enum EndpointEventTypeEnum { + + DEVICE_CONNECTED("DEVICE_CONNECTED"), + + DEVICE_DISCONNECTED("DEVICE_DISCONNECTED"); + + private String value; + + EndpointEventTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EndpointEventTypeEnum fromValue(String value) { + for (EndpointEventTypeEnum b : EndpointEventTypeEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EndpointEventTypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EndpointEventTypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EndpointEventTypeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EndpointEventTypeEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/EndpointResponse.java b/src/main/java/com/bandwidth/sdk/model/EndpointResponse.java new file mode 100644 index 00000000..3cb5e4b3 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/EndpointResponse.java @@ -0,0 +1,387 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.Endpoint; +import com.bandwidth.sdk.model.Error1; +import com.bandwidth.sdk.model.Link1; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * EndpointResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class EndpointResponse { + public static final String SERIALIZED_NAME_LINKS = "links"; + @SerializedName(SERIALIZED_NAME_LINKS) + @javax.annotation.Nonnull + private List links = new ArrayList<>(); + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private Endpoint data; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nonnull + private List errors = new ArrayList<>(); + + public EndpointResponse() { + } + + public EndpointResponse links(@javax.annotation.Nonnull List links) { + this.links = links; + return this; + } + + public EndpointResponse addLinksItem(Link1 linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * @return links + */ + @javax.annotation.Nonnull + public List getLinks() { + return links; + } + + public void setLinks(@javax.annotation.Nonnull List links) { + this.links = links; + } + + + public EndpointResponse data(@javax.annotation.Nonnull Endpoint data) { + this.data = data; + return this; + } + + /** + * Get data + * @return data + */ + @javax.annotation.Nonnull + public Endpoint getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull Endpoint data) { + this.data = data; + } + + + public EndpointResponse errors(@javax.annotation.Nonnull List errors) { + this.errors = errors; + return this; + } + + public EndpointResponse addErrorsItem(Error1 errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + */ + @javax.annotation.Nonnull + public List getErrors() { + return errors; + } + + public void setErrors(@javax.annotation.Nonnull List errors) { + this.errors = errors; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the EndpointResponse instance itself + */ + public EndpointResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + EndpointResponse endpointResponse = (EndpointResponse) o; + return Objects.equals(this.links, endpointResponse.links) && + Objects.equals(this.data, endpointResponse.data) && + Objects.equals(this.errors, endpointResponse.errors)&& + Objects.equals(this.additionalProperties, endpointResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(links, data, errors, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class EndpointResponse {\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("links", "data", "errors")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("links", "data", "errors")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to EndpointResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!EndpointResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in EndpointResponse is not found in the empty JSON string", EndpointResponse.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : EndpointResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the json data is an array + if (!jsonObj.get("links").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `links` to be an array in the JSON string but got `%s`", jsonObj.get("links").toString())); + } + + JsonArray jsonArraylinks = jsonObj.getAsJsonArray("links"); + // validate the required field `links` (array) + for (int i = 0; i < jsonArraylinks.size(); i++) { + Link1.validateJsonElement(jsonArraylinks.get(i)); + }; + // validate the required field `data` + Endpoint.validateJsonElement(jsonObj.get("data")); + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + // validate the required field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + Error1.validateJsonElement(jsonArrayerrors.get(i)); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!EndpointResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'EndpointResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(EndpointResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, EndpointResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public EndpointResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + EndpointResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of EndpointResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of EndpointResponse + * @throws IOException if the JSON string is invalid with respect to EndpointResponse + */ + public static EndpointResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, EndpointResponse.class); + } + + /** + * Convert an instance of EndpointResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/EndpointStatusEnum.java b/src/main/java/com/bandwidth/sdk/model/EndpointStatusEnum.java new file mode 100644 index 00000000..29a90e1f --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/EndpointStatusEnum.java @@ -0,0 +1,80 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets endpointStatusEnum + */ +@JsonAdapter(EndpointStatusEnum.Adapter.class) +public enum EndpointStatusEnum { + + CONNECTED("CONNECTED"), + + DISCONNECTED("DISCONNECTED"); + + private String value; + + EndpointStatusEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EndpointStatusEnum fromValue(String value) { + for (EndpointStatusEnum b : EndpointStatusEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EndpointStatusEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EndpointStatusEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EndpointStatusEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EndpointStatusEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/EndpointTypeEnum.java b/src/main/java/com/bandwidth/sdk/model/EndpointTypeEnum.java new file mode 100644 index 00000000..08f86bd5 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/EndpointTypeEnum.java @@ -0,0 +1,78 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.annotations.SerializedName; + +import java.io.IOException; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.JsonElement; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; + +/** + * Gets or Sets endpointTypeEnum + */ +@JsonAdapter(EndpointTypeEnum.Adapter.class) +public enum EndpointTypeEnum { + + WEBRTC("WEBRTC"); + + private String value; + + EndpointTypeEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static EndpointTypeEnum fromValue(String value) { + for (EndpointTypeEnum b : EndpointTypeEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final EndpointTypeEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public EndpointTypeEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return EndpointTypeEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + EndpointTypeEnum.fromValue(value); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/Endpoints.java b/src/main/java/com/bandwidth/sdk/model/Endpoints.java new file mode 100644 index 00000000..4a04e333 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/Endpoints.java @@ -0,0 +1,435 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.EndpointStatusEnum; +import com.bandwidth.sdk.model.EndpointTypeEnum; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.time.OffsetDateTime; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * Endpoints + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class Endpoints { + public static final String SERIALIZED_NAME_ENDPOINT_ID = "endpointId"; + @SerializedName(SERIALIZED_NAME_ENDPOINT_ID) + @javax.annotation.Nonnull + private String endpointId; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private EndpointTypeEnum type; + + public static final String SERIALIZED_NAME_STATUS = "status"; + @SerializedName(SERIALIZED_NAME_STATUS) + @javax.annotation.Nonnull + private EndpointStatusEnum status; + + public static final String SERIALIZED_NAME_CREATION_TIMESTAMP = "creationTimestamp"; + @SerializedName(SERIALIZED_NAME_CREATION_TIMESTAMP) + @javax.annotation.Nonnull + private OffsetDateTime creationTimestamp; + + public static final String SERIALIZED_NAME_EXPIRATION_TIMESTAMP = "expirationTimestamp"; + @SerializedName(SERIALIZED_NAME_EXPIRATION_TIMESTAMP) + @javax.annotation.Nonnull + private OffsetDateTime expirationTimestamp; + + public static final String SERIALIZED_NAME_TAG = "tag"; + @SerializedName(SERIALIZED_NAME_TAG) + @javax.annotation.Nullable + private String tag; + + public Endpoints() { + } + + public Endpoints endpointId(@javax.annotation.Nonnull String endpointId) { + this.endpointId = endpointId; + return this; + } + + /** + * The unique ID of the endpoint. + * @return endpointId + */ + @javax.annotation.Nonnull + public String getEndpointId() { + return endpointId; + } + + public void setEndpointId(@javax.annotation.Nonnull String endpointId) { + this.endpointId = endpointId; + } + + + public Endpoints type(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + return this; + } + + /** + * Get type + * @return type + */ + @javax.annotation.Nonnull + public EndpointTypeEnum getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull EndpointTypeEnum type) { + this.type = type; + } + + + public Endpoints status(@javax.annotation.Nonnull EndpointStatusEnum status) { + this.status = status; + return this; + } + + /** + * Get status + * @return status + */ + @javax.annotation.Nonnull + public EndpointStatusEnum getStatus() { + return status; + } + + public void setStatus(@javax.annotation.Nonnull EndpointStatusEnum status) { + this.status = status; + } + + + public Endpoints creationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + return this; + } + + /** + * The time the endpoint was created. In ISO-8601 format. + * @return creationTimestamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getCreationTimestamp() { + return creationTimestamp; + } + + public void setCreationTimestamp(@javax.annotation.Nonnull OffsetDateTime creationTimestamp) { + this.creationTimestamp = creationTimestamp; + } + + + public Endpoints expirationTimestamp(@javax.annotation.Nonnull OffsetDateTime expirationTimestamp) { + this.expirationTimestamp = expirationTimestamp; + return this; + } + + /** + * The time the endpoint token will expire. In ISO-8601 format. Tokens last 24 hours. + * @return expirationTimestamp + */ + @javax.annotation.Nonnull + public OffsetDateTime getExpirationTimestamp() { + return expirationTimestamp; + } + + public void setExpirationTimestamp(@javax.annotation.Nonnull OffsetDateTime expirationTimestamp) { + this.expirationTimestamp = expirationTimestamp; + } + + + public Endpoints tag(@javax.annotation.Nullable String tag) { + this.tag = tag; + return this; + } + + /** + * A tag for the endpoint. + * @return tag + */ + @javax.annotation.Nullable + public String getTag() { + return tag; + } + + public void setTag(@javax.annotation.Nullable String tag) { + this.tag = tag; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Endpoints instance itself + */ + public Endpoints putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Endpoints endpoints = (Endpoints) o; + return Objects.equals(this.endpointId, endpoints.endpointId) && + Objects.equals(this.type, endpoints.type) && + Objects.equals(this.status, endpoints.status) && + Objects.equals(this.creationTimestamp, endpoints.creationTimestamp) && + Objects.equals(this.expirationTimestamp, endpoints.expirationTimestamp) && + Objects.equals(this.tag, endpoints.tag)&& + Objects.equals(this.additionalProperties, endpoints.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(endpointId, type, status, creationTimestamp, expirationTimestamp, tag, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Endpoints {\n"); + sb.append(" endpointId: ").append(toIndentedString(endpointId)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" status: ").append(toIndentedString(status)).append("\n"); + sb.append(" creationTimestamp: ").append(toIndentedString(creationTimestamp)).append("\n"); + sb.append(" expirationTimestamp: ").append(toIndentedString(expirationTimestamp)).append("\n"); + sb.append(" tag: ").append(toIndentedString(tag)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("endpointId", "type", "status", "creationTimestamp", "expirationTimestamp", "tag")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("endpointId", "type", "status", "creationTimestamp", "expirationTimestamp")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Endpoints + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Endpoints.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Endpoints is not found in the empty JSON string", Endpoints.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Endpoints.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("endpointId").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `endpointId` to be a primitive type in the JSON string but got `%s`", jsonObj.get("endpointId").toString())); + } + // validate the required field `type` + EndpointTypeEnum.validateJsonElement(jsonObj.get("type")); + // validate the required field `status` + EndpointStatusEnum.validateJsonElement(jsonObj.get("status")); + if ((jsonObj.get("tag") != null && !jsonObj.get("tag").isJsonNull()) && !jsonObj.get("tag").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `tag` to be a primitive type in the JSON string but got `%s`", jsonObj.get("tag").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Endpoints.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Endpoints' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Endpoints.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Endpoints value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Endpoints read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Endpoints instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Endpoints given an JSON string + * + * @param jsonString JSON string + * @return An instance of Endpoints + * @throws IOException if the JSON string is invalid with respect to Endpoints + */ + public static Endpoints fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Endpoints.class); + } + + /** + * Convert an instance of Endpoints to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/Error1.java b/src/main/java/com/bandwidth/sdk/model/Error1.java new file mode 100644 index 00000000..0f1595f5 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/Error1.java @@ -0,0 +1,414 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.Error1Source; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; +import java.util.UUID; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * Error1 + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class Error1 { + public static final String SERIALIZED_NAME_ID = "id"; + @SerializedName(SERIALIZED_NAME_ID) + @javax.annotation.Nonnull + private UUID id; + + public static final String SERIALIZED_NAME_TYPE = "type"; + @SerializedName(SERIALIZED_NAME_TYPE) + @javax.annotation.Nonnull + private String type; + + public static final String SERIALIZED_NAME_DESCRIPTION = "description"; + @SerializedName(SERIALIZED_NAME_DESCRIPTION) + @javax.annotation.Nonnull + private String description; + + public static final String SERIALIZED_NAME_CODE = "code"; + @SerializedName(SERIALIZED_NAME_CODE) + @javax.annotation.Nonnull + private String code; + + public static final String SERIALIZED_NAME_SOURCE = "source"; + @SerializedName(SERIALIZED_NAME_SOURCE) + @javax.annotation.Nullable + private Error1Source source; + + public Error1() { + } + + public Error1 id(@javax.annotation.Nonnull UUID id) { + this.id = id; + return this; + } + + /** + * A unique identifier for the error. + * @return id + */ + @javax.annotation.Nonnull + public UUID getId() { + return id; + } + + public void setId(@javax.annotation.Nonnull UUID id) { + this.id = id; + } + + + public Error1 type(@javax.annotation.Nonnull String type) { + this.type = type; + return this; + } + + /** + * The type of error. + * @return type + */ + @javax.annotation.Nonnull + public String getType() { + return type; + } + + public void setType(@javax.annotation.Nonnull String type) { + this.type = type; + } + + + public Error1 description(@javax.annotation.Nonnull String description) { + this.description = description; + return this; + } + + /** + * A description of the error. + * @return description + */ + @javax.annotation.Nonnull + public String getDescription() { + return description; + } + + public void setDescription(@javax.annotation.Nonnull String description) { + this.description = description; + } + + + public Error1 code(@javax.annotation.Nonnull String code) { + this.code = code; + return this; + } + + /** + * A code that uniquely identifies the error. + * @return code + */ + @javax.annotation.Nonnull + public String getCode() { + return code; + } + + public void setCode(@javax.annotation.Nonnull String code) { + this.code = code; + } + + + public Error1 source(@javax.annotation.Nullable Error1Source source) { + this.source = source; + return this; + } + + /** + * Get source + * @return source + */ + @javax.annotation.Nullable + public Error1Source getSource() { + return source; + } + + public void setSource(@javax.annotation.Nullable Error1Source source) { + this.source = source; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Error1 instance itself + */ + public Error1 putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error1 error1 = (Error1) o; + return Objects.equals(this.id, error1.id) && + Objects.equals(this.type, error1.type) && + Objects.equals(this.description, error1.description) && + Objects.equals(this.code, error1.code) && + Objects.equals(this.source, error1.source)&& + Objects.equals(this.additionalProperties, error1.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(id, type, description, code, source, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Error1 {\n"); + sb.append(" id: ").append(toIndentedString(id)).append("\n"); + sb.append(" type: ").append(toIndentedString(type)).append("\n"); + sb.append(" description: ").append(toIndentedString(description)).append("\n"); + sb.append(" code: ").append(toIndentedString(code)).append("\n"); + sb.append(" source: ").append(toIndentedString(source)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("id", "type", "description", "code", "source")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("id", "type", "description", "code")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Error1 + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Error1.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Error1 is not found in the empty JSON string", Error1.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Error1.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if (!jsonObj.get("id").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `id` to be a primitive type in the JSON string but got `%s`", jsonObj.get("id").toString())); + } + if (!jsonObj.get("type").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `type` to be a primitive type in the JSON string but got `%s`", jsonObj.get("type").toString())); + } + if (!jsonObj.get("description").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `description` to be a primitive type in the JSON string but got `%s`", jsonObj.get("description").toString())); + } + if (!jsonObj.get("code").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `code` to be a primitive type in the JSON string but got `%s`", jsonObj.get("code").toString())); + } + // validate the optional field `source` + if (jsonObj.get("source") != null && !jsonObj.get("source").isJsonNull()) { + Error1Source.validateJsonElement(jsonObj.get("source")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Error1.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Error1' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Error1.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Error1 value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Error1 read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Error1 instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Error1 given an JSON string + * + * @param jsonString JSON string + * @return An instance of Error1 + * @throws IOException if the JSON string is invalid with respect to Error1 + */ + public static Error1 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Error1.class); + } + + /** + * Convert an instance of Error1 to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/Error1Source.java b/src/main/java/com/bandwidth/sdk/model/Error1Source.java new file mode 100644 index 00000000..d0bc96ac --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/Error1Source.java @@ -0,0 +1,375 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * Error1Source + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class Error1Source { + public static final String SERIALIZED_NAME_PARAMETER = "parameter"; + @SerializedName(SERIALIZED_NAME_PARAMETER) + @javax.annotation.Nullable + private String parameter; + + public static final String SERIALIZED_NAME_FIELD = "field"; + @SerializedName(SERIALIZED_NAME_FIELD) + @javax.annotation.Nullable + private String field; + + public static final String SERIALIZED_NAME_HEADER = "header"; + @SerializedName(SERIALIZED_NAME_HEADER) + @javax.annotation.Nullable + private String header; + + public static final String SERIALIZED_NAME_REFERENCE = "reference"; + @SerializedName(SERIALIZED_NAME_REFERENCE) + @javax.annotation.Nullable + private String reference; + + public Error1Source() { + } + + public Error1Source parameter(@javax.annotation.Nullable String parameter) { + this.parameter = parameter; + return this; + } + + /** + * The URI parameter that caused the error. + * @return parameter + */ + @javax.annotation.Nullable + public String getParameter() { + return parameter; + } + + public void setParameter(@javax.annotation.Nullable String parameter) { + this.parameter = parameter; + } + + + public Error1Source field(@javax.annotation.Nullable String field) { + this.field = field; + return this; + } + + /** + * The request body field that caused the error. + * @return field + */ + @javax.annotation.Nullable + public String getField() { + return field; + } + + public void setField(@javax.annotation.Nullable String field) { + this.field = field; + } + + + public Error1Source header(@javax.annotation.Nullable String header) { + this.header = header; + return this; + } + + /** + * The header that caused the error. + * @return header + */ + @javax.annotation.Nullable + public String getHeader() { + return header; + } + + public void setHeader(@javax.annotation.Nullable String header) { + this.header = header; + } + + + public Error1Source reference(@javax.annotation.Nullable String reference) { + this.reference = reference; + return this; + } + + /** + * The resource ID or path to the resource (or non-existent resource) causing the error. + * @return reference + */ + @javax.annotation.Nullable + public String getReference() { + return reference; + } + + public void setReference(@javax.annotation.Nullable String reference) { + this.reference = reference; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Error1Source instance itself + */ + public Error1Source putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Error1Source error1Source = (Error1Source) o; + return Objects.equals(this.parameter, error1Source.parameter) && + Objects.equals(this.field, error1Source.field) && + Objects.equals(this.header, error1Source.header) && + Objects.equals(this.reference, error1Source.reference)&& + Objects.equals(this.additionalProperties, error1Source.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(parameter, field, header, reference, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Error1Source {\n"); + sb.append(" parameter: ").append(toIndentedString(parameter)).append("\n"); + sb.append(" field: ").append(toIndentedString(field)).append("\n"); + sb.append(" header: ").append(toIndentedString(header)).append("\n"); + sb.append(" reference: ").append(toIndentedString(reference)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("parameter", "field", "header", "reference")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Error1Source + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Error1Source.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Error1Source is not found in the empty JSON string", Error1Source.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("parameter") != null && !jsonObj.get("parameter").isJsonNull()) && !jsonObj.get("parameter").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `parameter` to be a primitive type in the JSON string but got `%s`", jsonObj.get("parameter").toString())); + } + if ((jsonObj.get("field") != null && !jsonObj.get("field").isJsonNull()) && !jsonObj.get("field").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `field` to be a primitive type in the JSON string but got `%s`", jsonObj.get("field").toString())); + } + if ((jsonObj.get("header") != null && !jsonObj.get("header").isJsonNull()) && !jsonObj.get("header").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `header` to be a primitive type in the JSON string but got `%s`", jsonObj.get("header").toString())); + } + if ((jsonObj.get("reference") != null && !jsonObj.get("reference").isJsonNull()) && !jsonObj.get("reference").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `reference` to be a primitive type in the JSON string but got `%s`", jsonObj.get("reference").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Error1Source.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Error1Source' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Error1Source.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Error1Source value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Error1Source read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Error1Source instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Error1Source given an JSON string + * + * @param jsonString JSON string + * @return An instance of Error1Source + * @throws IOException if the JSON string is invalid with respect to Error1Source + */ + public static Error1Source fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Error1Source.class); + } + + /** + * Convert an instance of Error1Source to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/ErrorResponse.java b/src/main/java/com/bandwidth/sdk/model/ErrorResponse.java new file mode 100644 index 00000000..8c59b063 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/ErrorResponse.java @@ -0,0 +1,384 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.Error1; +import com.bandwidth.sdk.model.Link1; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * ErrorResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class ErrorResponse { + public static final String SERIALIZED_NAME_LINKS = "links"; + @SerializedName(SERIALIZED_NAME_LINKS) + @javax.annotation.Nonnull + private List links = new ArrayList<>(); + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nullable + private Object data; + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nonnull + private List errors = new ArrayList<>(); + + public ErrorResponse() { + } + + public ErrorResponse links(@javax.annotation.Nonnull List links) { + this.links = links; + return this; + } + + public ErrorResponse addLinksItem(Link1 linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * @return links + */ + @javax.annotation.Nonnull + public List getLinks() { + return links; + } + + public void setLinks(@javax.annotation.Nonnull List links) { + this.links = links; + } + + + public ErrorResponse data(@javax.annotation.Nullable Object data) { + this.data = data; + return this; + } + + /** + * Get data + * @return data + */ + @javax.annotation.Nullable + public Object getData() { + return data; + } + + public void setData(@javax.annotation.Nullable Object data) { + this.data = data; + } + + + public ErrorResponse errors(@javax.annotation.Nonnull List errors) { + this.errors = errors; + return this; + } + + public ErrorResponse addErrorsItem(Error1 errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + */ + @javax.annotation.Nonnull + public List getErrors() { + return errors; + } + + public void setErrors(@javax.annotation.Nonnull List errors) { + this.errors = errors; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ErrorResponse instance itself + */ + public ErrorResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ErrorResponse errorResponse = (ErrorResponse) o; + return Objects.equals(this.links, errorResponse.links) && + Objects.equals(this.data, errorResponse.data) && + Objects.equals(this.errors, errorResponse.errors)&& + Objects.equals(this.additionalProperties, errorResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(links, data, errors, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ErrorResponse {\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("links", "data", "errors")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("links", "data", "errors")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ErrorResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ErrorResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ErrorResponse is not found in the empty JSON string", ErrorResponse.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ErrorResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the json data is an array + if (!jsonObj.get("links").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `links` to be an array in the JSON string but got `%s`", jsonObj.get("links").toString())); + } + + JsonArray jsonArraylinks = jsonObj.getAsJsonArray("links"); + // validate the required field `links` (array) + for (int i = 0; i < jsonArraylinks.size(); i++) { + Link1.validateJsonElement(jsonArraylinks.get(i)); + }; + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + // validate the required field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + Error1.validateJsonElement(jsonArrayerrors.get(i)); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ErrorResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ErrorResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ErrorResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ErrorResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ErrorResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ErrorResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ErrorResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ErrorResponse + * @throws IOException if the JSON string is invalid with respect to ErrorResponse + */ + public static ErrorResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ErrorResponse.class); + } + + /** + * Convert an instance of ErrorResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/Link1.java b/src/main/java/com/bandwidth/sdk/model/Link1.java new file mode 100644 index 00000000..46428c5e --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/Link1.java @@ -0,0 +1,404 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * Link1 + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class Link1 { + public static final String SERIALIZED_NAME_HREF = "href"; + @SerializedName(SERIALIZED_NAME_HREF) + @javax.annotation.Nullable + private String href; + + public static final String SERIALIZED_NAME_REL = "rel"; + @SerializedName(SERIALIZED_NAME_REL) + @javax.annotation.Nullable + private String rel; + + /** + * The HTTP method to use when making the request. + */ + @JsonAdapter(MethodEnum.Adapter.class) + public enum MethodEnum { + GET("GET"), + + POST("POST"), + + DELETE("DELETE"); + + private String value; + + MethodEnum(String value) { + this.value = value; + } + + public String getValue() { + return value; + } + + @Override + public String toString() { + return String.valueOf(value); + } + + public static MethodEnum fromValue(String value) { + for (MethodEnum b : MethodEnum.values()) { + if (b.value.equalsIgnoreCase(value)) { + return b; + } + } + throw new IllegalArgumentException("Unexpected value '" + value + "'"); + } + + public static class Adapter extends TypeAdapter { + @Override + public void write(final JsonWriter jsonWriter, final MethodEnum enumeration) throws IOException { + jsonWriter.value(enumeration.getValue()); + } + + @Override + public MethodEnum read(final JsonReader jsonReader) throws IOException { + String value = jsonReader.nextString(); + return MethodEnum.fromValue(value); + } + } + + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + String value = jsonElement.getAsString(); + MethodEnum.fromValue(value); + } + } + + public static final String SERIALIZED_NAME_METHOD = "method"; + @SerializedName(SERIALIZED_NAME_METHOD) + @javax.annotation.Nullable + private MethodEnum method; + + public Link1() { + } + + public Link1 href(@javax.annotation.Nullable String href) { + this.href = href; + return this; + } + + /** + * The full URL of the link. + * @return href + */ + @javax.annotation.Nullable + public String getHref() { + return href; + } + + public void setHref(@javax.annotation.Nullable String href) { + this.href = href; + } + + + public Link1 rel(@javax.annotation.Nullable String rel) { + this.rel = rel; + return this; + } + + /** + * The relationship of the link to the current resource. + * @return rel + */ + @javax.annotation.Nullable + public String getRel() { + return rel; + } + + public void setRel(@javax.annotation.Nullable String rel) { + this.rel = rel; + } + + + public Link1 method(@javax.annotation.Nullable MethodEnum method) { + this.method = method; + return this; + } + + /** + * The HTTP method to use when making the request. + * @return method + */ + @javax.annotation.Nullable + public MethodEnum getMethod() { + return method; + } + + public void setMethod(@javax.annotation.Nullable MethodEnum method) { + this.method = method; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Link1 instance itself + */ + public Link1 putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Link1 link1 = (Link1) o; + return Objects.equals(this.href, link1.href) && + Objects.equals(this.rel, link1.rel) && + Objects.equals(this.method, link1.method)&& + Objects.equals(this.additionalProperties, link1.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(href, rel, method, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Link1 {\n"); + sb.append(" href: ").append(toIndentedString(href)).append("\n"); + sb.append(" rel: ").append(toIndentedString(rel)).append("\n"); + sb.append(" method: ").append(toIndentedString(method)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("href", "rel", "method")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Link1 + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Link1.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Link1 is not found in the empty JSON string", Link1.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("href") != null && !jsonObj.get("href").isJsonNull()) && !jsonObj.get("href").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `href` to be a primitive type in the JSON string but got `%s`", jsonObj.get("href").toString())); + } + if ((jsonObj.get("rel") != null && !jsonObj.get("rel").isJsonNull()) && !jsonObj.get("rel").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `rel` to be a primitive type in the JSON string but got `%s`", jsonObj.get("rel").toString())); + } + if ((jsonObj.get("method") != null && !jsonObj.get("method").isJsonNull()) && !jsonObj.get("method").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `method` to be a primitive type in the JSON string but got `%s`", jsonObj.get("method").toString())); + } + // validate the optional field `method` + if (jsonObj.get("method") != null && !jsonObj.get("method").isJsonNull()) { + MethodEnum.validateJsonElement(jsonObj.get("method")); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Link1.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Link1' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Link1.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Link1 value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Link1 read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Link1 instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Link1 given an JSON string + * + * @param jsonString JSON string + * @return An instance of Link1 + * @throws IOException if the JSON string is invalid with respect to Link1 + */ + public static Link1 fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Link1.class); + } + + /** + * Convert an instance of Link1 to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/ListEndpointsResponse.java b/src/main/java/com/bandwidth/sdk/model/ListEndpointsResponse.java new file mode 100644 index 00000000..b343746a --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/ListEndpointsResponse.java @@ -0,0 +1,434 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.Endpoints; +import com.bandwidth.sdk.model.Error1; +import com.bandwidth.sdk.model.Link1; +import com.bandwidth.sdk.model.Page; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * ListEndpointsResponse + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class ListEndpointsResponse { + public static final String SERIALIZED_NAME_LINKS = "links"; + @SerializedName(SERIALIZED_NAME_LINKS) + @javax.annotation.Nonnull + private List links = new ArrayList<>(); + + public static final String SERIALIZED_NAME_PAGE = "page"; + @SerializedName(SERIALIZED_NAME_PAGE) + @javax.annotation.Nullable + private Page page; + + public static final String SERIALIZED_NAME_DATA = "data"; + @SerializedName(SERIALIZED_NAME_DATA) + @javax.annotation.Nonnull + private List data = new ArrayList<>(); + + public static final String SERIALIZED_NAME_ERRORS = "errors"; + @SerializedName(SERIALIZED_NAME_ERRORS) + @javax.annotation.Nonnull + private List errors = new ArrayList<>(); + + public ListEndpointsResponse() { + } + + public ListEndpointsResponse links(@javax.annotation.Nonnull List links) { + this.links = links; + return this; + } + + public ListEndpointsResponse addLinksItem(Link1 linksItem) { + if (this.links == null) { + this.links = new ArrayList<>(); + } + this.links.add(linksItem); + return this; + } + + /** + * Get links + * @return links + */ + @javax.annotation.Nonnull + public List getLinks() { + return links; + } + + public void setLinks(@javax.annotation.Nonnull List links) { + this.links = links; + } + + + public ListEndpointsResponse page(@javax.annotation.Nullable Page page) { + this.page = page; + return this; + } + + /** + * Get page + * @return page + */ + @javax.annotation.Nullable + public Page getPage() { + return page; + } + + public void setPage(@javax.annotation.Nullable Page page) { + this.page = page; + } + + + public ListEndpointsResponse data(@javax.annotation.Nonnull List data) { + this.data = data; + return this; + } + + public ListEndpointsResponse addDataItem(Endpoints dataItem) { + if (this.data == null) { + this.data = new ArrayList<>(); + } + this.data.add(dataItem); + return this; + } + + /** + * Get data + * @return data + */ + @javax.annotation.Nonnull + public List getData() { + return data; + } + + public void setData(@javax.annotation.Nonnull List data) { + this.data = data; + } + + + public ListEndpointsResponse errors(@javax.annotation.Nonnull List errors) { + this.errors = errors; + return this; + } + + public ListEndpointsResponse addErrorsItem(Error1 errorsItem) { + if (this.errors == null) { + this.errors = new ArrayList<>(); + } + this.errors.add(errorsItem); + return this; + } + + /** + * Get errors + * @return errors + */ + @javax.annotation.Nonnull + public List getErrors() { + return errors; + } + + public void setErrors(@javax.annotation.Nonnull List errors) { + this.errors = errors; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the ListEndpointsResponse instance itself + */ + public ListEndpointsResponse putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ListEndpointsResponse listEndpointsResponse = (ListEndpointsResponse) o; + return Objects.equals(this.links, listEndpointsResponse.links) && + Objects.equals(this.page, listEndpointsResponse.page) && + Objects.equals(this.data, listEndpointsResponse.data) && + Objects.equals(this.errors, listEndpointsResponse.errors)&& + Objects.equals(this.additionalProperties, listEndpointsResponse.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(links, page, data, errors, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class ListEndpointsResponse {\n"); + sb.append(" links: ").append(toIndentedString(links)).append("\n"); + sb.append(" page: ").append(toIndentedString(page)).append("\n"); + sb.append(" data: ").append(toIndentedString(data)).append("\n"); + sb.append(" errors: ").append(toIndentedString(errors)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("links", "page", "data", "errors")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("links", "data", "errors")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to ListEndpointsResponse + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!ListEndpointsResponse.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in ListEndpointsResponse is not found in the empty JSON string", ListEndpointsResponse.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : ListEndpointsResponse.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // ensure the json data is an array + if (!jsonObj.get("links").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `links` to be an array in the JSON string but got `%s`", jsonObj.get("links").toString())); + } + + JsonArray jsonArraylinks = jsonObj.getAsJsonArray("links"); + // validate the required field `links` (array) + for (int i = 0; i < jsonArraylinks.size(); i++) { + Link1.validateJsonElement(jsonArraylinks.get(i)); + }; + // validate the optional field `page` + if (jsonObj.get("page") != null && !jsonObj.get("page").isJsonNull()) { + Page.validateJsonElement(jsonObj.get("page")); + } + // ensure the json data is an array + if (!jsonObj.get("data").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `data` to be an array in the JSON string but got `%s`", jsonObj.get("data").toString())); + } + + JsonArray jsonArraydata = jsonObj.getAsJsonArray("data"); + // validate the required field `data` (array) + for (int i = 0; i < jsonArraydata.size(); i++) { + Endpoints.validateJsonElement(jsonArraydata.get(i)); + }; + // ensure the json data is an array + if (!jsonObj.get("errors").isJsonArray()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `errors` to be an array in the JSON string but got `%s`", jsonObj.get("errors").toString())); + } + + JsonArray jsonArrayerrors = jsonObj.getAsJsonArray("errors"); + // validate the required field `errors` (array) + for (int i = 0; i < jsonArrayerrors.size(); i++) { + Error1.validateJsonElement(jsonArrayerrors.get(i)); + }; + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!ListEndpointsResponse.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'ListEndpointsResponse' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(ListEndpointsResponse.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, ListEndpointsResponse value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public ListEndpointsResponse read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + ListEndpointsResponse instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of ListEndpointsResponse given an JSON string + * + * @param jsonString JSON string + * @return An instance of ListEndpointsResponse + * @throws IOException if the JSON string is invalid with respect to ListEndpointsResponse + */ + public static ListEndpointsResponse fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, ListEndpointsResponse.class); + } + + /** + * Convert an instance of ListEndpointsResponse to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/Page.java b/src/main/java/com/bandwidth/sdk/model/Page.java new file mode 100644 index 00000000..659aced4 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/Page.java @@ -0,0 +1,374 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * Page + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class Page { + public static final String SERIALIZED_NAME_PAGE_SIZE = "pageSize"; + @SerializedName(SERIALIZED_NAME_PAGE_SIZE) + @javax.annotation.Nonnull + private Integer pageSize; + + public static final String SERIALIZED_NAME_TOTAL_ELEMENTS = "totalElements"; + @SerializedName(SERIALIZED_NAME_TOTAL_ELEMENTS) + @javax.annotation.Nullable + private Integer totalElements; + + public static final String SERIALIZED_NAME_TOTAL_PAGES = "totalPages"; + @SerializedName(SERIALIZED_NAME_TOTAL_PAGES) + @javax.annotation.Nullable + private Integer totalPages; + + public static final String SERIALIZED_NAME_PAGE_NUMBER = "pageNumber"; + @SerializedName(SERIALIZED_NAME_PAGE_NUMBER) + @javax.annotation.Nullable + private Integer pageNumber; + + public Page() { + } + + public Page pageSize(@javax.annotation.Nonnull Integer pageSize) { + this.pageSize = pageSize; + return this; + } + + /** + * The number of items per page. + * minimum: 0 + * @return pageSize + */ + @javax.annotation.Nonnull + public Integer getPageSize() { + return pageSize; + } + + public void setPageSize(@javax.annotation.Nonnull Integer pageSize) { + this.pageSize = pageSize; + } + + + public Page totalElements(@javax.annotation.Nullable Integer totalElements) { + this.totalElements = totalElements; + return this; + } + + /** + * The total number of items. + * minimum: 0 + * @return totalElements + */ + @javax.annotation.Nullable + public Integer getTotalElements() { + return totalElements; + } + + public void setTotalElements(@javax.annotation.Nullable Integer totalElements) { + this.totalElements = totalElements; + } + + + public Page totalPages(@javax.annotation.Nullable Integer totalPages) { + this.totalPages = totalPages; + return this; + } + + /** + * The total number of pages. + * minimum: 0 + * @return totalPages + */ + @javax.annotation.Nullable + public Integer getTotalPages() { + return totalPages; + } + + public void setTotalPages(@javax.annotation.Nullable Integer totalPages) { + this.totalPages = totalPages; + } + + + public Page pageNumber(@javax.annotation.Nullable Integer pageNumber) { + this.pageNumber = pageNumber; + return this; + } + + /** + * The current page number. + * minimum: 0 + * @return pageNumber + */ + @javax.annotation.Nullable + public Integer getPageNumber() { + return pageNumber; + } + + public void setPageNumber(@javax.annotation.Nullable Integer pageNumber) { + this.pageNumber = pageNumber; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the Page instance itself + */ + public Page putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + Page page = (Page) o; + return Objects.equals(this.pageSize, page.pageSize) && + Objects.equals(this.totalElements, page.totalElements) && + Objects.equals(this.totalPages, page.totalPages) && + Objects.equals(this.pageNumber, page.pageNumber)&& + Objects.equals(this.additionalProperties, page.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(pageSize, totalElements, totalPages, pageNumber, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class Page {\n"); + sb.append(" pageSize: ").append(toIndentedString(pageSize)).append("\n"); + sb.append(" totalElements: ").append(toIndentedString(totalElements)).append("\n"); + sb.append(" totalPages: ").append(toIndentedString(totalPages)).append("\n"); + sb.append(" pageNumber: ").append(toIndentedString(pageNumber)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("pageSize", "totalElements", "totalPages", "pageNumber")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(Arrays.asList("pageSize")); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to Page + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!Page.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in Page is not found in the empty JSON string", Page.openapiRequiredFields.toString())); + } + } + + // check to make sure all required properties/fields are present in the JSON string + for (String requiredField : Page.openapiRequiredFields) { + if (jsonElement.getAsJsonObject().get(requiredField) == null) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field `%s` is not found in the JSON string: %s", requiredField, jsonElement.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!Page.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'Page' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(Page.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, Page value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public Page read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + Page instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of Page given an JSON string + * + * @param jsonString JSON string + * @return An instance of Page + * @throws IOException if the JSON string is invalid with respect to Page + */ + public static Page fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, Page.class); + } + + /** + * Convert an instance of Page to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/SipConnectionMetadata.java b/src/main/java/com/bandwidth/sdk/model/SipConnectionMetadata.java new file mode 100644 index 00000000..c2434be1 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/SipConnectionMetadata.java @@ -0,0 +1,374 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.bandwidth.sdk.model.SipCredentials; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * SipConnectionMetadata + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class SipConnectionMetadata { + public static final String SERIALIZED_NAME_IP_ADDRESS = "ipAddress"; + @SerializedName(SERIALIZED_NAME_IP_ADDRESS) + @javax.annotation.Nullable + private String ipAddress; + + public static final String SERIALIZED_NAME_PORT = "port"; + @SerializedName(SERIALIZED_NAME_PORT) + @javax.annotation.Nullable + private Integer port; + + public static final String SERIALIZED_NAME_CREDENTIALS = "credentials"; + @SerializedName(SERIALIZED_NAME_CREDENTIALS) + @javax.annotation.Nullable + private SipCredentials credentials; + + public static final String SERIALIZED_NAME_UUI_HEADER = "uuiHeader"; + @SerializedName(SERIALIZED_NAME_UUI_HEADER) + @javax.annotation.Nullable + private String uuiHeader; + + public SipConnectionMetadata() { + } + + public SipConnectionMetadata ipAddress(@javax.annotation.Nullable String ipAddress) { + this.ipAddress = ipAddress; + return this; + } + + /** + * The IP address of the SIP connection. + * @return ipAddress + */ + @javax.annotation.Nullable + public String getIpAddress() { + return ipAddress; + } + + public void setIpAddress(@javax.annotation.Nullable String ipAddress) { + this.ipAddress = ipAddress; + } + + + public SipConnectionMetadata port(@javax.annotation.Nullable Integer port) { + this.port = port; + return this; + } + + /** + * The port of the SIP connection. + * @return port + */ + @javax.annotation.Nullable + public Integer getPort() { + return port; + } + + public void setPort(@javax.annotation.Nullable Integer port) { + this.port = port; + } + + + public SipConnectionMetadata credentials(@javax.annotation.Nullable SipCredentials credentials) { + this.credentials = credentials; + return this; + } + + /** + * Get credentials + * @return credentials + */ + @javax.annotation.Nullable + public SipCredentials getCredentials() { + return credentials; + } + + public void setCredentials(@javax.annotation.Nullable SipCredentials credentials) { + this.credentials = credentials; + } + + + public SipConnectionMetadata uuiHeader(@javax.annotation.Nullable String uuiHeader) { + this.uuiHeader = uuiHeader; + return this; + } + + /** + * The User-to-User Information header for the SIP connection. + * @return uuiHeader + */ + @javax.annotation.Nullable + public String getUuiHeader() { + return uuiHeader; + } + + public void setUuiHeader(@javax.annotation.Nullable String uuiHeader) { + this.uuiHeader = uuiHeader; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SipConnectionMetadata instance itself + */ + public SipConnectionMetadata putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SipConnectionMetadata sipConnectionMetadata = (SipConnectionMetadata) o; + return Objects.equals(this.ipAddress, sipConnectionMetadata.ipAddress) && + Objects.equals(this.port, sipConnectionMetadata.port) && + Objects.equals(this.credentials, sipConnectionMetadata.credentials) && + Objects.equals(this.uuiHeader, sipConnectionMetadata.uuiHeader)&& + Objects.equals(this.additionalProperties, sipConnectionMetadata.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(ipAddress, port, credentials, uuiHeader, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SipConnectionMetadata {\n"); + sb.append(" ipAddress: ").append(toIndentedString(ipAddress)).append("\n"); + sb.append(" port: ").append(toIndentedString(port)).append("\n"); + sb.append(" credentials: ").append(toIndentedString(credentials)).append("\n"); + sb.append(" uuiHeader: ").append(toIndentedString(uuiHeader)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("ipAddress", "port", "credentials", "uuiHeader")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SipConnectionMetadata + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SipConnectionMetadata.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SipConnectionMetadata is not found in the empty JSON string", SipConnectionMetadata.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("ipAddress") != null && !jsonObj.get("ipAddress").isJsonNull()) && !jsonObj.get("ipAddress").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `ipAddress` to be a primitive type in the JSON string but got `%s`", jsonObj.get("ipAddress").toString())); + } + // validate the optional field `credentials` + if (jsonObj.get("credentials") != null && !jsonObj.get("credentials").isJsonNull()) { + SipCredentials.validateJsonElement(jsonObj.get("credentials")); + } + if ((jsonObj.get("uuiHeader") != null && !jsonObj.get("uuiHeader").isJsonNull()) && !jsonObj.get("uuiHeader").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `uuiHeader` to be a primitive type in the JSON string but got `%s`", jsonObj.get("uuiHeader").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SipConnectionMetadata.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SipConnectionMetadata' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SipConnectionMetadata.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SipConnectionMetadata value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SipConnectionMetadata read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SipConnectionMetadata instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SipConnectionMetadata given an JSON string + * + * @param jsonString JSON string + * @return An instance of SipConnectionMetadata + * @throws IOException if the JSON string is invalid with respect to SipConnectionMetadata + */ + public static SipConnectionMetadata fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SipConnectionMetadata.class); + } + + /** + * Convert an instance of SipConnectionMetadata to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} + diff --git a/src/main/java/com/bandwidth/sdk/model/SipCredentials.java b/src/main/java/com/bandwidth/sdk/model/SipCredentials.java new file mode 100644 index 00000000..7db8bc71 --- /dev/null +++ b/src/main/java/com/bandwidth/sdk/model/SipCredentials.java @@ -0,0 +1,317 @@ +/* + * Bandwidth + * Bandwidth's Communication APIs + * + * The version of the OpenAPI document: 1.0.0 + * Contact: letstalk@bandwidth.com + * + * NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech). + * https://openapi-generator.tech + * Do not edit the class manually. + */ + + +package com.bandwidth.sdk.model; + +import java.util.Objects; +import java.util.Locale; +import com.google.gson.TypeAdapter; +import com.google.gson.annotations.JsonAdapter; +import com.google.gson.annotations.SerializedName; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; +import java.util.Arrays; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import com.google.gson.JsonArray; +import com.google.gson.JsonDeserializationContext; +import com.google.gson.JsonDeserializer; +import com.google.gson.JsonElement; +import com.google.gson.JsonObject; +import com.google.gson.JsonParseException; +import com.google.gson.TypeAdapterFactory; +import com.google.gson.reflect.TypeToken; +import com.google.gson.TypeAdapter; +import com.google.gson.stream.JsonReader; +import com.google.gson.stream.JsonWriter; +import java.io.IOException; + +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.Locale; + +import com.bandwidth.sdk.JSON; + +/** + * SipCredentials + */ +@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", comments = "Generator version: 7.17.0") +public class SipCredentials { + public static final String SERIALIZED_NAME_USERNAME = "username"; + @SerializedName(SERIALIZED_NAME_USERNAME) + @javax.annotation.Nullable + private String username; + + public static final String SERIALIZED_NAME_PASSWORD = "password"; + @SerializedName(SERIALIZED_NAME_PASSWORD) + @javax.annotation.Nullable + private String password; + + public SipCredentials() { + } + + public SipCredentials username(@javax.annotation.Nullable String username) { + this.username = username; + return this; + } + + /** + * The username for the SIP connection. + * @return username + */ + @javax.annotation.Nullable + public String getUsername() { + return username; + } + + public void setUsername(@javax.annotation.Nullable String username) { + this.username = username; + } + + + public SipCredentials password(@javax.annotation.Nullable String password) { + this.password = password; + return this; + } + + /** + * The password for the SIP connection. + * @return password + */ + @javax.annotation.Nullable + public String getPassword() { + return password; + } + + public void setPassword(@javax.annotation.Nullable String password) { + this.password = password; + } + + /** + * A container for additional, undeclared properties. + * This is a holder for any undeclared properties as specified with + * the 'additionalProperties' keyword in the OAS document. + */ + private Map additionalProperties; + + /** + * Set the additional (undeclared) property with the specified name and value. + * If the property does not already exist, create it otherwise replace it. + * + * @param key name of the property + * @param value value of the property + * @return the SipCredentials instance itself + */ + public SipCredentials putAdditionalProperty(String key, Object value) { + if (this.additionalProperties == null) { + this.additionalProperties = new HashMap(); + } + this.additionalProperties.put(key, value); + return this; + } + + /** + * Return the additional (undeclared) property. + * + * @return a map of objects + */ + public Map getAdditionalProperties() { + return additionalProperties; + } + + /** + * Return the additional (undeclared) property with the specified name. + * + * @param key name of the property + * @return an object + */ + public Object getAdditionalProperty(String key) { + if (this.additionalProperties == null) { + return null; + } + return this.additionalProperties.get(key); + } + + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + SipCredentials sipCredentials = (SipCredentials) o; + return Objects.equals(this.username, sipCredentials.username) && + Objects.equals(this.password, sipCredentials.password)&& + Objects.equals(this.additionalProperties, sipCredentials.additionalProperties); + } + + @Override + public int hashCode() { + return Objects.hash(username, password, additionalProperties); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("class SipCredentials {\n"); + sb.append(" username: ").append(toIndentedString(username)).append("\n"); + sb.append(" password: ").append(toIndentedString(password)).append("\n"); + sb.append(" additionalProperties: ").append(toIndentedString(additionalProperties)).append("\n"); + sb.append("}"); + return sb.toString(); + } + + /** + * Convert the given object to string with each line indented by 4 spaces + * (except the first line). + */ + private String toIndentedString(Object o) { + if (o == null) { + return "null"; + } + return o.toString().replace("\n", "\n "); + } + + + public static HashSet openapiFields; + public static HashSet openapiRequiredFields; + + static { + // a set of all properties/fields (JSON key names) + openapiFields = new HashSet(Arrays.asList("username", "password")); + + // a set of required properties/fields (JSON key names) + openapiRequiredFields = new HashSet(0); + } + + /** + * Validates the JSON Element and throws an exception if issues found + * + * @param jsonElement JSON Element + * @throws IOException if the JSON Element is invalid with respect to SipCredentials + */ + public static void validateJsonElement(JsonElement jsonElement) throws IOException { + if (jsonElement == null) { + if (!SipCredentials.openapiRequiredFields.isEmpty()) { // has required fields but JSON element is null + throw new IllegalArgumentException(String.format(Locale.ROOT, "The required field(s) %s in SipCredentials is not found in the empty JSON string", SipCredentials.openapiRequiredFields.toString())); + } + } + JsonObject jsonObj = jsonElement.getAsJsonObject(); + if ((jsonObj.get("username") != null && !jsonObj.get("username").isJsonNull()) && !jsonObj.get("username").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `username` to be a primitive type in the JSON string but got `%s`", jsonObj.get("username").toString())); + } + if ((jsonObj.get("password") != null && !jsonObj.get("password").isJsonNull()) && !jsonObj.get("password").isJsonPrimitive()) { + throw new IllegalArgumentException(String.format(Locale.ROOT, "Expected the field `password` to be a primitive type in the JSON string but got `%s`", jsonObj.get("password").toString())); + } + } + + public static class CustomTypeAdapterFactory implements TypeAdapterFactory { + @SuppressWarnings("unchecked") + @Override + public TypeAdapter create(Gson gson, TypeToken type) { + if (!SipCredentials.class.isAssignableFrom(type.getRawType())) { + return null; // this class only serializes 'SipCredentials' and its subtypes + } + final TypeAdapter elementAdapter = gson.getAdapter(JsonElement.class); + final TypeAdapter thisAdapter + = gson.getDelegateAdapter(this, TypeToken.get(SipCredentials.class)); + + return (TypeAdapter) new TypeAdapter() { + @Override + public void write(JsonWriter out, SipCredentials value) throws IOException { + JsonObject obj = thisAdapter.toJsonTree(value).getAsJsonObject(); + obj.remove("additionalProperties"); + // serialize additional properties + if (value.getAdditionalProperties() != null) { + for (Map.Entry entry : value.getAdditionalProperties().entrySet()) { + if (entry.getValue() instanceof String) + obj.addProperty(entry.getKey(), (String) entry.getValue()); + else if (entry.getValue() instanceof Number) + obj.addProperty(entry.getKey(), (Number) entry.getValue()); + else if (entry.getValue() instanceof Boolean) + obj.addProperty(entry.getKey(), (Boolean) entry.getValue()); + else if (entry.getValue() instanceof Character) + obj.addProperty(entry.getKey(), (Character) entry.getValue()); + else { + JsonElement jsonElement = gson.toJsonTree(entry.getValue()); + if (jsonElement.isJsonArray()) { + obj.add(entry.getKey(), jsonElement.getAsJsonArray()); + } else { + obj.add(entry.getKey(), jsonElement.getAsJsonObject()); + } + } + } + } + elementAdapter.write(out, obj); + } + + @Override + public SipCredentials read(JsonReader in) throws IOException { + JsonElement jsonElement = elementAdapter.read(in); + validateJsonElement(jsonElement); + JsonObject jsonObj = jsonElement.getAsJsonObject(); + // store additional fields in the deserialized instance + SipCredentials instance = thisAdapter.fromJsonTree(jsonObj); + for (Map.Entry entry : jsonObj.entrySet()) { + if (!openapiFields.contains(entry.getKey())) { + if (entry.getValue().isJsonPrimitive()) { // primitive type + if (entry.getValue().getAsJsonPrimitive().isString()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsString()); + else if (entry.getValue().getAsJsonPrimitive().isNumber()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsNumber()); + else if (entry.getValue().getAsJsonPrimitive().isBoolean()) + instance.putAdditionalProperty(entry.getKey(), entry.getValue().getAsBoolean()); + else + throw new IllegalArgumentException(String.format(Locale.ROOT, "The field `%s` has unknown primitive type. Value: %s", entry.getKey(), entry.getValue().toString())); + } else if (entry.getValue().isJsonArray()) { + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), List.class)); + } else { // JSON object + instance.putAdditionalProperty(entry.getKey(), gson.fromJson(entry.getValue(), HashMap.class)); + } + } + } + return instance; + } + + }.nullSafe(); + } + } + + /** + * Create an instance of SipCredentials given an JSON string + * + * @param jsonString JSON string + * @return An instance of SipCredentials + * @throws IOException if the JSON string is invalid with respect to SipCredentials + */ + public static SipCredentials fromJson(String jsonString) throws IOException { + return JSON.getGson().fromJson(jsonString, SipCredentials.class); + } + + /** + * Convert an instance of SipCredentials to an JSON string + * + * @return JSON string + */ + public String toJson() { + return JSON.getGson().toJson(this); + } +} +