Skip to content

Commit

Permalink
!deploy v2.23.0 to resolve #152
Browse files Browse the repository at this point in the history
## 2.23.0

* [Issue #152](#152)
  * Added full coverage of `Gmail.Settings.SendAs` resource (where signatures are managed with the newer Gmail API):
    * Added: `Get-GSGmailSendAsAlias`
    * Added: `Update-GSGmailSendAsAlias`
    * Added: `Get-GSGmailSignature` (aliased to `Get-GSGmailSendAsAlias`)
    * Added: `Update-GSGmailSignature` (aliased to `Update-GSGmailSendAsAlias` with some additional convenience parameters)
    * Added: `Get-GSGmailSendAsSettings` (aliased to `Get-GSGmailSendAsAlias`)
    * Added: `Update-GSGmailSendAsSettings` (aliased to `Update-GSGmailSendAsAlias`)
    * Added: `Remove-GSGmailSendAsAlias`
    * Added: `New-GSGmailSendAsAlias`
    * Added: `Send-GSGmailSendAsConfirmation`
  • Loading branch information
scrthq authored Feb 27, 2019
2 parents 5618d38 + b595c24 commit 702737e
Show file tree
Hide file tree
Showing 60 changed files with 780 additions and 33 deletions.
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# Changelog

* [Changelog](#changelog)
* [2.23.0](#2230)
* [2.22.4](#2224)
* [2.22.3](#2223)
* [2.22.2](#2222)
Expand Down Expand Up @@ -73,6 +74,20 @@

***

## 2.23.0

* [Issue #152](https://github.com/scrthq/PSGSuite/issues/152)
* Added full coverage of `Gmail.Settings.SendAs` resource (where signatures are managed with the newer Gmail API):
* Added: `Get-GSGmailSendAsAlias`
* Added: `Update-GSGmailSendAsAlias`
* Added: `Get-GSGmailSignature` (aliased to `Get-GSGmailSendAsAlias`)
* Added: `Update-GSGmailSignature` (aliased to `Update-GSGmailSendAsAlias` with some additional convenience parameters)
* Added: `Get-GSGmailSendAsSettings` (aliased to `Get-GSGmailSendAsAlias`)
* Added: `Update-GSGmailSendAsSettings` (aliased to `Update-GSGmailSendAsAlias`)
* Added: `Remove-GSGmailSendAsAlias`
* Added: `New-GSGmailSendAsAlias`
* Added: `Send-GSGmailSendAsConfirmation`

## 2.22.4

* [Issue #147](https://github.com/scrthq/PSGSuite/issues/147)
Expand Down
74 changes: 56 additions & 18 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
<!-- TOC -->

* [Contributing to PSGSuite](#contributing-to-psgsuite)
* [Git and Pull requests](#git-and-pull-requests)
* [Overview](#overview)
* [Step by Step (High-Level)](#step-by-step-high-level)
* [Contributing Guidelines](#contributing-guidelines)
* [Updating the Wiki](#updating-the-wiki)
* [Getting Started](#getting-started)
* [Enabling Debug Mode](#enabling-debug-mode)
* [Google .NET SDK Documentation](#google-net-sdk-documentation)
* [.NET/API Documentation Links](#netapi-documentation-links)
* [Keeping in Touch](#keeping-in-touch)
* [Git and Pull requests](#git-and-pull-requests)
* [Overview](#overview)
* [Step by Step (High-Level)](#step-by-step-high-level)
* [Contributing Guidelines](#contributing-guidelines)
* [Updating the Wiki](#updating-the-wiki)
* [Getting Started](#getting-started)
* [Enabling Debug Mode](#enabling-debug-mode)
* [Google .NET SDK Documentation](#google-net-sdk-documentation)
* [.NET/API Documentation Links](#netapi-documentation-links)
* [Keeping in Touch](#keeping-in-touch)

<!-- /TOC -->

Expand Down Expand Up @@ -123,19 +123,57 @@ Here are some links to the most commonly used SDK's and API's in PSGSuite:
* **Admin SDK: Directory API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/admin/directory_v1/csharp/latest/index.html)
* [API Documentation](https://developers.google.com/admin-sdk/directory/v1/reference/)
* **Drive SDK**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/drive/v3/csharp/latest/)
* [API Documentation](https://developers.google.com/drive/api/v3/reference/)
* **Sheets API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/sheets/v4/csharp/latest/)
* [API Documentation](https://developers.google.com/sheets/api/reference/rest/)
* **Apps Activity API - Updating to Drive Activity API v2 (new name) - Sunset scheduled December 2019**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/appsactivity/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/drive/activity/v1/reference/)
* **Contacts API - To be replaced soon with People API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/contacts/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/contacts/v3/reference)
* **Drive Activity API v2**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/driveactivity/v2/csharp/latest/)
* [API Documentation](https://developers.google.com/drive/activity/v2/reference/rest/)
* **Enterprise License Manager API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/licensing/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/admin-sdk/licensing/v1/reference/)
* **Gmail API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/gmail/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/gmail/api/v1/reference/)
* **Calendar API**
* **Google Calendar API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/calendar/v3/csharp/latest/)
* [API Documentation](https://developers.google.com/calendar/v3/reference/)
* **Google Classroom API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/classroom/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/classroom/reference/rest/)
* **Google Docs API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/docs/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/docs/api/reference/rest/)
* **Google Drive API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/drive/v3/csharp/latest/)
* [API Documentation](https://developers.google.com/drive/api/v3/reference/)
* **Google Sheets API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/sheets/v4/csharp/latest/)
* [API Documentation](https://developers.google.com/sheets/api/reference/rest/)
* **Google Slides API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/slides/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/slides/reference/rest/)
* **Groups Settings API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/groupssettings/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/admin-sdk/groups-settings/v1/reference/groups)
* **Hangouts Chat API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/chat/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/hangouts/chat/reference/)
* **People API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/people/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/people/api/rest/)
* **Tasks API**
* [.NET SDK Documentation](https://developers.google.com/resources/api-libraries/documentation/tasks/v1/csharp/latest/)
* [API Documentation](https://developers.google.com/tasks/v1/reference/)


## Keeping in Touch

For any questions, comments or concerns outside of opening an issue, please join us in the `#psgsuite` channel on the SCRT HQ Slack; Team: `scrthq.slack.com`. [Click here](https://scrthq-slack-invite.herokuapp.com/) to get an invite!
For any questions, comments or concerns outside of opening an issue, please reach out:
* on the SCRT HQ Slack: `scrthq.slack.com`. [Click here](https://scrthq-slack-invite.herokuapp.com/) to get an invite!
* on the SCRT HQ Discord: [Click here](https://discord.gg/G66zVG7) to get an invite!
* `@scrthq` on the [PowerShell Slack](http://slack.poshcode.org/) if you're on there as well!
* [`@scrthq`](https://twitter.com/scrthq) on Twitter
3 changes: 3 additions & 0 deletions PSGSuite/Aliases/PSGSuite.Aliases.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,7 @@
'Switch-PSGSuiteDomain' = 'Switch-PSGSuiteConfig'
'Update-GSCalendarResource' = 'Update-GSResource'
'Update-GSSheetValue' = 'Export-GSSheet'
'Get-GSGmailSignature' = 'Get-GSGmailSendAsAlias'
'Get-GSGmailSendAsSettings' = 'Get-GSGmailSendAsAlias'
'Update-GSGmailSendAsSettings' = 'Update-GSGmailSendAsAlias'
}
2 changes: 1 addition & 1 deletion PSGSuite/PSGSuite.psd1
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
RootModule = 'PSGSuite.psm1'

# Version number of this module.
ModuleVersion = '2.22.4'
ModuleVersion = '2.23.0'

# ID used to uniquely identify this module
GUID = '9d751152-e83e-40bb-a6db-4c329092aaec'
Expand Down
84 changes: 84 additions & 0 deletions PSGSuite/Public/Gmail/Get-GSGmailSendAsAlias.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
function Get-GSGmailSendAsAlias {
<#
.SYNOPSIS
Gets SendAs alias settings for a user.
.DESCRIPTION
Gets SendAs alias settings for a user.
.PARAMETER SendAsEmail
The SendAs alias to be retrieved.
If excluded, gets the list of SendAs aliases.
.PARAMETER User
The email of the user you are getting the information for
.EXAMPLE
Get-GSGmailSendAsSettings -User [email protected]
Gets the list of SendAs Settings for Joe
#>
[OutputType('Google.Apis.Gmail.v1.Data.SendAs')]
[cmdletbinding()]
Param (
[parameter(Mandatory = $false,Position = 0,ValueFromPipelineByPropertyName = $true)]
[Alias("SendAs")]
[string[]]
$SendAsEmail,
[parameter(Mandatory = $false,ValueFromPipelineByPropertyName = $true)]
[Alias("PrimaryEmail","UserKey","Mail")]
[ValidateNotNullOrEmpty()]
[string]
$User = $Script:PSGSuite.AdminEmail
)
Process {
if ($User -ceq 'me') {
$User = $Script:PSGSuite.AdminEmail
}
elseif ($User -notlike "*@*.*") {
$User = "$($User)@$($Script:PSGSuite.Domain)"
}
$serviceParams = @{
Scope = 'https://www.googleapis.com/auth/gmail.settings.basic'
ServiceType = 'Google.Apis.Gmail.v1.GmailService'
User = $User
}
$service = New-GoogleService @serviceParams
if ($PSBoundParameters.ContainsKey('SendAsEmail')) {
foreach ($sendAs in $SendAsEmail) {
try {
if ($sendAs -notlike "*@*.*") {
$sendAs = "$($sendAs)@$($Script:PSGSuite.Domain)"
}
$request = $service.Users.Settings.SendAs.Get($User,$sendAs)
Write-Verbose "Getting SendAs settings of alias '$sendAs' for user '$User'"
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
else {
try {
$request = $service.Users.Settings.SendAs.List($User)
Write-Verbose "Getting SendAs List for user '$User'"
$request.Execute() | Select-Object -ExpandProperty SendAs | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
}
124 changes: 124 additions & 0 deletions PSGSuite/Public/Gmail/New-GSGmailSendAsAlias.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
function New-GSGmailSendAsAlias {
<#
.SYNOPSIS
Creates a new SendAs alias for a user.
.DESCRIPTION
Creates a new SendAs alias for a user.
.PARAMETER User
The user to create the SendAs alias for.
.PARAMETER SendAsEmail
The email address that appears in the "From:" header for mail sent using this alias.
.PARAMETER DisplayName
A name that appears in the "From:" header for mail sent using this alias.
For custom "from" addresses, when this is empty, Gmail will populate the "From:" header with the name that is used for the primary address associated with the account.
If the admin has disabled the ability for users to update their name format, requests to update this field for the primary login will silently fail.
.PARAMETER IsDefault
Whether this address is selected as the default "From:" address in situations such as composing a new message or sending a vacation auto-reply.
Every Gmail account has exactly one default send-as address, so the only legal value that clients may write to this field is true.
Changing this from false to true for an address will result in this field becoming false for the other previous default address.
.PARAMETER ReplyToAddress
An optional email address that is included in a "Reply-To:" header for mail sent using this alias.
If this is empty, Gmail will not generate a "Reply-To:" header.
.PARAMETER Signature
An optional HTML signature that is included in messages composed with this alias in the Gmail web UI.
.PARAMETER SmtpMsa
An optional SMTP service that will be used as an outbound relay for mail sent using this alias.
If this is empty, outbound mail will be sent directly from Gmail's servers to the destination SMTP service. This setting only applies to custom "from" aliases.
Use the helper function Add-GmailSmtpMsa to create the correct object for this parameter.
.PARAMETER TreatAsAlias
Whether Gmail should treat this address as an alias for the user's primary email address.
This setting only applies to custom "from" aliases.
.EXAMPLE
$smtpMsa = Add-GSGmailSmtpMsa -Host 10.0.30.18 -Port 3770 -SecurityMode none -Username mailadmin -Password $(ConvertTo-SecureString $password -AsPlainText -Force)
New-GSGmailSendAsAlias -SendAsEmail [email protected] -User [email protected] -Signature "<div>Thank you for your time,</br>Joseph Wiggum</div>" -SmtpMsa $smtpMsa
Creates a new SendAs alias for Joe's formal/work address including signature and SmtpMsa settings.
#>
[OutputType('Google.Apis.Gmail.v1.Data.SendAs')]
[cmdletbinding()]
Param (
[parameter(Mandatory = $true,ValueFromPipelineByPropertyName = $true)]
[Alias("PrimaryEmail","UserKey","Mail")]
[ValidateNotNullOrEmpty()]
[string]
$User,
[parameter(Mandatory = $true)]
[string]
$SendAsEmail,
[parameter(Mandatory = $false)]
[string]
$DisplayName,
[parameter(Mandatory = $false)]
[switch]
$IsDefault,
[parameter(Mandatory = $false)]
[string]
$ReplyToAddress,
[parameter(Mandatory = $false)]
[string]
$Signature,
[parameter(Mandatory = $false)]
[Google.Apis.Gmail.v1.Data.SmtpMsa]
$SmtpMsa,
[parameter(Mandatory = $false)]
[switch]
$TreatAsAlias
)
Process {
if ($User -ceq 'me') {
$User = $Script:PSGSuite.AdminEmail
}
elseif ($User -notlike "*@*.*") {
$User = "$($User)@$($Script:PSGSuite.Domain)"
}
if (-not $PSBoundParameters.ContainsKey('SendAsEmail')) {
$SendAsEmail = $User
}
elseif ($SendAsEmail -notlike "*@*.*") {
$SendAsEmail = "$($SendAsEmail)@$($Script:PSGSuite.Domain)"
}
$serviceParams = @{
Scope = @(
'https://www.googleapis.com/auth/gmail.settings.sharing'
)
ServiceType = 'Google.Apis.Gmail.v1.GmailService'
User = $User
}
$service = New-GoogleService @serviceParams
try {
$body = New-Object 'Google.Apis.Gmail.v1.Data.SendAs'
foreach ($prop in $PSBoundParameters.Keys | Where-Object {$body.PSObject.Properties.Name -contains $_}) {
$body.$prop = $PSBoundParameters[$prop]
}
$request = $service.Users.Settings.SendAs.Create($body,$User)
Write-Verbose "Creating new SendAs alias '$SendAsEmail' for user '$User'"
$request.Execute() | Add-Member -MemberType NoteProperty -Name 'User' -Value $User -PassThru
}
catch {
if ($ErrorActionPreference -eq 'Stop') {
$PSCmdlet.ThrowTerminatingError($_)
}
else {
Write-Error $_
}
}
}
}
Loading

0 comments on commit 702737e

Please sign in to comment.