Skip to content

Implements CRUD event operations. #13

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 29 commits into
base: master
Choose a base branch
from
Open

Implements CRUD event operations. #13

wants to merge 29 commits into from

Conversation

MalteRei
Copy link
Member

@MalteRei MalteRei commented May 1, 2020

Preparations

Please check if the PR fulfills these requirements

  • [X ] The commit message follows our guidelines
  • Tests for the changes have been added (for bug fixes / features)
  • [X ] Docs have been added / updated (for bug fixes / features)

🎫 Description

  • What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
    feature

  • What is the current behavior? (You can also link to an open issue here)
    Current behavior is not applicable because the application did not exist before.

  • What is the new behavior (if this is a feature change)?
    Add CRUD operations against Microsoft Graph for MCC events.

  • Does this PR introduce a breaking change? (What changes might users need to make in their application due to this PR?)
    No

  • Other information:

🔒 Closes

Which issue(s) is (are) being closed by the PR?
#3

MalteRei added 28 commits March 24, 2020 10:01
Creates a new project with an asp net core api application using https, no authentication and docker disabled
Someone with the right permissions needs to do a POST call to https://graph.microsoft.com/v1.0/schemaExtensions

Also I think type Boolean is not allowed for targetType event schema extension. Which is why we might have to change requiredPhotoAgreement

#1
…s public client in AAD under authentication
#3

Still need to do testing and figure out how we want to restrict the api in the regard which parts of the graph events we want to expose.
I got Username/Password flow to work by removing all permissions the application had in Azure and adding them back.
Removes all the code where I tried to get the graph authentication working.
To be able to have the schema extension as a type inside the event the MCCEvent can be created from an Outlook Event.
Found solution to Problem where casting additional data to the EventSchemaExtension object from JObject did not work. However, JObject has a conversion method.
Add documentation.
@MalteRei MalteRei self-assigned this May 1, 2020
@MalteRei MalteRei added the documentation Improvements or additions to documentation label May 1, 2020
@MalteRei MalteRei added the feature request New feature or request label May 1, 2020
@MalteRei MalteRei added this to the Version 1.0 milestone May 1, 2020
@MalteRei MalteRei linked an issue May 1, 2020 that may be closed by this pull request
@MalteRei MalteRei requested a review from urmade May 1, 2020 18:05
@urmade
Copy link
Member

urmade commented May 1, 2020

Could you please provide Build instructions to start the project locally or an URL to an endpoint where the code is deployed?

@MalteRei
Copy link
Member Author

MalteRei commented May 1, 2020

Could you please provide Build instructions to start the project locally or an URL to an endpoint where the code is deployed?

The code is not yet deployed because it needs to be secured first.
However, you can run it locally with the following steps:

  1. Create MCC-App_Event-Engine\Microsoft.CampusCommunity.EventEngine\Microsoft.CampusCommunity.EventEngine.Api/local.settings.json file. This file is not checked in to GitHub because of sensitive information.
  2. Inside local.settings.json add the following:

    {
    "IsEncrypted": false,
    "Values": {
    "AzureWebJobsStorage": "UseDevelopmentStorage=true",
    "FUNCTIONS_WORKER_RUNTIME": "dotnet",
    "Graph:TenantId": "[Insert tenant if here]",
    "Graph:ClientId": "b1e984e3-af89-43f2-bc75-13cdb5fa2948",
    "Graph:AdminPrincipalUsername": "[your mcc tenant username]",
    "Graph:AdminPrincipalPassword": "[your password]"
    }
    }
  3. Install Azure Functions Core Tools for this project you will need version 3.x
  4. In the command line navigate to MCC-App_Event-Engine\Microsoft.CampusCommunity.EventEngine\Microsoft.CampusCommunity.EventEngine.Api
  5. Run func start --build

When running it if you get an error along the lines of Could not find a part of the path 'D:\home\data\byob_graphmap' see this GitHub issue. I usually get this error. For me the solution of adding a different path to the configuration file does not solve the problem. This comment does work for me.

Please let me know if there are any issues.

@urmade
Copy link
Member

urmade commented May 2, 2020

Please specify that .net core 3.1 is required to run the program (had errors when trying to run func build with .net core 2.2). I now get the following error:

Microsoft.CampusCommunity.EventEngine.Api: Method not found: 'Microsoft.Extensions.DependencyInjection.IServiceCollection Microsoft.Azure.Functions.Extensions.DependencyInjection.IFunctionsHostBuilder.get_Services()'.
Value cannot be null.

