// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
// Code generated by Microsoft (R) AutoRest Code Generator.

package com.azure.analytics.purview.sharing;

import com.azure.core.annotation.Generated;
import com.azure.core.annotation.ReturnType;
import com.azure.core.annotation.ServiceClient;
import com.azure.core.annotation.ServiceMethod;
import com.azure.core.exception.ClientAuthenticationException;
import com.azure.core.exception.HttpResponseException;
import com.azure.core.exception.ResourceModifiedException;
import com.azure.core.exception.ResourceNotFoundException;
import com.azure.core.http.rest.PagedIterable;
import com.azure.core.http.rest.RequestOptions;
import com.azure.core.http.rest.Response;
import com.azure.core.util.BinaryData;
import com.azure.core.util.polling.SyncPoller;

/** Initializes a new instance of the synchronous PurviewShareClient type. */
@ServiceClient(builder = ReceivedSharesClientBuilder.class)
public final class ReceivedSharesClient {
    @Generated private final ReceivedSharesAsyncClient client;

    /**
     * Initializes an instance of ReceivedSharesClient class.
     *
     * @param client the async client.
     */
    @Generated
    ReceivedSharesClient(ReceivedSharesAsyncClient client) {
        this.client = client;
    }

    /**
     * Get a received share by unique id.
     *
     * <p>Get a received share.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     type: String (Optional)
     * }
     * }</pre>
     *
     * @param receivedShareId Id of the received share.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a received share along with {@link Response}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> getReceivedShareWithResponse(String receivedShareId, RequestOptions requestOptions) {
        return this.client.getReceivedShareWithResponse(receivedShareId, requestOptions).block();
    }

    /**
     * Create or replace a received share.
     *
     * <p>Update changes to a received share.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     type: String (Optional)
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     type: String (Optional)
     * }
     * }</pre>
     *
     * @param receivedShareId Id of the received share.
     * @param receivedShare The received share to create or replace.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link SyncPoller} for polling of a received share data transfer object.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<BinaryData, BinaryData> beginCreateOrReplaceReceivedShare(
            String receivedShareId, BinaryData receivedShare, RequestOptions requestOptions) {
        return this.client
                .beginCreateOrReplaceReceivedShare(receivedShareId, receivedShare, requestOptions)
                .getSyncPoller();
    }

    /**
     * Deletes a received share
     *
     * <p>Delete a received share.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     endTime: OffsetDateTime (Optional)
     *     error (Optional): {
     *         code: String (Required)
     *         details (Optional): [
     *             (recursive schema, see above)
     *         ]
     *         message: String (Required)
     *         target: String (Optional)
     *     }
     *     id: String (Optional)
     *     startTime: OffsetDateTime (Optional)
     *     status: String(Running/TransientFailure/Succeeded/Failed/NotStarted) (Required)
     * }
     * }</pre>
     *
     * @param receivedShareId Id of the received share.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return the {@link SyncPoller} for polling of response for long running operation.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.LONG_RUNNING_OPERATION)
    public SyncPoller<BinaryData, Void> beginDeleteReceivedShare(
            String receivedShareId, RequestOptions requestOptions) {
        return this.client.beginDeleteReceivedShare(receivedShareId, requestOptions).getSyncPoller();
    }

    /**
     * Get a list of attached received shares.
     *
     * <p>List attached received shares.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>filter</td><td>String</td><td>No</td><td>Filters the results using OData syntax</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>Sorts the results using OData syntax</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     type: String (Optional)
     * }
     * }</pre>
     *
     * @param referenceName A name that references a data store.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return list of received shares as paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listAttachedReceivedShares(String referenceName, RequestOptions requestOptions) {
        return new PagedIterable<>(this.client.listAttachedReceivedShares(referenceName, requestOptions));
    }

    /**
     * Get a list of detached received shares.
     *
     * <p>List detached received shares.
     *
     * <p><strong>Query Parameters</strong>
     *
     * <table border="1">
     *     <caption>Query Parameters</caption>
     *     <tr><th>Name</th><th>Type</th><th>Required</th><th>Description</th></tr>
     *     <tr><td>filter</td><td>String</td><td>No</td><td>Filters the results using OData syntax</td></tr>
     *     <tr><td>orderby</td><td>String</td><td>No</td><td>Sorts the results using OData syntax</td></tr>
     * </table>
     *
     * You can add these to a request with {@link RequestOptions#addQueryParam}
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     type: String (Optional)
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return list of received shares as paginated response with {@link PagedIterable}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.COLLECTION)
    public PagedIterable<BinaryData> listDetachedReceivedShares(RequestOptions requestOptions) {
        return new PagedIterable<>(this.client.listDetachedReceivedShares(requestOptions));
    }

    /**
     * Activates the tenant and email combination using the activation code received.
     *
     * <p>Activates the email registration for current tenant.
     *
     * <p><strong>Request Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     type: String (Optional)
     *     properties (Optional): {
     *         activationCode: String (Required)
     *         activationExpiration: OffsetDateTime (Optional)
     *         email: String (Optional)
     *         registrationStatus: String(ActivationPending/Activated/ActivationAttemptsExhausted) (Optional)
     *         state: String(Unknown/Succeeded/Creating/Deleting/Moving/Failed) (Optional)
     *         tenantId: String (Optional)
     *     }
     * }
     * }</pre>
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     type: String (Optional)
     *     properties (Optional): {
     *         activationCode: String (Required)
     *         activationExpiration: OffsetDateTime (Optional)
     *         email: String (Optional)
     *         registrationStatus: String(ActivationPending/Activated/ActivationAttemptsExhausted) (Optional)
     *         state: String(Unknown/Succeeded/Creating/Deleting/Moving/Failed) (Optional)
     *         tenantId: String (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param tenantEmailRegistration The tenant email registration payload.
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a tenant email registration data transfer object along with {@link Response}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> activateTenantEmailRegistrationWithResponse(
            BinaryData tenantEmailRegistration, RequestOptions requestOptions) {
        return this.client.activateTenantEmailRegistrationWithResponse(tenantEmailRegistration, requestOptions).block();
    }

    /**
     * Registers the tenant and email combination for activation.
     *
     * <p>Register an email for the current tenant.
     *
     * <p><strong>Response Body Schema</strong>
     *
     * <pre>{@code
     * {
     *     id: String (Optional)
     *     type: String (Optional)
     *     properties (Optional): {
     *         activationCode: String (Required)
     *         activationExpiration: OffsetDateTime (Optional)
     *         email: String (Optional)
     *         registrationStatus: String(ActivationPending/Activated/ActivationAttemptsExhausted) (Optional)
     *         state: String(Unknown/Succeeded/Creating/Deleting/Moving/Failed) (Optional)
     *         tenantId: String (Optional)
     *     }
     * }
     * }</pre>
     *
     * @param requestOptions The options to configure the HTTP request before HTTP client sends it.
     * @throws HttpResponseException thrown if the request is rejected by server.
     * @throws ClientAuthenticationException thrown if the request is rejected by server on status code 401.
     * @throws ResourceNotFoundException thrown if the request is rejected by server on status code 404.
     * @throws ResourceModifiedException thrown if the request is rejected by server on status code 409.
     * @return a tenant email registration data transfer object along with {@link Response}.
     */
    @Generated
    @ServiceMethod(returns = ReturnType.SINGLE)
    public Response<BinaryData> registerTenantEmailRegistrationWithResponse(RequestOptions requestOptions) {
        return this.client.registerTenantEmailRegistrationWithResponse(requestOptions).block();
    }
}
