Skip to content

Commit

Permalink
Email service data plane operations - Send email and get email send s…
Browse files Browse the repository at this point in the history
…tatus (#25431)

* Email services data plane operations

* Email Service data plane - added examples

* Email Service pipeline issue fix

* Pipeline issue fix

* Updated the module name to EmailServicedata

* Email Service data plane - updated test scenarios

* Revert "Email Service data plane - updated test scenarios"

This reverts commit 15c7974.

* Email Service data plane - Updated test scenarios
  • Loading branch information
v-vprasannak authored Jul 30, 2024
1 parent bdbc966 commit d950ce1
Show file tree
Hide file tree
Showing 25 changed files with 2,112 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/Communication/EmailServicedata.Autorest/.gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* text=auto
16 changes: 16 additions & 0 deletions src/Communication/EmailServicedata.Autorest/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
bin
obj
.vs
generated
internal
exports
tools
custom/*.psm1
custom/autogen-model-cmdlets
test/*-TestResults.xml
/*.ps1
/*.ps1xml
/*.psm1
/*.snk
/*.csproj
/*.nuspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
@{
GUID = '5168d495-7a9d-45d6-ab8f-9127f05ee378'
RootModule = './Az.EmailServicedata.psm1'
ModuleVersion = '0.1.0'
CompatiblePSEditions = 'Core', 'Desktop'
Author = 'Microsoft Corporation'
CompanyName = 'Microsoft Corporation'
Copyright = 'Microsoft Corporation. All rights reserved.'
Description = 'Microsoft Azure PowerShell: EmailServicedata cmdlets'
PowerShellVersion = '5.1'
DotNetFrameworkVersion = '4.7.2'
RequiredAssemblies = './bin/Az.EmailServicedata.private.dll'
FormatsToProcess = './Az.EmailServicedata.format.ps1xml'
FunctionsToExport = 'Get-AzEmailServicedataEmailSendResult', 'Send-AzEmailServicedataEmail'
PrivateData = @{
PSData = @{
Tags = 'Azure', 'ResourceManager', 'ARM', 'PSModule', 'EmailServicedata'
LicenseUri = 'https://aka.ms/azps-license'
ProjectUri = 'https://github.com/Azure/azure-powershell'
ReleaseNotes = ''
}
}
}
79 changes: 79 additions & 0 deletions src/Communication/EmailServicedata.Autorest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<!-- region Generated -->
# Az.EmailServicedata
This directory contains the PowerShell module for the EmailServicedata service.

---
## Info
- Modifiable: yes
- Generated: all
- Committed: yes
- Packaged: yes

---
## Detail
This module was primarily generated via [AutoRest](https://github.com/Azure/autorest) using the [PowerShell](https://github.com/Azure/autorest.powershell) extension.

## Module Requirements
- [Az.Accounts module](https://www.powershellgallery.com/packages/Az.Accounts/), version 2.7.5 or greater

## Authentication
AutoRest does not generate authentication code for the module. Authentication is handled via Az.Accounts by altering the HTTP payload before it is sent.

## Development
For information on how to develop for `Az.EmailServicedata`, see [how-to.md](how-to.md).
<!-- endregion -->

### AutoRest Configuration
> see https://aka.ms/autorest
``` yaml
commit: 512e966e15cd8e6ffd756279971c478702f4e19e
require:
# readme.azure.noprofile.md is the common configuration file
- $(this-folder)/../../readme.azure.noprofile.md
input-file:
# You need to specify your swagger files here.
- $(repo)/specification/communication/data-plane/Email/stable/2023-03-31/CommunicationServicesEmail.json
# If the swagger has not been put in the repo, you may uncomment the following line and refer to it locally
# - (this-folder)/relative-path-to-your-swagger

root-module-name: $(prefix).Communication
# For new RP, the version is 0.1.0
module-version: 0.1.0
# Normally, title is the service name
title: EmailServicedata
subject-prefix: $(service-name)

# If there are post APIs for some kinds of actions in the RP, you may need to
# uncomment following line to support viaIdentity for these post APIs
identity-correction-for-post: true
resourcegroup-append: true
nested-object-to-string: true
endpoint-resource-id-key-name: AzureCommunicationEmailEndpointResourceId

directive:
# [swagger] change the final-state-via to align with service response
- from: swagger-document
where: $.paths["/emails:send"].post["x-ms-long-running-operation-options"]
transform: $["final-state-via"] = "operation-location"

# Add 200 status code.
- from: swagger-document
where: $.paths["/emails:send"].post.responses
transform: >-
return {
"200": {
"description": "Message status was successfully retrieved.",
"headers": {
"retry-after": {
"description": "This header will only be present when the status is a non-terminal status. It indicates the minimum amount of time in seconds to wait before polling for operation status again.",
"type": "integer",
"format": "int32"
}
},
"schema": {
"$ref": "#/definitions/EmailSendResult"
}
}
}
```
41 changes: 41 additions & 0 deletions src/Communication/EmailServicedata.Autorest/custom/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# Custom
This directory contains custom implementation for non-generated cmdlets for the `Az.EmailServicedata` module. Both scripts (`.ps1`) and C# files (`.cs`) can be implemented here. They will be used during the build process in `build-module.ps1`, and create cmdlets into the `..\exports` folder. The only generated file into this folder is the `Az.EmailServicedata.custom.psm1`. This file should not be modified.

## Info
- Modifiable: yes
- Generated: partial
- Committed: yes
- Packaged: yes

## Details
For `Az.EmailServicedata` to use custom cmdlets, it does this two different ways. We **highly recommend** creating script cmdlets, as they are easier to write and allow access to the other exported cmdlets. C# cmdlets *cannot access exported cmdlets*.

For C# cmdlets, they are compiled with the rest of the generated low-level cmdlets into the `./bin/Az.EmailServicedata.private.dll`. The names of the cmdlets (methods) and files must follow the `[cmdletName]_[variantName]` syntax used for generated cmdlets. The `variantName` is used as the `ParameterSetName`, so use something appropriate that doesn't clash with already created variant or parameter set names. You cannot use the `ParameterSetName` property in the `Parameter` attribute on C# cmdlets. Each cmdlet must be separated into variants using the same pattern as seen in the `generated/cmdlets` folder.

For script cmdlets, these are loaded via the `Az.EmailServicedata.custom.psm1`. Then, during the build process, this module is loaded and processed in the same manner as the C# cmdlets. The fundamental difference is the script cmdlets use the `ParameterSetName` attribute and C# cmdlets do not. To create a script cmdlet variant of a generated cmdlet, simply decorate all parameters in the script with the new `ParameterSetName` in the `Parameter` attribute. This will appropriately treat each parameter set as a separate variant when processed to be exported during the build.

## Purpose
This allows the modules to have cmdlets that were not defined in the REST specification. It also allows combining logic using generated cmdlets. This is a level of customization beyond what can be done using the [readme configuration options](https://github.com/Azure/autorest/blob/master/docs/powershell/options.md) that are currently available. These custom cmdlets are then referenced by the cmdlets created at build-time in the `..\exports` folder.

## Usage
The easiest way currently to start developing custom cmdlets is to copy an existing cmdlet. For C# cmdlets, copy one from the `generated/cmdlets` folder. For script cmdlets, build the project using `build-module.ps1` and copy one of the scripts from the `..\exports` folder. After that, if you want to add new parameter sets, follow the guidelines in the `Details` section above. For implementing a new cmdlets, at minimum, please keep these parameters:
- Break
- DefaultProfile
- HttpPipelineAppend
- HttpPipelinePrepend
- Proxy
- ProxyCredential
- ProxyUseDefaultCredentials

These provide functionality to our HTTP pipeline and other useful features. In script, you can forward these parameters using `$PSBoundParameters` to the other cmdlets you're calling within `Az.EmailServicedata`. For C#, follow the usage seen in the `ProcessRecordAsync` method.

### Attributes
For processing the cmdlets, we've created some additional attributes:
- `Microsoft.Azure.PowerShell.Cmdlets.EmailServicedata.DescriptionAttribute`
- Used in C# cmdlets to provide a high-level description of the cmdlet. This is propagated to reference documentation via [help comments](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) in the exported scripts.
- `Microsoft.Azure.PowerShell.Cmdlets.EmailServicedata.DoNotExportAttribute`
- Used in C# and script cmdlets to suppress creating an exported cmdlet at build-time. These cmdlets will *not be exposed* by `Az.EmailServicedata`.
- `Microsoft.Azure.PowerShell.Cmdlets.EmailServicedata.InternalExportAttribute`
- Used in C# cmdlets to route exported cmdlets to the `..\internal`, which are *not exposed* by `Az.EmailServicedata`. For more information, see [README.md](..\internal/README.md) in the `..\internal` folder.
- `Microsoft.Azure.PowerShell.Cmdlets.EmailServicedata.ProfileAttribute`
- Used in C# and script cmdlets to define which Azure profiles the cmdlet supports. This is only supported for Azure (`--azure`) modules.
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
Module Name: Az.EmailServicedata
Module Guid: 5168d495-7a9d-45d6-ab8f-9127f05ee378
Download Help Link: https://learn.microsoft.com/powershell/module/az.emailservicedata
Help Version: 1.0.0.0
Locale: en-US
---

# Az.EmailServicedata Module
## Description
Microsoft Azure PowerShell: EmailServicedata cmdlets

## Az.EmailServicedata Cmdlets
### [Get-AzEmailServicedataEmailSendResult](Get-AzEmailServicedataEmailSendResult.md)
Gets the status of the email send operation.

### [Send-AzEmailServicedataEmail](Send-AzEmailServicedataEmail.md)
Queues an email message to be sent to one or more recipients

Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
---
external help file:
Module Name: Az.Communication
online version: https://learn.microsoft.com/powershell/module/az.communication/get-azemailservicedataemailsendresult
schema: 2.0.0
---

# Get-AzEmailServicedataEmailSendResult

## SYNOPSIS
Gets the status of the email send operation.

## SYNTAX

### Get (Default)
```
Get-AzEmailServicedataEmailSendResult -Endpoint <String> -OperationId <String> [-DefaultProfile <PSObject>]
[<CommonParameters>]
```

### GetViaIdentity
```
Get-AzEmailServicedataEmailSendResult -Endpoint <String> -InputObject <IEmailServicedataIdentity>
[-DefaultProfile <PSObject>] [<CommonParameters>]
```

## DESCRIPTION
Gets the status of the email send operation.

## EXAMPLES

### Example 1: Gets the status and operation id of the email send operation.
```powershell
Get-AzEmailServicedataEmailSendResult -Endpoint "https://contoso.unitedstates.communication.azure.com" -OperationId 1111c0de-899f-5cce-acb5-3ec493af3800
```

```output
AdditionalInfo :
Code :
Detail :
Id : 1111c0de-899f-5cce-acb5-3ec493af3800
Message :
ResourceGroupName :
RetryAfter :
Status : Succeeded
Target :
```

Returns a status and operation id of the email send operation.

## PARAMETERS

### -DefaultProfile
The DefaultProfile parameter is not functional.
Use the SubscriptionId parameter when available if executing the cmdlet against a different subscription.

```yaml
Type: System.Management.Automation.PSObject
Parameter Sets: (All)
Aliases: AzureRMContext, AzureCredential

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -Endpoint
The communication resource, for example https://my-resource.communication.azure.com
```yaml
Type: System.String
Parameter Sets: (All)
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### -InputObject
Identity Parameter
```yaml
Type: Microsoft.Azure.PowerShell.Cmdlets.EmailServicedata.Models.IEmailServicedataIdentity
Parameter Sets: GetViaIdentity
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
```
### -OperationId
ID of the long running operation (GUID) returned from a previous call to send email
```yaml
Type: System.String
Parameter Sets: Get
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```
### CommonParameters
This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutVariable, -OutBuffer, -PipelineVariable, -Verbose, -WarningAction, and -WarningVariable. For more information, see [about_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).
## INPUTS
### Microsoft.Azure.PowerShell.Cmdlets.EmailServicedata.Models.IEmailServicedataIdentity
## OUTPUTS
### Microsoft.Azure.PowerShell.Cmdlets.EmailServicedata.Models.IEmailSendResult
## NOTES
## RELATED LINKS
11 changes: 11 additions & 0 deletions src/Communication/EmailServicedata.Autorest/docs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Docs
This directory contains the documentation of the cmdlets for the `Az.EmailServicedata` module. To run documentation generation, use the `generate-help.ps1` script at the root module folder. Files in this folder will *always be overridden on regeneration*. To update documentation examples, please use the `..\examples` folder.

## Info
- Modifiable: no
- Generated: all
- Committed: yes
- Packaged: yes

## Details
The process of documentation generation loads `Az.EmailServicedata` and analyzes the exported cmdlets from the module. It recognizes the [help comments](https://learn.microsoft.com/powershell/module/microsoft.powershell.core/about/about_comment_based_help) that are generated into the scripts in the `..\exports` folder. Additionally, when writing custom cmdlets in the `..\custom` folder, you can use the help comments syntax, which decorate the exported scripts at build-time. The documentation examples are taken from the `..\examples` folder.
Loading

0 comments on commit d950ce1

Please sign in to comment.