Steps to reproduce:

  1. Clone repository.
  2. Install tools as described (.net core 3.1.201 and azure-functions-core-tools through npm)
  3. Run MCC-App_Event-Engine\Microsoft.CampusCommunity.EventEngine\Microsoft.CampusCommunity.EventEngine.Api>func start --build

Host Machine:
Windows 10 Version 10.0.18362 Build 18362
dotnet SDK: 3.1.201
.NET Core runtimes installed:
Microsoft.AspNetCore.All 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
Microsoft.AspNetCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.14 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 3.1.0 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 3.1.3 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]

Any hints on how to proceed?

@MalteRei
Copy link
Member Author

MalteRei commented May 2, 2020

I have no idea.
Maybe it is easier if you try it in Visual Studio.
The local.settings.json configuration stays the same.
Instead of steps 3. + 4. and 5. check that you have required Visual Studio tools installed. Open the solution file from MCC-App_Event-Engine\Microsoft.CampusCommunity.EventEngine in Visual Studio. Once all projects are loaded press F5 to run Azure Function locally.

@urmade
Copy link
Member

urmade commented May 9, 2020

Sorry for the long delay. These steps have worked for me:

  1. De-Install the npm packages azure-functions-core-tools (only necessary because I tried to install them manually before)
  2. Create new folder tmp in C:\Users{User}\
  3. Execute subst d: C:\Users\turba\tmp
  4. Go to Visual Studio, open project, start Microsoft.CampusCommunity.EventEngine.Api

To the actual functionality:
Where can I find documentation for the endpoints? It would be specifically interesting:

  • what kinds of Events the GET Events API returns (right now it is an empty Array),
  • what information is needed to POST a request and
  • what side-effects creating a new event has (in which calendar it is located, does it send any emails to everyone, ...)?

Please add this to the documentation.

@MalteRei
Copy link
Member Author

MalteRei commented May 10, 2020

I am glad it finally worked. Sorry for the inconvenience.

  1. what kinds of Events the GET Events API returns (right now it is an empty Array)
    If the GET Events API returns an empty array then it is most likely because there are no future events and by default past events are not returned. To show past events include a boolean parameter like so http://localhost:7071/api/v1/events?includePastEvents=true.
  2. what information is needed to POST a request
    Right now the event you can POST to the endpoint is similar to the MS Graph event.
    The main difference is that the event engine also accepts custom data. Namely readableId: String, planningStatus: String, titleImageUrl: String, requirePhotoAgreement: Boolean and supportRequestId: String.
    However, we can work together to think about what information the event engine should abstract because it is not needed.
    Example POST request body:
    "subject": "EventEngine test event",
    "body": {
        "contentType": "HTML",
        "content": "Nothing to see. 👀"
    },
    "start": {
        "dateTime": "2019-06-16T12:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "end": {
        "dateTime": "2019-06-16T14:00:00",
        "timeZone": "Pacific Standard Time"
    },
    "location": {
        "displayName": "online"
    },
    "attendees": [
        {
            "emailAddress": {
                "address": "[email protected]",
                "name": "Malte Reimann"
            },
            "type": "required"
        }
    ],
    
        "readableId": "humanReadableId",
        "planningStatus": "completed",
        "titleImageUrl": "https://tctechcrunch2011.files.wordpress.com/2015/10/6f9a9902.jpg",
        "requirePhotoAgreement": false,
        "supportRequestId": "long-term field to handle event support requests automatically later on"
    
}
  1. what side-effects creating a new event has (in which calendar it is located, does it send any emails to everyone, ...)?
    There are no side-effects. Emails are only send to the people listed in the attendees property. In addition the events can be deleted by sending a DELETE request with the event id. Events are located in the events group calendar (group id: 7a77d007-2cd2-4cb5-bb71-5ff85aa92e82).

@urmade
Copy link
Member

urmade commented May 11, 2020

Please provide a documentation on this before you merge it back into master. A good inspiration for this is https://commasto-api-dev.azurewebsites.net/swagger/index.html, but you can also write a markdown page explaining URLs, allowed query parameters, necessary body input and possible responses from the API.
Although this API isn't yet production ready, we should always keep it in a state where other developers could work and test with it locally.

@MalteRei
Copy link
Member Author

Please provide a documentation on this before you merge it back into master. A good inspiration for this is https://commasto-api-dev.azurewebsites.net/swagger/index.html, but you can also write a markdown page explaining URLs, allowed query parameters, necessary body input and possible responses from the API.
Although this API isn't yet production ready, we should always keep it in a state where other developers could work and test with it locally.

#14 is on the TODO list

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation feature request New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Implement get and create event features
2 participants