diff --git a/API/Lab1 - PokeAPI.zip b/API/Lab1 - PokeAPI.zip deleted file mode 100644 index 6e40192..0000000 Binary files a/API/Lab1 - PokeAPI.zip and /dev/null differ diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Program.cs b/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Program.cs deleted file mode 100644 index dbec262..0000000 --- a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Program.cs +++ /dev/null @@ -1,46 +0,0 @@ -using Scalar.AspNetCore; - -// 1. Модели теперь можно объявить здесь, так как они находятся внутри пространства имен -public record Pokemon(int Id, string Name, string Type, int Level); -public record PokemonInput(string Name, string Type, int Level); - -public class Program -{ - public static void Main(string[] args) - { - var builder = WebApplication.CreateBuilder(args); - - builder.Services.AddOpenApi(); - - var app = builder.Build(); - - var pokemons = new List - { - new(1, "Pikachu", "Electric", 12), - new(2, "Charmander", "Fire", 8), - new(3, "Squirtle", "Water", 10) - }; - - // GET /pokemons - app.MapGet("/pokemons/{id}", (int id) => - { - var pokemon = pokemons.FirstOrDefault(p => p.Id == id); - - return pokemon is null - ? Results.NotFound() - : Results.Ok(pokemon); - }); - - if (app.Environment.IsDevelopment()) - { - app.MapOpenApi(); - app.MapScalarApiReference(options => - { - options.WithTitle("Pokedex API") - .WithOpenApiRoutePattern("/openapi/v1.json"); - }); - } - - app.Run(); - } -} \ No newline at end of file diff --git a/API/Lab1 — PokeAPI/pokeapi.bruno.json b/API/Lab1 — PokeAPI/pokeapi.bruno.json deleted file mode 100644 index 97680e0..0000000 Binary files a/API/Lab1 — PokeAPI/pokeapi.bruno.json and /dev/null differ diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/delete -pokemons--id.yml b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/delete -pokemons--id.yml new file mode 100644 index 0000000..281a4c2 --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/delete -pokemons--id.yml @@ -0,0 +1,35 @@ +info: + name: delete /pokemons/:id + type: http + seq: 5 + tags: + - PokedexApi + +http: + method: DELETE + url: http://localhost:5211/pokemons/6 + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +examples: + - name: 200 Response + description: OK + request: + url: "{{baseUrl}}/pokemons/:id" + method: DELETE + params: + - name: id + value: "" + type: path + response: + status: 200 + statusText: OK + body: + type: text + data: "" diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/folder.yml b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/folder.yml new file mode 100644 index 0000000..f040f0b --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/folder.yml @@ -0,0 +1,6 @@ +info: + name: PokedexApi + type: folder + +request: + auth: inherit diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/get -pokemons--id.yml b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/get -pokemons--id.yml new file mode 100644 index 0000000..82ed2c9 --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/get -pokemons--id.yml @@ -0,0 +1,35 @@ +info: + name: get /pokemons/:id + type: http + seq: 3 + tags: + - PokedexApi + +http: + method: GET + url: http://localhost:5211/pokemons/5 + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +examples: + - name: 200 Response + description: OK + request: + url: "{{baseUrl}}/pokemons/:id" + method: GET + params: + - name: id + value: "" + type: path + response: + status: 200 + statusText: OK + body: + type: text + data: "" diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/get -pokemons.yml b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/get -pokemons.yml new file mode 100644 index 0000000..80cb5eb --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/get -pokemons.yml @@ -0,0 +1,31 @@ +info: + name: get /pokemons + type: http + seq: 2 + tags: + - PokedexApi + +http: + method: GET + url: http://localhost:5211/pokemons + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +examples: + - name: 200 Response + description: OK + request: + url: "{{baseUrl}}/pokemons" + method: GET + response: + status: 200 + statusText: OK + body: + type: text + data: "" diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/post -pokemons.yml b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/post -pokemons.yml new file mode 100644 index 0000000..1422ea8 --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/post -pokemons.yml @@ -0,0 +1,47 @@ +info: + name: post /pokemons + type: http + seq: 3 + tags: + - PokedexApi + +http: + method: POST + url: http://localhost:5211/pokemons + body: + type: json + data: |- + { + "name": "Pikachu", + "type": "Electric", + "level": 12 + } + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +examples: + - name: 200 Response + description: OK + request: + url: "{{baseUrl}}/pokemons" + method: POST + body: + type: json + data: |- + { + "name": "", + "type": "", + "level": "" + } + response: + status: 200 + statusText: OK + body: + type: text + data: "" diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/put -pokemons--id.yml b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/put -pokemons--id.yml new file mode 100644 index 0000000..bf44d6c --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/PokedexApi/put -pokemons--id.yml @@ -0,0 +1,51 @@ +info: + name: put /pokemons/:id + type: http + seq: 5 + tags: + - PokedexApi + +http: + method: PUT + url: http://localhost:5211/pokemons/1 + body: + type: json + data: |- + { + "name": "Raichu", + "type": "Electric", + "level": 32 + } + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +examples: + - name: 200 Response + description: OK + request: + url: "{{baseUrl}}/pokemons/:id" + method: PUT + params: + - name: id + value: "" + type: path + body: + type: json + data: |- + { + "name": "", + "type": "", + "level": "" + } + response: + status: 200 + statusText: OK + body: + type: text + data: "" diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/environments/Environment 1.yml b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/environments/Environment 1.yml new file mode 100644 index 0000000..19ba1fc --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/environments/Environment 1.yml @@ -0,0 +1,4 @@ +name: Environment 1 +variables: + - name: baseUrl + value: http://localhost:5211 diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/opencollection.yml b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/opencollection.yml new file mode 100644 index 0000000..56921c6 --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1 - 1/opencollection.yml @@ -0,0 +1,10 @@ +opencollection: 1.0.0 + +info: + name: PokedexApi | v1 - 1 +bundled: false +extensions: + bruno: + ignore: + - node_modules + - .git diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/folder.yml b/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/folder.yml new file mode 100644 index 0000000..f040f0b --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/folder.yml @@ -0,0 +1,6 @@ +info: + name: PokedexApi + type: folder + +request: + auth: inherit diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/get -hello.yml b/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/get -hello.yml new file mode 100644 index 0000000..4f14b68 --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/get -hello.yml @@ -0,0 +1,34 @@ +info: + name: get /hello + type: http + seq: 1 + tags: + - PokedexApi + +http: + method: GET + url: "{{baseUrl}}/hello" + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +examples: + - name: 200 Response + description: OK + request: + url: "{{baseUrl}}/hello" + method: GET + response: + status: 200 + statusText: OK + headers: + - name: Content-Type + value: text/plain + body: + type: text + data: "" diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/get -pokemons--id.yml b/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/get -pokemons--id.yml new file mode 100644 index 0000000..1fc60da --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/get -pokemons--id.yml @@ -0,0 +1,39 @@ +info: + name: get /pokemons/:id + type: http + seq: 3 + tags: + - PokedexApi + +http: + method: GET + url: "{{baseUrl}}/pokemons/:id" + params: + - name: id + value: "" + type: path + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +examples: + - name: 200 Response + description: OK + request: + url: "{{baseUrl}}/pokemons/:id" + method: GET + params: + - name: id + value: "" + type: path + response: + status: 200 + statusText: OK + body: + type: text + data: "" diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/get -pokemons.yml b/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/get -pokemons.yml new file mode 100644 index 0000000..81a34eb --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1/PokedexApi/get -pokemons.yml @@ -0,0 +1,31 @@ +info: + name: get /pokemons + type: http + seq: 2 + tags: + - PokedexApi + +http: + method: GET + url: "{{baseUrl}}/pokemons" + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +examples: + - name: 200 Response + description: OK + request: + url: "{{baseUrl}}/pokemons" + method: GET + response: + status: 200 + statusText: OK + body: + type: text + data: "" diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1/environments/Environment 1.yml b/API/lab-01/BrunoCollections/PokedexApi - v1/environments/Environment 1.yml new file mode 100644 index 0000000..19ba1fc --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1/environments/Environment 1.yml @@ -0,0 +1,4 @@ +name: Environment 1 +variables: + - name: baseUrl + value: http://localhost:5211 diff --git a/API/lab-01/BrunoCollections/PokedexApi - v1/opencollection.yml b/API/lab-01/BrunoCollections/PokedexApi - v1/opencollection.yml new file mode 100644 index 0000000..d06d32c --- /dev/null +++ b/API/lab-01/BrunoCollections/PokedexApi - v1/opencollection.yml @@ -0,0 +1,34 @@ +opencollection: 1.0.0 + +info: + name: PokedexApi | v1 + version: "1" +config: + proxy: + inherit: true + config: + protocol: http + hostname: "" + port: "" + auth: + username: "" + password: "" + bypassProxy: "" + +request: + variables: + - name: baseUrl + value: http://localhost:5211 +bundled: false +extensions: + bruno: + ignore: + - node_modules + - .git + openapi: + - sourceUrl: ../../v1.json + groupBy: tags + lastSyncDate: 2026-10-15T12:42:49.890Z + specHash: 3772da9d0fb4ef0d1ddc6bccd9094f9d + autoCheck: true + autoCheckInterval: 5 diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi.sln b/API/lab-01/PokedexApi/PokedexApi.sln similarity index 57% rename from API/Lab1 — PokeAPI/PokedexApi/PokedexApi.sln rename to API/lab-01/PokedexApi/PokedexApi.sln index 5f83476..a9cdaee 100644 --- a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi.sln +++ b/API/lab-01/PokedexApi/PokedexApi.sln @@ -1,6 +1,6 @@  Microsoft Visual Studio Solution File, Format Version 12.00 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokedexApi", "PokedexApi\PokedexApi.csproj", "{0AC1C38E-7B58-4271-9193-B74B674ECF6C}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "PokedexApi", "PokedexApi\PokedexApi.csproj", "{9A30BAE9-E0E9-413B-953F-26F43F01E17F}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -8,9 +8,9 @@ Global Release|Any CPU = Release|Any CPU EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Debug|Any CPU.Build.0 = Debug|Any CPU - {0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Release|Any CPU.ActiveCfg = Release|Any CPU - {0AC1C38E-7B58-4271-9193-B74B674ECF6C}.Release|Any CPU.Build.0 = Release|Any CPU + {9A30BAE9-E0E9-413B-953F-26F43F01E17F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9A30BAE9-E0E9-413B-953F-26F43F01E17F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9A30BAE9-E0E9-413B-953F-26F43F01E17F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9A30BAE9-E0E9-413B-953F-26F43F01E17F}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection EndGlobal diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.csproj b/API/lab-01/PokedexApi/PokedexApi/PokedexApi.csproj similarity index 100% rename from API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.csproj rename to API/lab-01/PokedexApi/PokedexApi/PokedexApi.csproj diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.http b/API/lab-01/PokedexApi/PokedexApi/PokedexApi.http similarity index 62% rename from API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.http rename to API/lab-01/PokedexApi/PokedexApi/PokedexApi.http index f4fd3c7..836e73b 100644 --- a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/PokedexApi.http +++ b/API/lab-01/PokedexApi/PokedexApi/PokedexApi.http @@ -1,4 +1,4 @@ -@PokedexApi_HostAddress = http://localhost:5116 +@PokedexApi_HostAddress = http://localhost:5211 GET {{PokedexApi_HostAddress}}/weatherforecast/ Accept: application/json diff --git a/API/lab-01/PokedexApi/PokedexApi/Program.cs b/API/lab-01/PokedexApi/PokedexApi/Program.cs new file mode 100644 index 0000000..3adf7f0 --- /dev/null +++ b/API/lab-01/PokedexApi/PokedexApi/Program.cs @@ -0,0 +1,86 @@ +using Scalar.AspNetCore; + +var builder = WebApplication.CreateBuilder(args); + +builder.Services.AddOpenApi(); + +var app = builder.Build(); + +if (app.Environment.IsDevelopment()) +{ + app.MapOpenApi(); + app.MapScalarApiReference(); +} + +var pokemons = new List +{ + new(1, "Pikachu", "Electric", 12), + new(2, "Charmander", "Fire", 8), + new(3, "Squirtle", "Water", 10) +}; + +app.MapGet("/pokemons", () => Results.Ok(pokemons)); + +app.MapGet("/pokemons/{id}", (int id) => +{ + var pokemon = pokemons.FirstOrDefault(p => p.Id == id); + return pokemon is null ? Results.NotFound() : Results.Ok(pokemon); +}); + +app.MapPost("/pokemons", (PokemonInput input) => +{ + var errors = Validate(input); + if (errors.Count > 0) + { + return Results.BadRequest(new { errors }); + } + + var newId = pokemons.Count > 0 ? pokemons.Max(p => p.Id) + 1 : 1; + var pokemon = new Pokemon(newId, input.Name, input.Type, input.Level); + pokemons.Add(pokemon); + return Results.Created($"/pokemons/{newId}", pokemon); +}); + +app.MapPut("/pokemons/{id}", (int id, PokemonInput input) => +{ + var existing = pokemons.FirstOrDefault(p => p.Id == id); + if (existing is null) + { + return Results.NotFound(); + } + + var errors = Validate(input); + if (errors.Count > 0) + { + return Results.BadRequest(new { errors }); + } + + var updated = new Pokemon(id, input.Name, input.Type, input.Level); + pokemons[pokemons.IndexOf(existing)] = updated; + return Results.Ok(updated); +}); + +app.MapDelete("/pokemons/{id}", (int id) => +{ + var existing = pokemons.FirstOrDefault(p => p.Id == id); + if (existing is null) + { + return Results.NotFound(); + } + pokemons.Remove(existing); + return Results.NoContent(); +}); + +app.Run(); + +List Validate(PokemonInput input) +{ + var errors = new List(); + if (string.IsNullOrWhiteSpace(input.Name)) errors.Add("Имя не может быть пустым."); + if (string.IsNullOrWhiteSpace(input.Type)) errors.Add("Тип не может быть пустым."); + if (input.Level <= 0) errors.Add("Уровень должен быть больше 0."); + return errors; +} + +public record Pokemon(int Id, string Name, string Type, int Level); +public record PokemonInput(string Name, string Type, int Level); \ No newline at end of file diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Properties/launchSettings.json b/API/lab-01/PokedexApi/PokedexApi/Properties/launchSettings.json similarity index 80% rename from API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Properties/launchSettings.json rename to API/lab-01/PokedexApi/PokedexApi/Properties/launchSettings.json index 555b35a..a75e319 100644 --- a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/Properties/launchSettings.json +++ b/API/lab-01/PokedexApi/PokedexApi/Properties/launchSettings.json @@ -5,7 +5,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "http://localhost:5116", + "applicationUrl": "http://localhost:5211", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -14,7 +14,7 @@ "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": false, - "applicationUrl": "https://localhost:7103;http://localhost:5116", + "applicationUrl": "https://localhost:7050;http://localhost:5211", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.Development.json b/API/lab-01/PokedexApi/PokedexApi/appsettings.Development.json similarity index 100% rename from API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.Development.json rename to API/lab-01/PokedexApi/PokedexApi/appsettings.Development.json diff --git a/API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.json b/API/lab-01/PokedexApi/PokedexApi/appsettings.json similarity index 100% rename from API/Lab1 — PokeAPI/PokedexApi/PokedexApi/appsettings.json rename to API/lab-01/PokedexApi/PokedexApi/appsettings.json diff --git a/API/Lab1 — PokeAPI/.gitignore b/API/lab-01/lab-01 - PokeAPI/.gitignore similarity index 100% rename from API/Lab1 — PokeAPI/.gitignore rename to API/lab-01/lab-01 - PokeAPI/.gitignore diff --git a/API/lab-01/lab-01 - PokeAPI/1 request.yml b/API/lab-01/lab-01 - PokeAPI/1 request.yml new file mode 100644 index 0000000..848f74f --- /dev/null +++ b/API/lab-01/lab-01 - PokeAPI/1 request.yml @@ -0,0 +1,21 @@ +info: + name: "1 request " + type: http + seq: 1 + +http: + method: GET + url: https://pokeapi.co/api/v2/pokemon/pikachu + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +docs: |- + 1 запрос: + + Вывод покемона по имени diff --git a/API/lab-01/lab-01 - PokeAPI/2 request.yml b/API/lab-01/lab-01 - PokeAPI/2 request.yml new file mode 100644 index 0000000..e28fb84 --- /dev/null +++ b/API/lab-01/lab-01 - PokeAPI/2 request.yml @@ -0,0 +1,23 @@ +info: + name: 2 request + type: http + seq: 2 + +http: + method: GET + url: https://pokeapi.co/api/v2/pokemon/25 + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +docs: |- + 2 запрос: + + Вывод покемона по id + +
diff --git a/API/lab-01/lab-01 - PokeAPI/3 request.yml b/API/lab-01/lab-01 - PokeAPI/3 request.yml new file mode 100644 index 0000000..d9c2e69 --- /dev/null +++ b/API/lab-01/lab-01 - PokeAPI/3 request.yml @@ -0,0 +1,28 @@ +info: + name: 3 request + type: http + seq: 3 + +http: + method: GET + url: https://pokeapi.co/api/v2/pokemon?limit=5&offset=0 + params: + - name: limit + value: "5" + type: query + - name: offset + value: "0" + type: query + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +docs: |- + 3 запрос: + + Вывод списка покемонов diff --git a/API/lab-01/lab-01 - PokeAPI/4 request.yml b/API/lab-01/lab-01 - PokeAPI/4 request.yml new file mode 100644 index 0000000..912b2e9 --- /dev/null +++ b/API/lab-01/lab-01 - PokeAPI/4 request.yml @@ -0,0 +1,21 @@ +info: + name: 4 request + type: http + seq: 4 + +http: + method: GET + url: https://pokeapi.co/api/v2/type/electric + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +docs: |- + 4 запрос: + + Вывод информации о типе diff --git a/API/lab-01/lab-01 - PokeAPI/5 request.yml b/API/lab-01/lab-01 - PokeAPI/5 request.yml new file mode 100644 index 0000000..7f2d461 --- /dev/null +++ b/API/lab-01/lab-01 - PokeAPI/5 request.yml @@ -0,0 +1,29 @@ +info: + name: 5 request + type: http + seq: 5 + +http: + method: POST + url: https://jsonplaceholder.typicode.com/posts + body: + type: json + data: |- + { + "title": "Мой первый покемон", + "body": "Поймал Пикачу!", + "userId": 1 + } + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +docs: |- + 5 запрос: + + Создания ресурсов diff --git a/API/lab-01/lab-01 - PokeAPI/6 request.yml b/API/lab-01/lab-01 - PokeAPI/6 request.yml new file mode 100644 index 0000000..a16fb23 --- /dev/null +++ b/API/lab-01/lab-01 - PokeAPI/6 request.yml @@ -0,0 +1,23 @@ +info: + name: 6 request + type: http + seq: 6 + +http: + method: GET + url: https://pokeapi.co/api/v2/pokemon/unknown-pokemon-xyz + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +docs: |- + запрос 6: + + Вывод ошибки + +
diff --git a/API/Lab1 — PokeAPI/opencollection.yml b/API/lab-01/lab-01 - PokeAPI/opencollection.yml similarity index 81% rename from API/Lab1 — PokeAPI/opencollection.yml rename to API/lab-01/lab-01 - PokeAPI/opencollection.yml index 58c2d98..0dce206 100644 --- a/API/Lab1 — PokeAPI/opencollection.yml +++ b/API/lab-01/lab-01 - PokeAPI/opencollection.yml @@ -1,7 +1,7 @@ opencollection: 1.0.0 info: - name: Lab1 — PokeAPI + name: lab-01 - PokeAPI bundled: false extensions: bruno: diff --git a/API/lab-01/lab-01 - PokeAPI/request bonus.yml b/API/lab-01/lab-01 - PokeAPI/request bonus.yml new file mode 100644 index 0000000..7e2ea87 --- /dev/null +++ b/API/lab-01/lab-01 - PokeAPI/request bonus.yml @@ -0,0 +1,28 @@ +info: + name: request bonus + type: http + seq: 7 + +http: + method: GET + url: https://pokeapi.co/api/v2/pokemon?limit=3&offset=10 + params: + - name: limit + value: "3" + type: query + - name: offset + value: "10" + type: query + auth: inherit + +settings: + encodeUrl: true + timeout: 0 + followRedirects: true + maxRedirects: 5 + forwardAuthorizationHeader: false + +docs: |- + запрос 7: + + Вывод информация о покемонах 3 со смещением 10 diff --git a/API/lab-01/v1.json b/API/lab-01/v1.json new file mode 100644 index 0000000..d93365b --- /dev/null +++ b/API/lab-01/v1.json @@ -0,0 +1,185 @@ +{ + "openapi": "3.1.1", + "info": { + "title": "PokedexApi | v1", + "version": "1.0.0" + }, + "servers": [ + { + "url": "http://localhost:5211/" + } + ], + "paths": { + "/hello": { + "get": { + "tags": [ + "PokedexApi" + ], + "responses": { + "200": { + "description": "OK", + "content": { + "text/plain": { + "schema": { + "type": "string" + } + } + } + } + } + } + }, + "/pokemons": { + "get": { + "tags": [ + "PokedexApi" + ], + "responses": { + "200": { + "description": "OK" + } + } + }, + "post": { + "tags": [ + "PokedexApi" + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PokemonInput" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + } + }, + "/pokemons/{id}": { + "get": { + "tags": [ + "PokedexApi" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "pattern": "^-?(?:0|[1-9]\\d*)$", + "type": [ + "integer", + "string" + ], + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + }, + "put": { + "tags": [ + "PokedexApi" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "pattern": "^-?(?:0|[1-9]\\d*)$", + "type": [ + "integer", + "string" + ], + "format": "int32" + } + } + ], + "requestBody": { + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/PokemonInput" + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "OK" + } + } + }, + "delete": { + "tags": [ + "PokedexApi" + ], + "parameters": [ + { + "name": "id", + "in": "path", + "required": true, + "schema": { + "pattern": "^-?(?:0|[1-9]\\d*)$", + "type": [ + "integer", + "string" + ], + "format": "int32" + } + } + ], + "responses": { + "200": { + "description": "OK" + } + } + } + } + }, + "components": { + "schemas": { + "PokemonInput": { + "required": [ + "name", + "type", + "level" + ], + "type": "object", + "properties": { + "name": { + "type": "string" + }, + "type": { + "type": "string" + }, + "level": { + "pattern": "^-?(?:0|[1-9]\\d*)$", + "type": [ + "integer", + "string" + ], + "format": "int32" + } + } + } + } + }, + "tags": [ + { + "name": "PokedexApi" + } + ] +} \ No newline at end of file diff --git a/PostgresSQL/Script.sql b/PostgresSQL/Script.sql index c1ecf9a..9f76eb9 100644 --- a/PostgresSQL/Script.sql +++ b/PostgresSQL/Script.sql @@ -105,4 +105,124 @@ CREATE TABLE caught_pokemon ( catch_region_id INTEGER REFERENCES region(region_id) ON DELETE SET NULL ); +INSERT INTO ability (ability_name, ability_description, ability_is_hidden) VALUES +('Overgrow', 'Усиливает травяные приёмы при низком HP', false), +('Chlorophyll', 'Удваивает скорость под ярким солнцем', false), +('Blaze', 'Усиливает огненные приёмы при низком HP', false), +('Solar Power', 'Повышает Sp. Atk на солнце, но теряет HP', true), +('Torrent', 'Усиливает водные приёмы при низком HP', false), +('Rain Dish', 'Восстанавливает HP под дождём', true), +('Shield Dust', 'Блокирует дополнительные эффекты атак', false), +('Run Away', 'Гарантирует побег от диких покемонов', false), +('Keen Eye', 'Не понижает точность', false), +('Tangled Feet', 'Повышает уклонение при путанице', true), +('Intimidate', 'Понижает атаку противника при выходе', false), +('Static', 'Может парализовать при контакте', false), +('Lightning Rod', 'Притягивает электрические атаки', true), +('Sand Veil', 'Повышает уклонение в песчаную бурю', false), +('Poison Point', 'Может отравить при контакте', false), +('Rivalry', 'Усиливает атаки против соперников того же пола', false), +('Levitate', 'Иммунитет к наземным атакам', false), +('Flash Fire', 'Поглощает огненные атаки и усиливает свои', false), +('Drought', 'Вызывает яркое солнце при выходе', true), +('Speed Boost', 'Повышает скорость каждый ход', true); +INSERT INTO move (move_name, type_id, move_category, move_power, move_accuracy, move_pp, move_description) VALUES +('Tackle', 1, 'physical', 40, 100, 35, 'Простой физический удар'), +('Growl', 1, 'status', NULL, 100, 40, 'Понижает атаку противника'), +('Vine Whip', 5, 'physical', 45, 100, 25, 'Удар лозой'), +('Razor Leaf', 5, 'physical', 55, 95, 25, 'Острые листья с высоким шансом крита'), +('Ember', 2, 'special', 40, 100, 25, 'Небольшой огненный шар'), +('Flamethrower', 2, 'special', 90, 100, 15, 'Мощная струя пламени'), +('Water Gun', 3, 'special', 40, 100, 25, 'Струя воды'), +('Hydro Pump', 3, 'special', 110, 80, 5, 'Мощный поток воды'), +('Thunder Shock', 4, 'special', 40, 100, 30, 'Электрический разряд с шансом паралича'), +('Thunderbolt', 4, 'special', 90, 100, 15, 'Сильный электрический удар'), +('Quick Attack', 1, 'physical', 40, 100, 30, 'Всегда бьёт первым'), +('Body Slam', 1, 'physical', 85, 100, 15, 'Тяжёлый удар телом с шансом паралича'), +('Ice Beam', 6, 'special', 90, 100, 10, 'Ледяной луч с шансом заморозки'), +('Blizzard', 6, 'special', 110, 70, 5, 'Мощная снежная буря'), +('Karate Chop', 7, 'physical', 50, 100, 25, 'Рубящий удар с высоким шансом крита'), +('Sludge Bomb', 8, 'special', 90, 100, 10, 'Бомба из токсичного ила'), +('Earthquake', 9, 'physical', 100, 100, 10, 'Мощное сотрясение земли'), +('Wing Attack', 10, 'physical', 60, 100, 35, 'Удар крылом'), +('Psychic', 11, 'special', 90, 100, 10, 'Психическая атака с шансом понизить Sp. Def'), +('Leech Life', 12, 'physical', 80, 100, 10, 'Высасывает HP противника'), +('Rock Slide', 13, 'physical', 75, 90, 10, 'Камнепад с шансом испуга'), +('Shadow Ball', 14, 'special', 80, 100, 15, 'Шар теней с шансом понизить Sp. Def'), +('Dragon Claw', 15, 'physical', 80, 100, 15, 'Удар драконьим когтем'), +('Crunch', 16, 'physical', 80, 100, 15, 'Укус с шансом понизить защиту'), +('Iron Tail', 17, 'physical', 100, 75, 15, 'Удар стальным хвостом'), +('Dazzling Gleam', 18, 'special', 80, 100, 10, 'Ослепительная вспышка'), +('Swords Dance', 1, 'status', NULL, NULL, 20, 'Сильно повышает атаку'), +('Recover', 1, 'status', NULL, NULL, 25, 'Восстанавливает половину HP'), +('Rest', 11, 'status', NULL, NULL, 5, 'Полностью восстанавливает HP и засыпает'), +('Surf', 3, 'special', 90, 100, 15, 'Большая волна, бьющая всех вокруг'); + +INSERT INTO pokemon (pokemon_national_dex_number, pokemon_name, pokemon_species, pokemon_height, pokemon_weight, pokemon_base_hp, pokemon_base_attack, pokemon_base_defense, +pokemon_base_sp_attack, pokemon_base_sp_defense, pokemon_base_speed, pokemon_is_legendary, pokemon_is_mythical, region_id, pokemon_description) VALUES +(1, 'Bulbasaur', 'Seed Pokémon', 0.70, 6.90, 45, 49, 49, 65, 65, 45, false, false, 1, 'На спине носит семечко, которое растёт вместе с ним'), +(2, 'Ivysaur', 'Seed Pokémon', 1.00, 13.00, 60, 62, 63, 80, 80, 60, false, false, 1, 'Бутон на спине готовится расцвести'), +(3, 'Venusaur', 'Seed Pokémon', 2.00, 100.00, 80, 82, 83, 100, 100, 80, false, false, 1, 'Цветок на спине испускает приятный аромат'), +(4, 'Charmander', 'Lizard Pokémon', 0.60, 8.50, 39, 52, 43, 60, 50, 65, false, false, 1, 'Огонь на хвосте гаснет, если покемон слаб'), +(5, 'Charmeleon', 'Flame Pokémon', 1.10, 19.00, 58, 64, 58, 80, 65, 80, false, false, 1, 'Жестокий покемон, любит сражения'), +(6, 'Charizard', 'Flame Pokémon', 1.70, 90.50, 78, 84, 78, 109, 85, 100, false, false, 1, 'Летающий дракон, дышащий огнём'), +(7, 'Squirtle', 'Tiny Turtle Pokémon', 0.50, 9.00, 44, 48, 65, 50, 64, 43, false, false, 1, 'Прячется в панцирь при опасности'), +(8, 'Wartortle', 'Turtle Pokémon', 1.00, 22.50, 59, 63, 80, 65, 80, 58, false, false, 1, 'Символ долголетия, хвост покрыт мехом'), +(9, 'Blastoise', 'Shellfish Pokémon', 1.60, 85.50, 79, 83, 100, 85, 105, 78, false, false, 1, 'Струи воды из пушек на панцире пробивают сталь'), +(10, 'Caterpie', 'Worm Pokémon', 0.30, 2.90, 45, 30, 35, 20, 20, 45, false, false, 1, 'Выделяет нить для ловли врагов'), +(12, 'Butterfree', 'Butterfly Pokémon', 1.10, 32.00, 60, 45, 50, 90, 80, 70, false, false, 1, 'Крылья покрыты водоотталкивающей пыльцой'), +(25, 'Pikachu', 'Mouse Pokémon', 0.40, 6.00, 35, 55, 40, 50, 50, 90, false, false, 1, 'Накапливает электричество в щеках'), +(26, 'Raichu', 'Mouse Pokémon', 0.80, 30.00, 60, 90, 55, 90, 80, 110, false, false, 1, 'Хвост служит заземлением'), +(133, 'Eevee', 'Evolution Pokémon', 0.30, 6.50, 55, 55, 50, 45, 65, 55, false, false, 1, 'Нестабильная генетика позволяет много эволюций'), +(134, 'Vaporeon', 'Bubble Jet Pokémon', 1.00, 29.00, 130, 65, 60, 110, 95, 65, false, false, 1, 'Клетки тела похожи на воду'), +(135, 'Jolteon', 'Lightning Pokémon', 0.80, 24.50, 65, 65, 60, 110, 95, 130, false, false, 1, 'Шерсть накапливает электричество'), +(136, 'Flareon', 'Flame Pokémon', 0.90, 25.00, 65, 130, 60, 95, 110, 65, false, false, 1, 'Температура тела достигает 900 °C'), +(143, 'Snorlax', 'Sleeping Pokémon', 2.10, 460.00, 160, 110, 65, 65, 110, 30, false, false, 1, 'Ест и спит почти всё время'), +(150, 'Mewtwo', 'Genetic Pokémon', 2.00, 122.00, 106, 110, 90, 154, 90, 130, true, false, 1, 'Создан из ДНК Мью, обладает огромной силой'), +(151, 'Mew', 'New Species Pokémon', 0.40, 4.00, 100, 100, 100, 100, 100, 100, false, true, 1, 'Считается предком всех покемонов'), +(152, 'Chikorita', 'Leaf Pokémon', 0.90, 6.40, 45, 49, 65, 49, 65, 45, false, false, 2, 'Лист на голове определяет настроение'), +(155, 'Cyndaquil', 'Fire Mouse Pokémon', 0.50, 7.90, 39, 52, 43, 60, 50, 65, false, false, 2, 'Выпускает огонь из спины при угрозе'), +(158, 'Totodile', 'Big Jaw Pokémon', 0.60, 9.50, 50, 65, 64, 44, 48, 43, false, false, 2, 'Мощные челюсти способны перекусить всё'), +(249, 'Lugia', 'Diving Pokémon', 5.20, 216.00, 106, 90, 130, 90, 154, 110, true, false, 2, 'Страж морей, живёт в глубоких впадинах'), +(252, 'Treecko', 'Wood Gecko Pokémon', 0.50, 5.00, 40, 45, 35, 65, 55, 70, false, false, 3, 'Лазает по стенам благодаря клейким лапам'), +(255, 'Torchic', 'Chick Pokémon', 0.40, 2.50, 45, 60, 40, 70, 50, 45, false, false, 3, 'Плюётся огнём, внутри пылает пламя'), +(258, 'Mudkip', 'Mud Fish Pokémon', 0.40, 7.60, 50, 70, 50, 50, 50, 40, false, false, 3, 'Плавник на голове чувствует движение воды'), +(384, 'Rayquaza', 'Sky High Pokémon', 7.00, 206.50, 105, 150, 90, 150, 90, 95, true, false, 3, 'Живёт в озоновом слое и управляет погодой'), +(387, 'Turtwig', 'Tiny Leaf Pokémon', 0.40, 10.20, 55, 68, 64, 45, 55, 31, false, false, 4, 'Панцирь из земли, пьёт воду кожей'), +(390, 'Chimchar', 'Chimp Pokémon', 0.50, 6.20, 44, 58, 44, 58, 44, 61, false, false, 4, 'Огонь на хвосте горит постоянно'), +(393, 'Piplup', 'Penguin Pokémon', 0.40, 5.20, 53, 51, 53, 61, 56, 40, false, false, 4, 'Гордый покемон, не любит принимать еду'), +(493, 'Arceus', 'Alpha Pokémon', 3.20, 320.00, 120, 120, 120, 120, 120, 120, false, true, 4, 'Считается создателем вселенной покемонов'); + +INSERT INTO region (region_name, region_generation, region_description) VALUES +('Kanto', 1, 'Первый регион, где началась история покемонов'), +('Johto', 2, 'Регион с богатой историей и традициями'), +('Hoenn', 3, 'Тропический регион с большим количеством воды'), +('Sinnoh', 4, 'Холодный северный регион с горами'), +('Unova', 5, 'Регион, вдохновлённый Нью-Йорком'), +('Kalos', 6, 'Регион, вдохновлённый Францией'), +('Alola', 7, 'Тропический архипелаг из четырёх островов'), +('Galar', 8, 'Регион, вдохновлённый Великобританией'), +('Paldea', 9, 'Пиренейский регион с открытым миром'); + +INSERT INTO type (type_name, type_color_hex) VALUES +('Normal', '#A8A77A'), +('Fire', '#EE8130'), +('Water', '#6390F0'), +('Electric', '#F7D02C'), +('Grass', '#7AC74C'), +('Ice', '#96D9D6'), +('Fighting', '#C22E28'), +('Poison', '#A33EA1'), +('Ground', '#E2BF65'), +('Flying', '#A98FF3'), +('Psychic', '#F95587'), +('Bug', '#A6B91A'), +('Rock', '#86A136'), +('Ghost', '#735797'), +('Dragon', '#6F35FC'), +('Dark', '#705746'), +('Steel', '#B7B7CE'), +('Fairy', '#D685AD'); + +SELECT * FROM type \ No newline at end of file diff --git a/Новый текстовый документ.txt b/Новый текстовый документ.txt deleted file mode 100644 index 300d034..0000000 --- a/Новый текстовый документ.txt +++ /dev/null @@ -1,52 +0,0 @@ -PS Z:\> Get-Service -Name postgresql* -PS Z:\> Start-Service -Name postgresql-x64-14 26.1.5 -Start-Service : Не удается найти позиционный параметр, принимающий аргумент "26.1.5". -строка:1 знак:1 -+ Start-Service -Name postgresql-x64-14 26.1.5 -+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - + CategoryInfo : InvalidArgument: (:) [Start-Service], ParameterBindingException - + FullyQualifiedErrorId : PositionalParameterNotFound,Microsoft.PowerShell.Commands.StartServiceCommand - -PS Z:\> docker ps -failed to connect to the docker API at npipe:////./pipe/dockerDesktopLinuxEngine; check if the path is correct and if the daemon is running: open //./pipe/dockerDesktopLinuxEngine: The system cannot find the file specified. -PS Z:\> docker ps -a -CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -a9d7eff4a438 postgres "docker-entrypoint.s…" 6 weeks ago Exited (1) 6 weeks ago test -PS Z:\> docker start postgres -Error response from daemon: No such container: postgres -failed to start containers: postgres -PS Z:\> docker start test -test -PS Z:\> docker ps -CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -PS Z:\> docker logs test -Error: Database is uninitialized and superuser password is not specified. - You must specify POSTGRES_PASSWORD to a non-empty value for the - superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". - - You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all - connections without a password. This is *not* recommended. - - See PostgreSQL documentation about "trust": - https://www.postgresql.org/docs/current/auth-trust.html -Error: Database is uninitialized and superuser password is not specified. - You must specify POSTGRES_PASSWORD to a non-empty value for the - superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". - - You may also use "POSTGRES_HOST_AUTH_METHOD=trust" to allow all - connections without a password. This is *not* recommended. - - See PostgreSQL documentation about "trust": - https://www.postgresql.org/docs/current/auth-trust.html -Error: Database is uninitialized and superuser password is not specified. - You must specify POSTGRES_PASSWORD to a non-empty value for the - superuser. For example, "-e POSTGRES_PASSWORD=password" on "docker run". - -PS Z:\> docker rm test -test -PS Z:\> docker run --name test -p 5432:5432 -e POSTGRES_PASSWORD=pokedex_pass -d postgres -37830188239ba74b3fb1bdaaee83681304754f815f2ffeae507900b85f82b2d8 -PS Z:\> docker ps -CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES -37830188239b postgres "docker-entrypoint.s…" 18 seconds ago Up 17 seconds 0.0.0.0:5432->5432/tcp, [::]:5432->5432/tcp test -PS Z:\> \ No newline at end of file