/// <summary>
 /// Returns the specified import from the specified workspace.
 /// </summary>
 /// <remarks>
 /// &lt;br/&gt;**Required scope**: Dataset.ReadWrite.All or Dataset.Read.All
 /// &lt;br/&gt;To set the permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='groupId'>
 /// The workspace id
 /// </param>
 /// <param name='importId'>
 /// The import id
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Import> GetImportInGroupAsync(this IImportsOperations operations, System.Guid groupId, System.Guid importId, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetImportInGroupWithHttpMessagesAsync(groupId, importId, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Returns a list of imports for the organization.
 /// </summary>
 /// <remarks>
 /// **Note:** The user must have administrator rights (such as Office 365
 /// Global Administrator or Power BI Service Administrator) to call this API.
 /// &lt;br/&gt;&lt;br/&gt;**Required scope**: Tenant.Read.All or
 /// Tenant.ReadWrite.All&lt;br/&gt;To set the permissions scope, see [Register
 /// an app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='expand'>
 /// Expands related entities inline
 /// </param>
 /// <param name='filter'>
 /// Filters the results, based on a boolean condition
 /// </param>
 /// <param name='top'>
 /// Returns only the first n results
 /// </param>
 /// <param name='skip'>
 /// Skips the first n results
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Imports> GetImportsAsAdminAsync(this IImportsOperations operations, string expand = default(string), string filter = default(string), int?top = default(int?), int?skip = default(int?), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetImportsAsAdminWithHttpMessagesAsync(expand, filter, top, skip, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Returns a list of imports from **"My Workspace"**.
 /// </summary>
 /// <remarks>
 /// &lt;br/&gt;**Required scope**: Dataset.ReadWrite.All or Dataset.Read.All
 /// &lt;br/&gt;To set the permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Imports> GetImportsAsync(this IImportsOperations operations, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.GetImportsWithHttpMessagesAsync(null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Creates new content on the specified workspace from .pbix, .json, Excel,
 /// Rdl, or file path in OneDrive for Business.
 /// </summary>
 /// <remarks>
 /// &lt;br/&gt;**Required scope**: Dataset.ReadWrite.All &lt;br/&gt;To set the
 /// permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// &lt;h3&gt;Notes&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;To import a file, request
 /// Headers should include **Content-Type: multipart/form-data** with the file
 /// [encoded as form data](https://www.w3.org/TR/html401/interact/forms.html)
 /// in the request body &lt;/li&gt;&lt;li&gt;To import from OneDrive for
 /// Business, request Headers should include **Content-Type: application/json**
 /// with [ImportInfo](/rest/api/power-bi/imports/postimportingroup#importinfo)
 /// in the request body.&lt;/li&gt;&lt;li&gt;To import large .pbix files
 /// between 1 GB and 10 GB see [Create Temporary Upload Location In
 /// Group](/rest/api/power-bi/imports/createtemporaryuploadlocationingroup),
 /// supported only for workspaces on premium capacity.&lt;/li&gt;&lt;li&gt;To
 /// create a dataflow from a model.json, specify the parameter
 /// datasetDisplayName as described below.&lt;/li&gt;&lt;/ul&gt;
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='groupId'>
 /// The workspace id
 /// </param>
 /// <param name='datasetDisplayName'>
 /// The display name of the dataset should include file extension. Not
 /// supported when importing from OneDrive for Business. For importing or
 /// creating dataflows, this parameter should be hardcoded to model.json.
 /// </param>
 /// <param name='importInfo'>
 /// The import to post
 /// </param>
 /// <param name='nameConflict'>
 /// Determines what to do if a dataset with the same name already exists.
 /// Default value is 'Ignore'.&lt;br/&gt;Only Abort and Overwrite are supported
 /// with Rdl files.&lt;br/&gt;Only Abort and GenerateUniqueName are supported
 /// with dataflow model.json files. Possible values include: 'Ignore', 'Abort',
 /// 'Overwrite', 'CreateOrOverwrite', 'GenerateUniqueName'
 /// </param>
 /// <param name='skipReport'>
 /// Determines whether to skip report import, if specified value must be
 /// 'true'. Only supported for PBIX files.
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <Import> PostImportInGroupAsync(this IImportsOperations operations, System.Guid groupId, string datasetDisplayName, ImportInfo importInfo, ImportConflictHandlerMode?nameConflict = default(ImportConflictHandlerMode?), bool?skipReport = default(bool?), CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.PostImportInGroupWithHttpMessagesAsync(groupId, datasetDisplayName, importInfo, nameConflict, skipReport, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
Beispiel #5
0
        /// <summary>
        /// Uploads a PBIX file to the specified group
        /// </summary>
        /// <param name="operations">
        /// The import operations
        /// </param>

        /// <param name='groupId'>
        /// The group id
        /// </param>
        /// <param name='fileStream'>
        /// The PBIX file to import
        /// </param>
        /// <param name='datasetDisplayName'>
        /// The dataset display name
        /// </param>
        /// <param name='nameConflict'>
        /// Whether to overwrite dataset during conflicts
        /// </param>
        /// <param name='skipReport'>
        /// Determines whether to skip report import, if specified value must be 'true'. Only supported for PBIX files.
        /// </param>
        /// <param name='cancellationToken'>
        /// The cancellation token.
        /// </param>
        public static async Task <Import> PostImportWithFileAsync(this IImportsOperations operations, Guid groupId, Stream fileStream, string datasetDisplayName = default(string), ImportConflictHandlerMode?nameConflict = default(ImportConflictHandlerMode?), bool?skipReport = default(bool?), CancellationToken cancellationToken = default(CancellationToken))
        {
            using (var _result = await operations.PostImportFileWithHttpMessage(groupId, fileStream, datasetDisplayName, nameConflict, skipReport, null, cancellationToken).ConfigureAwait(false))
            {
                return(_result.Body);
            }
        }
 public PowerBIClientWrapper(string workspaceName, string clientId, IImportsOperations importClient, IReportsOperations reportsClient, IGroupsOperations groupsClient)
 {
     this.ClientId      = clientId;
     this.importClient  = importClient;
     this.reportsClient = reportsClient;
     this.groupsClient  = groupsClient;
     GetWorkspaces(workspaceName);
 }
        private void InitializeClients()
        {
            AuthenticationResult result = DoInteractiveSignIn();

            client = new PowerBIClient(new Uri(PowerBIWrapperConstants.PowerBiApiUri), new TokenCredentials(result.AccessToken));

            importClient  = new ImportsOperations(client);
            reportsClient = new ReportsOperations(client);
            groupsClient  = new GroupsOperations(client);
        }
 /// <summary>
 /// Creates new content on **"My Workspace"** from .pbix, Excel, Rdl or file
 /// path in OneDrive for Business.
 /// </summary>
 /// <remarks>
 /// &lt;br/&gt;**Required scope**: Dataset.ReadWrite.All &lt;br/&gt;To set the
 /// permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// &lt;h3&gt;Notes&lt;/h3&gt;&lt;ul&gt;&lt;li&gt;To import a file, request
 /// Headers should include **Content-Type: multipart/form-data** with the file
 /// [encoded as form data](https://www.w3.org/TR/html401/interact/forms.html)
 /// in the request body. &lt;/li&gt;&lt;li&gt;To import xlsx file from OneDrive
 /// for Business, request Headers should include **Content-Type:
 /// application/json** with
 /// [ImportInfo](/rest/api/power-bi/imports/postimport#importinfo) in the
 /// request body.&lt;/li&gt;&lt;li&gt;Import .pbix file from OneDrive is not
 /// supported.&lt;/li&gt;&lt;li&gt;To import large .pbix files between 1 GB and
 /// 10 GB, see [Create Temporary Upload
 /// Location](/rest/api/power-bi/imports/createtemporaryuploadlocation),
 /// supported only for workspaces on premium capacity.&lt;/li&gt;&lt;/ul&gt;
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='datasetDisplayName'>
 /// The display name of the dataset, should include file extension. Not
 /// supported when importing from OneDrive for Business.
 /// </param>
 /// <param name='importInfo'>
 /// The import to post
 /// </param>
 /// <param name='nameConflict'>
 /// Determines what to do if a dataset with the same name already exists.
 /// Default value is 'Ignore'.&lt;br/&gt;Only Abort and Overwrite are supported
 /// with Rdl files. Possible values include: 'Ignore', 'Abort', 'Overwrite',
 /// 'CreateOrOverwrite', 'GenerateUniqueName'
 /// </param>
 /// <param name='skipReport'>
 /// Determines whether to skip report import, if specified value must be
 /// 'true'. Only supported for PBIX files.
 /// </param>
 public static Import PostImport(this IImportsOperations operations, string datasetDisplayName, ImportInfo importInfo, ImportConflictHandlerMode?nameConflict = default(ImportConflictHandlerMode?), bool?skipReport = default(bool?))
 {
     return(operations.PostImportAsync(datasetDisplayName, importInfo, nameConflict, skipReport).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Returns a list of imports for the organization.
 /// </summary>
 /// <remarks>
 /// **Note:** The user must have administrator rights (such as Office 365
 /// Global Administrator or Power BI Service Administrator) to call this API.
 /// &lt;br/&gt;&lt;br/&gt;**Required scope**: Tenant.Read.All or
 /// Tenant.ReadWrite.All&lt;br/&gt;To set the permissions scope, see [Register
 /// an app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='expand'>
 /// Expands related entities inline
 /// </param>
 /// <param name='filter'>
 /// Filters the results, based on a boolean condition
 /// </param>
 /// <param name='top'>
 /// Returns only the first n results
 /// </param>
 /// <param name='skip'>
 /// Skips the first n results
 /// </param>
 public static Imports GetImportsAsAdmin(this IImportsOperations operations, string expand = default(string), string filter = default(string), int?top = default(int?), int?skip = default(int?))
 {
     return(operations.GetImportsAsAdminAsync(expand, filter, top, skip).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Creates a temporary blob storage to be used to import large .pbix files
 /// larger than 1 GB and up to 10 GB.
 /// </summary>
 /// <remarks>
 /// To import large .pbix files, create a temporary upload location and upload
 /// the .pbix file using the shared access signature (SAS) url from the
 /// response, and then call [Post Import In
 /// Group](/rest/api/power-bi/imports/postimportingroup) and specify 'fileUrl'
 /// to be the SAS url in the [Request
 /// Body](/rest/api/power-bi/imports/postimportingroup#request-body).&lt;br/&gt;&lt;br/&gt;**Note**:
 /// Import large .pbix files is only available for workspaces on premium
 /// capacity and for .pbix files that is between 1 GB and 10 GB.
 /// &lt;br/&gt;&lt;br/&gt;**Required scope**: Dataset.ReadWrite.All
 /// &lt;br/&gt;To set the permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='groupId'>
 /// The workspace id
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <TemporaryUploadLocation> CreateTemporaryUploadLocationInGroupAsync(this IImportsOperations operations, System.Guid groupId, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.CreateTemporaryUploadLocationInGroupWithHttpMessagesAsync(groupId, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
 /// <summary>
 /// Creates a temporary blob storage to be used to import large .pbix files
 /// larger than 1 GB and up to 10 GB.
 /// </summary>
 /// <remarks>
 /// To import large .pbix files, create a temporary upload location and upload
 /// the .pbix file using the shared access signature (SAS) url from the
 /// response, and then call [Post Import In
 /// Group](/rest/api/power-bi/imports/postimportingroup) and specify 'fileUrl'
 /// to be the SAS url in the [Request
 /// Body](/rest/api/power-bi/imports/postimportingroup#request-body).&lt;br/&gt;&lt;br/&gt;**Note**:
 /// Import large .pbix files is only available for workspaces on premium
 /// capacity and for .pbix files that is between 1 GB and 10 GB.
 /// &lt;br/&gt;&lt;br/&gt;**Required scope**: Dataset.ReadWrite.All
 /// &lt;br/&gt;To set the permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='groupId'>
 /// The workspace id
 /// </param>
 public static TemporaryUploadLocation CreateTemporaryUploadLocationInGroup(this IImportsOperations operations, System.Guid groupId)
 {
     return(operations.CreateTemporaryUploadLocationInGroupAsync(groupId).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Returns the specified import from the specified workspace.
 /// </summary>
 /// <remarks>
 /// &lt;br/&gt;**Required scope**: Dataset.ReadWrite.All or Dataset.Read.All
 /// &lt;br/&gt;To set the permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='groupId'>
 /// The workspace id
 /// </param>
 /// <param name='importId'>
 /// The import id
 /// </param>
 public static Import GetImportInGroup(this IImportsOperations operations, System.Guid groupId, System.Guid importId)
 {
     return(operations.GetImportInGroupAsync(groupId, importId).GetAwaiter().GetResult());
 }
 /// <summary>
 /// Returns a list of imports from **"My Workspace"**.
 /// </summary>
 /// <remarks>
 /// &lt;br/&gt;**Required scope**: Dataset.ReadWrite.All or Dataset.Read.All
 /// &lt;br/&gt;To set the permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static Imports GetImports(this IImportsOperations operations)
 {
     return(operations.GetImportsAsync().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Creates a temporary blob storage to be used to import large .pbix files
 /// larger than 1 GB and up to 10 GB.
 /// </summary>
 /// <remarks>
 /// To import large .pbix files, create a temporary upload location and upload
 /// the .pbix file using the shared access signature (SAS) url from the
 /// response, and then call [Post
 /// Import](/rest/api/power-bi/imports/postimport) and specify 'fileUrl' to be
 /// the SAS url in the [Request
 /// Body](/rest/api/power-bi/imports/postimport#request-body)&lt;br/&gt;&lt;br/&gt;**Note**:
 /// Import large .pbix files is only available for workspaces on premium
 /// capacity and for .pbix files that are between 1 GB and 10 GB.
 /// &lt;br/&gt;&lt;br/&gt;**Required scope**: Dataset.ReadWrite.All
 /// &lt;br/&gt;To set the permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 public static TemporaryUploadLocation CreateTemporaryUploadLocation(this IImportsOperations operations)
 {
     return(operations.CreateTemporaryUploadLocationAsync().GetAwaiter().GetResult());
 }
 /// <summary>
 /// Returns the specified import from **"My Workspace"**.
 /// </summary>
 /// <remarks>
 /// &lt;br/&gt;**Required scope**: Dataset.ReadWrite.All or Dataset.Read.All
 /// &lt;br/&gt;To set the permissions scope, see [Register an
 /// app](https://docs.microsoft.com/power-bi/developer/register-app).
 /// </remarks>
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='importId'>
 /// The import id
 /// </param>
 public static Import GetImport(this IImportsOperations operations, System.Guid importId)
 {
     return(operations.GetImportAsync(importId).GetAwaiter().GetResult());
 }
Beispiel #16
0
 /// <summary>
 /// Uploads a PBIX file to the specified group
 /// </summary>
 /// <param name="operations">
 /// The import operations
 /// </param>
 /// <param name='groupId'>
 /// The group id
 /// </param>
 /// <param name='fileStream'>
 /// The PBIX file to import
 /// </param>
 /// <param name='datasetDisplayName'>
 /// The dataset display name
 /// </param>
 /// <param name='nameConflict'>
 /// Whether to overwrite dataset during conflicts
 /// </param>
 /// <param name='skipReport'>
 /// Determines whether to skip report import, if specified value must be 'true'. Only supported for PBIX files.
 /// </param>
 public static Import PostImportWithFile(this IImportsOperations operations, Guid groupId, Stream fileStream, string datasetDisplayName = default(string), ImportConflictHandlerMode?nameConflict = default(ImportConflictHandlerMode?), bool?skipReport = default(bool?))
 {
     return(Task.Factory.StartNew(s => ((IImportsOperations)s).PostImportFileWithHttpMessage(groupId, fileStream, datasetDisplayName, nameConflict, skipReport), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult().Body);
 }